Is this means to be functional for MP games? The a12 Combinator system is very explicitly designed to only process one unit of information each per 1/60s "tick", both to avoid infinite loops eating up all the CPU and freezing the game, and to avoid creating problems for MP-over-Internet games.
Re: [0.12.x][0.0.1] Programmable Controllers
Posted: Sun Aug 09, 2015 2:14 am
by craftoBot
It is processing 1024 program cycles on each game tick, or lower if yld instruction is used, but it not mp- tested, i think if you have a good network channal you can use this mod in MP.
Also you can adjust cycles per tick count in control.lua( var cycles_per_tick )
Re: [0.12.x][0.0.1] Programmable Controllers
Posted: Sun Aug 09, 2015 2:43 pm
by craftoBot
MP tested and it working nice, enjoy MP with programmable controllers)
Re: [0.12.x][0.0.2] Programmable Controllers
Posted: Thu Aug 13, 2015 5:28 pm
by ikiris
You're awesome. Now I just want a combinator that runs python... =)
The concept is pretty good, here my thought about the mod :
I would recommend you to post it on github, It would be a pleasure for me to participate in it's evolution.
The cpu interface is a bit too intrusive, you should add a small button to have the possibility to hide or show them
(already done, ask me for code) The peripheral order should correspond to their positions relative to the cpu, so it would be easier to move a program.
(already done, ask me for code) Why don't you merge lines of consecutive same type modules and give meaningful name to modules. For example changing this :
P1: FROM 1 TO 1 IS PROGRAM COUNTER
P2: FROM 2 TO 16 IS OUT COMBINATOR
P3: FROM 17 TO 48 IS MEM BLOCK
P4: FROM 49 TO 80 IS MEM BLOCK
P5: FROM 81 TO 112 IS MEM BLOCK
P6: FROM 113 TO 144 IS MEM BLOCK
P7: FROM 145 TO 145 IS 1-INPUT
P8: FROM 146 TO 146 IS 1-INPUT
P9: FROM 147 TO 147 IS 1-INPUT
P10: FROM 148 TO 148 IS 1-INPUT
The coding interface would need some refinements to be better scalled and aligned, code lines are to high, you should reskin it a bit.
A debugger button to access ram, input, output would be interesting.
An integrated help with instructions.
Also the next thing is completely my point of view and there is no problem if you don't respect it :
I would have added a rom module, rom would simply not be writable by a program and so would permit to store informations for the program to run.
Programs would be stored in rom (and maybe ram). everything would be representable by numbers (instructions, constants, adresses), data area would need to be declared as data folowed by data lenght, this would prevent it to be parsed as instructions. and allowing to jump trought this block of data.
Insructions that could be used with multiples type would get specific opcode for those cases
$123 -- it is address 123
123 -- it is constant 123
#123 -- it is line 123
0 # nil # - do nothing
1 123 456 # mov $123 $456 # - copy number at 123 to number at 456
2 123 456 # mov 123 $456 # - copy number 123 to number at 456
3 123 # inc $123 # - add 1 to number stored at 123
4 123 # dec $123 # - sub 1 to number stored at 123
5 123 456 # add $123 $456 # - add number at 456 to number at 123 and store result at 123
6 123 456 # add $123 456 # - add number 456 to number at 123 and store result at 123
7 123 456 # sub $123 $456 # - sub number at 456 to number at 123 and store result at 123
8 123 456 # sub $123 456 # - sub number 456 to number at 123 and store result at 123
9 123 456 # mul $123 $456 # - multiply number at 456 to number at 123 and store result at 123
10 123 456 # mul $123 456 # - multiply number 456 to number at 123 and store result at 123
11 123 456 # div $123 $456 # - divide number at 456 to number at 123 and store result at 123
12 123 456 # div $123 456 # - divide number 456 to number at 123 and store result at 123
13 123 # flo $123 # - floor number at 123 and store result at 123
14 123 # cel $123 # - ceil number at 123 and store result at 123
15 123 456 # pow $123 $456 # - power number at 123 by number at 456 and store result at 123
16 123 456 # pow $123 456 # - power number at 123 by number 456 and store result at 123
17 123 456 # lsh $123 $456 # - left shift of number at 123 by number at 456 and store result at 123
18 123 456 # lsh $123 456 # - left shift of number at 123 by number 456 and store result at 123
19 123 456 # rsh $123 $456 # - right shift of number at 123 by number at 456 and store result at 123
20 123 456 # rsh $123 456 # - right shift of number at 123 by number 456 and store result at 123
21 123 # jmp
...
All CPU would share the same memory and so the same code, to diferentiate CPUs, the firsts code cells (which would corespond to the number of CPUs) would contains an address indicating the initial program counter value (at reset)
Excuse me .. it's a bit too difficult for me. they could in simple words to describe what makes the mod? and perhaps show a practical example? thx
PS: if there is such a great evolution as you TrainLogicSystem, I would like to know more
Re: [MOD 0.12.x][0.0.2] Programmable Controllers
Posted: Sun Sep 13, 2015 11:22 pm
by Keyalha
Looks veeeeeeeeeerrryy interesting. It would be nice to know what Inputs it recognizes and in what format to actually use it.
If the howto is up i will take another look.
Re: [MOD 0.12.x][0.0.2] Programmable Controllers
Posted: Sat Sep 26, 2015 6:52 pm
by redcharlie
the input is the result of the condition in the input controller, 0 or 1
so if the input is "from 2 to 2" in the cell 2 you have 0 or 1.
Re: [MOD 0.12.x][0.0.2] Programmable Controllers
Posted: Mon Dec 26, 2016 1:11 pm
by y.petremann
I'm taking over this mod with a lot of modifications which are still in progress :
There is now Ram, Rom, In, Out, Cpu and Cable.
Ram, Rom, In, Out behave like constant combinator.
Ram (32 slots) can be preloaded or modified in live, but a reset erase Ram
Rom (32 slots) can be preloaded or modified in live, it's read-only memory for programs
In (16 slots) can have signal preloaded by hand or by program, then the program can get the signal value from circuit network.
Out (16 slots) can have signal preloaded by hand or by program, then the program can send the signal value to circuit network.
Cable simply connect things together and do nothing else, things are now grouped by three level :
components are ordered by position
components of same type grouped together are now adjacent in memory, the top-right components position define priority
components grouped together (not separated by Cable) are now adjacent in memory, the top-right components position define priority
components of a computer group can only be accessed from this computer.
Cpu (1 process id, 1 control pointer, 6 call stack, 1 main Register, 7 internal ram slots) if grouped together, they act as one processor, slave processor (8 internal ram slots, 8 call stack pointer) use main processor for control pointer and main register, they also extend the main call stack and internal ram with their call stack and internal ram. Internal ram can only be used by processor and can't be set manually, process id is automaticaly set and contain the processor ID, start pointer is defined by first rom address+process id, separated cpu can start different programs with shared memory or start the same program, for processor usage convenience, processor address are always the first, the other processor simply follow.
Re: [MOD 0.12.x][0.0.2] Programmable Controllers
Posted: Mon Dec 26, 2016 6:28 pm
by Earendel
This looks like it would go well with the AAI Programmable Vehicles mod.
Re: [MOD 0.12.x][0.0.2] Programmable Controllers
Posted: Tue Dec 27, 2016 4:15 am
by y.petremann
Earendel wrote:This looks like it would go well with the AAI Programmable Vehicles mod.
I think it would go very well.
I've not mentionned that all coding could be now using constant combinator, every instruction are special signal which have only one parameter, they can use the internal register
here is a draft of the suported instructions :
Instructions:
nop - : 00 do nothing
get A : 01 copy A to R (constant)
get @A : 02 copy @A to R (address)
set @A : 03 copy R to @A (get @A set @B = mov @A @B)
inc @A : 04 increase @A by 1
dec @A : 05 decrease @A by 1
add @A : 06 add R to @A
sub @A : 07 substract R to @A
mul @A : 08 multiply by R in @A
div @A : 09 divide by R in @A
flo @A : 10 floor @A
cel @A : 11 ceil @A
neg @A : 12 negate @A
and @A : 13 bitwise and R on @A
or @A : 14 bitwise or R on @A
not @A : 15 not @A
xor @A : 16 bitwise xor R on @A
pow @A : 17 power by R in @A
pow @A : 18 power by R in @A
lsh @A : 19 left shift of R in @A
rsh @A : 20 right shift of R in @A
jmp A : 21 jump to A (address)
jmp @A : 22 jump to @A (constant)
cjp A : 23 jump to B if R == 0 (address)
cjp @A : 24 jump to @B if R == 0 (constant)
hlt @A : 25 halt process with message @A
yld A : 26 wait A next game tick
yld @A : 27 wait @A next game tick
wfm @A : 28 wait for modification on @A
psh @A : 29 push in stack @A (add at start)
pul @A : 30 pull in stack @A (remove at start)
stk @A : 31 stack in stack @A (add at end)
pop @A : 32 pop in stack @A (remove at end)
tez @A : 33 1 if @A == 0 else 0
tgt @A : 34 1 if @A > 0 else 0
tlz @A : 35 1 if @A < 0 else 0
tcz @A : 36 -1 if @A < 0 else 1 if @A > 0 else 0
Re: [MOD 0.12.x][0.0.2] Programmable Controllers
Posted: Thu Dec 29, 2016 11:03 am
by Wildejackson
I just discovered this mod and am excited to see that y.petremann has an interest in updating it!
Re: [MOD 0.12.x][0.0.2] Programmable Controllers
Posted: Thu Dec 29, 2016 10:53 pm
by y.petremann
My interest is mainly because this is the kind of mods I want to see working ...
Re: [MOD 0.12.x][0.0.2] Programmable Controllers
Posted: Tue Feb 14, 2017 7:57 am
by y.petremann
Here a quick update on where I am on the update of this mod :
Firstly, enjoy the new graphics :
factorio.png (464.41 KiB) Viewed 14083 times
If anybody would like to make icon corresponding to each computer module it would be great, for now I only have a chip with the name on them, but I really appreciate something that looks like factorioish (symbolic and beautiful)
Also here a preview of all opcodes, reworked and should be final version (new opcodes should go after them, so prepare designing your programs) :
- 00 nop - : do nothing
- 01 val A : copy value A to R
- 02 get A : copy A to R (address, signal included)
- 03 get @A : copy @A to R (pointer, signal included)
- 04 set A : copy R to A
- 05 set @A : copy R to @A
- 06 swp A : swap R with A
- 07 swp @A : swap R with @A
- 08 slp A : wait A processor cycles
- 09 slp @A : wait @A processor cycles
- 0A yld A : wait A game tick
- 0B yld @A : wait @A game tick
- 0C int A : wait for modification on @A
- 0D int @A : wait for modification on @A
- 0E hlt A : halt with code A
- 0F hlt @A : halt with code A
- 10 jmp A : jump to A
- 11 jmp @A : jump to @A
- 12 rjp A : jump relative by A
- 13 rjp @A : jump relative by @A
- 14 seq A : skip if A == 0
- 15 seq @A : skip if @A == 0
- 16 slt A : skip if A < 0
- 17 slt @A : skip if @A < 0
- 18 sgt A : skip if A > 0
- 19 sgt @A : skip if @A > 0
- 1A snq A : skip if A != 0
- 1B snq @A : skip if @A != 0
- 1C slq A : skip if A <= 0
- 1D slq @A : skip if @A <= 0
- 1E sgq A : skip if A >= 0
- 1F sgq @A : skip if @A >= 0
- 20 add A : add R to A
- 21 add @A : add R to @A
- 22 sub A : sub R to A
- 23 sub @A : sub R to @A
- 24 inc A : increase A by 1
- 25 inc @A : increase @A by 1
- 26 dec A : decrease A by 1
- 27 dec @A : decrease @A by 1
- 28 lsh A : left shift A by R
- 29 lsh @A : left shift @A by R
- 2A rsh A : right shift A by R
- 2B rsh @A : right shift @A by R
- 2C ngd A : negate A
- 2D ngd @A : negate @A
- 2E not A : bitwise not A
- 2F not @A : bitwise not @A
- 30 and A : bitwise and A by R
- 31 and @A : bitwise and @A by R
- 32 adn A : bitwise and A by not R
- 33 adn @A : bitwise and @A by not R
- 34 nad A : bitwise nand A by R
- 35 nad @A : bitwise nand @A by R
- 36 ndn A : bitwise nand A by not R
- 37 ndn @A : bitwise nand @A by not R
- 38 or A : bitwise or A by R
- 39 or @A : bitwise or @A by R
- 3A orn A : bitwise or A by not R
- 3B orn @A : bitwise or @A by not R
- 3C nor A : bitwise nor A by R
- 3D nor @A : bitwise nor @A by R
- 3E nrn A : bitwise nor A by not R
- 3F nrn @A : bitwise nor @A by not R
- 40 mul A : multiply by R in @A
- 41 mul @A : multiply by R in @A
- 42 dvf A : floor division A by R
- 43 dvf @A : floor division @A by R
- 44 dvc A : ceil division A by R
- 45 dvc @A : ceil division @A by R
- 46 mod @A : modulo A by R
- 47 mod @A : modulo @A by R
- 48 xor A : bitwise xor A by R
- 49 xor @A : bitwise xor @A by R
- 4A xrn A : bitwise xor A by not R
- 4B xrn @A : bitwise xor @A by not R
- 4C nxr A : bitwise nxor A by R
- 4D nxr @A : bitwise nxor @A by R
- 4E nxn A : bitwise nxor A by not R
- 4F nxn @A : bitwise nxor @A by not R
Re: [MOD 0.12.x][0.0.2] Programmable Controllers
Posted: Thu Feb 16, 2017 4:58 am
by y.petremann
Here the first program I've done yet:
A basic second clock
clock.png (69.12 KiB) Viewed 14054 times
Re: [MOD 0.12.x][0.0.2] Programmable Controllers
Posted: Wed Feb 22, 2017 5:42 pm
by y.petremann
Hey, I've good news for you !
I've uploaded a beta version of the new version of programmable controllers, why ? Because for now it's incomplete, but you can play with some functions just to look a bit.