[MOD 0.12.x][0.0.2] Programmable Controllers

Topics and discussion about specific mods
craftoBot
Inserter
Inserter
Posts: 37
Joined: Sun Dec 28, 2014 7:39 pm
Contact:

[MOD 0.12.x][0.0.2] Programmable Controllers

Post by craftoBot »

Hello everyone, today i done strange thing, i had created programmable controller for circuit network......

Features
HOWTO
WARNING, ALL INSTRUCTIONS ARE IN LOWER CASE
Syntax Help:
Accessors
Math
Conditions
Try...
I will write more detail tutorial if my idea will be intresing for you...
TODO
Also, code avalible at bitbucket https://bitbucket.org/xcodersteam/progr ... ontrollers.
Attachments
ProgrammableControllers_0.0.2.zip
Fixed small bugs in code editor, fixed tech and recipes, also tested in MP, working nice confirmed
(63.26 KiB) Downloaded 502 times
ProgrammableControllers_0.0.1.zip
I think, you can try(If any bugs/crashes report please)
(61.82 KiB) Downloaded 256 times
Last edited by craftoBot on Tue Aug 25, 2015 3:02 am, edited 5 times in total.

Peter34
Smart Inserter
Smart Inserter
Posts: 1100
Joined: Mon Nov 10, 2014 12:44 pm
Contact:

Re: [0.12.x][0.0.1] Programmable Controllers

Post by Peter34 »

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.

craftoBot
Inserter
Inserter
Posts: 37
Joined: Sun Dec 28, 2014 7:39 pm
Contact:

Re: [0.12.x][0.0.1] Programmable Controllers

Post 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 )

craftoBot
Inserter
Inserter
Posts: 37
Joined: Sun Dec 28, 2014 7:39 pm
Contact:

Re: [0.12.x][0.0.1] Programmable Controllers

Post by craftoBot »

MP tested and it working nice, enjoy MP with programmable controllers)

ikiris
Inserter
Inserter
Posts: 26
Joined: Sun Jul 19, 2015 5:57 pm
Contact:

Re: [0.12.x][0.0.2] Programmable Controllers

Post by ikiris »

You're awesome. Now I just want a combinator that runs python... =)

craftoBot
Inserter
Inserter
Posts: 37
Joined: Sun Dec 28, 2014 7:39 pm
Contact:

Re: [0.12.x][0.0.2] Programmable Controllers

Post by craftoBot »

@ikiris

Code: Select all

SSSSSSSSSSSSSSSSSSSSSHHHHHHHHHHHH 
SSSSSSSSSSSSSSSSSSSSSS > SHHHHHHHHHHHHHHHHHH:
    SH(SSSSSSHHHH,SSSSSSSSHHHHHHH)
SSHH 'SSSSSSHHHHHHHHHH'
SSHH 'Done'
:lol:

ikiris
Inserter
Inserter
Posts: 26
Joined: Sun Jul 19, 2015 5:57 pm
Contact:

Re: [0.12.x][0.0.2] Programmable Controllers

Post by ikiris »

@craftoBot

I said python... not brainfuck =P


Although you got a laugh, so well done.

User avatar
y.petremann
Filter Inserter
Filter Inserter
Posts: 416
Joined: Mon Mar 17, 2014 4:24 pm
Contact:

Re: [MOD 0.12.x][0.0.2] Programmable Controllers

Post by y.petremann »

The concept is pretty good, here my thought about the mod :
  1. I would recommend you to post it on github, It would be a pleasure for me to participate in it's evolution.
  2. The cpu interface is a bit too intrusive, you should add a small button to have the possibility to hide or show them
  3. (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.
  4. (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 :

    Code: Select all

    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
    into this :

    Code: Select all

    0001:0001 PROGRAM COUNTER (CPU1)
    0002:0016 OUTPUT (OUT1)
    0017:0144 MEMORY (RAM1,RAM2,RAM3,RAM4)
    0145:0144 MEMORY (RAM1,RAM2,RAM3,RAM4)
    0145:0148 INPUT (IN1,IN2,IN3,IN4)
  5. The coding interface would need some refinements to be better scalled and aligned, code lines are to high, you should reskin it a bit.
  6. A debugger button to access ram, input, output would be interesting.
  7. 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 :
  1. 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.
  2. 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

    Code: Select all

    $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
    ...
    
  3. 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)

craftoBot
Inserter
Inserter
Posts: 37
Joined: Sun Dec 28, 2014 7:39 pm
Contact:

Re: [MOD 0.12.x][0.0.2] Programmable Controllers

Post by craftoBot »

Sources now available at git repository https://bitbucket.org/xcodersteam/progr ... ontrollers.

Alexs
Fast Inserter
Fast Inserter
Posts: 102
Joined: Sun Sep 07, 2014 9:46 am

Re: [MOD 0.12.x][0.0.2] Programmable Controllers

Post by Alexs »

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 :)

