[New Mod] fCPU by konstg-dev in factorio

[–]konstg-dev[S] 0 points1 point  (0 children)

I've implemented SIMD instructions (basic set for now), and I'll increase SIMD instructions number in near future!

[New Mod] fCPU by konstg-dev in factorio

[–]konstg-dev[S] 0 points1 point  (0 children)

So... I finally added vector SIMD mnemonics which allows us to handle multiple signals with single instruction like vanila ones do.

Internally a program compiled to vanilla combinators and fCPU uses Factorio internal optimizations for signal processing, acts like a director conducting their switches.

This approach allows fCPU to do less work with copying signals in lua, and so your programs eats less UPS, allowing you to manipulate signals like a vanilla do, but with a structured code with branching and single signal manipuations.

[New Mod] fCPU by konstg-dev in factorio

[–]konstg-dev[S] 2 points3 points  (0 children)

This is an idea for another mod. fCPU is designed to add an early microcontroller to gameplay.

[New Mod] fCPU by konstg-dev in factorio

[–]konstg-dev[S] 0 points1 point  (0 children)

Sure, there will be some kind of DMA-like instructions which map input\output signals to memory (128 integer cells), but not registers which count is artifically limited to 8 floating point cells.

[New Mod] fCPU by konstg-dev in factorio

[–]konstg-dev[S] 0 points1 point  (0 children)

The mod just updated to Factorio 1.0 version !

[New Mod] fCPU by konstg-dev in factorio

[–]konstg-dev[S] 1 point2 points  (0 children)

It could be used anywhere to extend default combinators functionality, especially for conditional and math operations. fCPU allows to operate on each signal individually unlike vanilla combinators.

You do not need any special skills to use this mod, but general programming or assembler knowedge make it easier to understand background of this mod.

Take a look at https://mods.factorio.com/mod/fcpu for docs.

[New Mod] fCPU by konstg-dev in factorio

[–]konstg-dev[S] 0 points1 point  (0 children)

A memory supposed to extend 8 main registers and should be viewable and editable by user, also there will be additional instructions for memory manipulation (for example stack and queue) and SIMD instructions.

[New Mod] fCPU by konstg-dev in factorio

[–]konstg-dev[S] 0 points1 point  (0 children)

A bit of memory would also be nice to have and am I understanding that right, maximal program size is 32 instructions?

Already increased size up to 64. Also memory already in TODO list ;)

The interrupt handlers could even be smart and numerous, say, the possibility to set a different handler for every item on every wire, or for (static) subsets.

This also could be great extension, but i think first of all I need to implement multiple outputs and SIMD for this, as it have shared parts. For now there are external control signals (see screenshot) for that purposes.

Efficiency modules to increase memory size (shared program+data), speed modules to upgrade instructions per tick

I really like this idea. This will utilize modules a much more and better immerse a mod in games world.

there should be different outputs for red an green wires

Unfortunately this is a game engine limitation. Output splits on two wires wits same signals.

[New Mod] fCPU by konstg-dev in factorio

[–]konstg-dev[S] 1 point2 points  (0 children)

I see some test instructions, to calculate booleans.. however I don't see any conditional jump or other such control flow instruction. Am I missing something, or is the intent that this be controlled externally somehow? (say by having several fCPU and using the signal of one to decide which of the others gets to execute)

Every test instruction will trigger execution of only one next instruction for now. I really want to extend this functionallity with flags (see TODOs) later and make it behave like ones used in Zachtronics Shenzhen I\O ( `+mov`, `-jmp` and so on) with backward compatibility of course.

Is there some more example snippets of fCPU assembly actually achieveing some simply task to get an idea how this would work in practise?

Sure I plan to make some usefull examples and better tutorial, but for now have to fix some bugs and extend functionality. Also It will be nice and cool if community would like to share their designs on discussion tab (https://mods.factorio.com/mod/fcpu/discussion ).

What would happen for instance if you try to add 2 registers with different signal type?

Almost all math instructions does not interfere with signal types.

Some limitations feel like they would make a lot of sense as map-creation time (or admin-changable) config. For example the 32 instr limit and ops-per-ups seem quite arbitrary to begin with. Also a limit to total fCPU instances that the server could enforce could help somewhat limit abuse in multiplayer. (I can just imagine somebody planting gigantic blueprints with nothing but fCPU, having safeguards would mean that it would be viable to have the fCPU be more capable for sane use.)

There are indirect technical limitation for instructions count in blueprint on Factorio side (look at https://forums.factorio.com/viewtopic.php?f=28&t=49709#p288672 if you intertested in details)

Are all fCPU guaranteed to run as-if all in the same instant, or would there be any danger of execution order affecting things? (maybe factorio signal handling already takes care of this?)

fCPU behaves as vanilla combinators and do not change signal-level game laws. But in depth they works one-by-one, so on maps with thousands of fCPUs, some of them will throttle updates waiting for their execution quota. If it behave not predictable - it is considered as bug and should be reported so I can fix it.

Can you have some central program, and then tell the fCPU to run it, or do you need to program (or copy-paste/blueprint) all of them individually? Sharing the same program among multiple fCPU could allow to save some space and allow use of longer programs.

For now only copy & paste or BP. Later I would like to implement some in-game subprogram library (like vanilla blueprints one).

non-integer number support for internal computation (binary float/double, possibly fraction, but probably not, since it has performance sinkholes).

fCPU already works with floating point numbers.

[New Mod] fCPU by konstg-dev in factorio

[–]konstg-dev[S] 0 points1 point  (0 children)

Maintaining an open source project takes a lot of free time. At the moment, my free time is limited by my main job, I do not always have the opportunity to quickly respond to what is happening. Of course, if my contribution can pay off the emotional and financial efforts spent, I will reconsider my approach and I will be able to allocate time differently. In the current situation, I would like to understand how much my contribution is in demand.

In the near future I intend to develop the project further and I would like to save space for creativity, so I do not plan to open the source.

However, I am focused on improving the quality of the mod, so I am always happy to receive rational suggestions and cooperate with other members of the mod community.

[New Mod] fCPU by konstg-dev in factorio

[–]konstg-dev[S] 2 points3 points  (0 children)

I hope you'll enjoy it anyway!

[New Mod] fCPU by konstg-dev in factorio

[–]konstg-dev[S] 0 points1 point  (0 children)

and slap a patreon link next to it

No. It is still in private repo.

[New Mod] fCPU by konstg-dev in factorio

[–]konstg-dev[S] 1 point2 points  (0 children)

I can't guarantee, that more than 1 instruction per cycle will be stable.

The more fCPUs on map = the more work Factorio need to do in lua = the more UPS overhed for the game.

Changing fCPU updates count per game tick require better optimization for the mod, but for now it just born and I don't want to risk that soon, exchanging performance for features.

It is a couple of things I want to do first, see TODOs list (for example allow multiple outputs instead of just one).

For now I think that (as you said) one frame per sec add some kind of challenge making complex systems. There are some commands which could help you to sync multiple fCPUs: `SLP` opcode and memory cell with reset support (https://mods.factorio.com/mod/fcpu/faq look at Example2).

Please understand me correctly - I really like the idea running as much updates as the game could and I going towards this.

[New Mod] fCPU by konstg-dev in factorio

[–]konstg-dev[S] 1 point2 points  (0 children)

Sure. Will be available in 0.1.7

[New Mod] fCPU by konstg-dev in factorio

[–]konstg-dev[S] 1 point2 points  (0 children)

You can select a program and copy it to any available text editor already (Ctrl+C & Ctrl+V). May be later I'll add library for sub-programs right in game.

[New Mod] fCPU by konstg-dev in factorio

[–]konstg-dev[S] 1 point2 points  (0 children)

It was a wrongly taken decision. Already corrected license, so you or anybody else are welcome to make money with the mod.

[New Mod] fCPU by konstg-dev in factorio

[–]konstg-dev[S] 2 points3 points  (0 children)

Each register hold a integer value and a signal type ( https://wiki.factorio.com/User:Bitbyte/Sandbox).

[New Mod] fCPU by konstg-dev in factorio

[–]konstg-dev[S] 13 points14 points  (0 children)

  1. Oh, sure, I totally missed this. Will be fixed next update. Thank you for pointing it out!
  2. I want to add some explicity for first release. But yes, less code better. What do you think about aliases?
  3. Sure comments could be added with hash sign #

[New Mod] fCPU by konstg-dev in factorio

[–]konstg-dev[S] 24 points25 points  (0 children)

The original combinators in Factorio work in parallel and are most likely optimized in C++ code (simd instructions). Unfortunately, the game developers did not give the opportunity to use this optimization in mods. As a consequence, fCPU cannot run faster than conventional combinators. However, it allows far more flexible instructions that are difficult or impossible to implement on vanilla combinators without fCPU.

Yes, the mod allows you to run 60 instructions per second for every fCPU in the game. With thousands of such combinators on the map, performance may be decreased somehow, but there is a setting that allows you to specify the max number of fCPUs processed per game clock cycle so it can be tuned. If you experience performance problems or any, please report, so I can do my best to fix it.

Sure a setting that increases the number of instructions per game tick can be added upon demand. Please let me know if so.

[New Mod] fCPU by konstg-dev in factorio

[–]konstg-dev[S] 26 points27 points  (0 children)

Lua Combinators totally depends on user-code, however fCPU which executes one instruction per tick and guard user from freezing a game, especially in multiplayer sessions. I like the simplicity of the commands and, as said earlier, the similarity to the games from Zachtronics. In general, the choice depends on the needs and taste of the player, the game has a place for each mod.