Keyalha
Inserter
Inserter
Posts: 34
Joined: Wed Nov 05, 2014 7:24 pm
Contact:

Re: [MOD 0.12.x][0.0.2] Programmable Controllers

Post 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.

redcharlie
Manual Inserter
Manual Inserter
Posts: 1
Joined: Sat Sep 05, 2015 9:48 pm
Contact:

Re: [MOD 0.12.x][0.0.2] Programmable Controllers

Post 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.

User avatar
y.petremann
Filter Inserter
Filter Inserter
Posts: 416
Joined: Mon Mar 17, 2014 4:24 pm
Contact:

Re: [MOD 0.12.x][0.0.2] Programmable Controllers

Post by y.petremann »

I'm taking over this mod with a lot of modifications which are still in progress :
  1. There is now Ram, Rom, In, Out, Cpu and Cable.
  2. Ram, Rom, In, Out behave like constant combinator.
  3. Ram (32 slots) can be preloaded or modified in live, but a reset erase Ram
  4. Rom (32 slots) can be preloaded or modified in live, it's read-only memory for programs
  5. In (16 slots) can have signal preloaded by hand or by program, then the program can get the signal value from circuit network.
  6. Out (16 slots) can have signal preloaded by hand or by program, then the program can send the signal value to circuit network.
  7. Cable simply connect things together and do nothing else, things are now grouped by three level :
    1. components are ordered by position
    2. components of same type grouped together are now adjacent in memory, the top-right components position define priority
    3. components grouped together (not separated by Cable) are now adjacent in memory, the top-right components position define priority
    4. components of a computer group can only be accessed from this computer.
  8. 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.

User avatar
Earendel
Factorio Staff
Factorio Staff
Posts: 716
Joined: Sun Nov 23, 2014 11:57 am
Contact:

Re: [MOD 0.12.x][0.0.2] Programmable Controllers

Post by Earendel »

This looks like it would go well with the AAI Programmable Vehicles mod.

User avatar
y.petremann
Filter Inserter
Filter Inserter
Posts: 416
Joined: Mon Mar 17, 2014 4:24 pm
Contact:

Re: [MOD 0.12.x][0.0.2] Programmable Controllers

Post 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

Wildejackson
Long Handed Inserter
Long Handed Inserter
Posts: 54
Joined: Sun Jul 31, 2016 2:40 am
Contact:

Re: [MOD 0.12.x][0.0.2] Programmable Controllers

Post by Wildejackson »

I just discovered this mod and am excited to see that y.petremann has an interest in updating it!

User avatar
y.petremann
Filter Inserter
Filter Inserter
Posts: 416
Joined: Mon Mar 17, 2014 4:24 pm
Contact:

Re: [MOD 0.12.x][0.0.2] Programmable Controllers

Post by y.petremann »

My interest is mainly because this is the kind of mods I want to see working ...

User avatar
y.petremann
Filter Inserter
Filter Inserter
Posts: 416
Joined: Mon Mar 17, 2014 4:24 pm
Contact:

Re: [MOD 0.12.x][0.0.2] Programmable Controllers

Post by y.petremann »

Here a quick update on where I am on the update of this mod :

Firstly, enjoy the new graphics :
factorio.png
factorio.png (464.41 KiB) Viewed 14087 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) :
opcodes

User avatar
y.petremann
Filter Inserter
Filter Inserter
Posts: 416
Joined: Mon Mar 17, 2014 4:24 pm
Contact:

Re: [MOD 0.12.x][0.0.2] Programmable Controllers

Post by y.petremann »

Here the first program I've done yet:
A basic second clock
A basic second clock
clock.png (69.12 KiB) Viewed 14058 times

User avatar
y.petremann
Filter Inserter
Filter Inserter
Posts: 416
Joined: Mon Mar 17, 2014 4:24 pm
Contact:

Re: [MOD 0.12.x][0.0.2] Programmable Controllers

Post 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.
programmable-controllers_0.14.0.zip
(174.13 KiB) Downloaded 198 times
I've managed to make a specific system in factorio and this is a zone controller for AAI mods :
Basically this :
pci.png
pci.png (796.7 KiB) Viewed 13989 times
Replace that :
Image

Post Reply

Return to “Mods”