I've been dabbling with the idea of a game based on programming and Self-Modifying Code for a long time (inspired by Code Wars and ...this sub-game...). My idea involves having "robots" which move on a grid, with "instructions" (like arrows or rotations) which are either tiles on the grid or movable blocks. The robot(s) would read instructions as they encountered them, and either store them somewhere or cause some other robot to execute that instruction. Or perhaps there could be different color instructions and different color robots, such that a robot would "push" his own instruction blocks, but step on others so as to affect the other robots. Perhaps instead, the robot(s) could have a "processing unit" which actually moves around in the grid, but can also be interacted with directly. ... Lots of variables and options; and I don't even know what the goal would be!!!
However, I have once again found a possible idea for this kind of game (though it's not a complete idea): There could be instructions for moving (whether fixed directions, or rotations and "foward/backward" etc.), and there would be numbered instructions. The robot(s) have their own set of instructions that they are executing (separately from what is on the grid). For every (non-blank) tile that the robot steps on, the corresponding instruction is copied into some kind of "memory" (For now, let's assume that all memory banks are numbered [one per possible number instruction], and that their contents are visible). It is important to distinguish that the robot will be continuously EXECUTING instructions from some memory bank (rather than from the tiles that it steps on directly). As the robot(s) steps on a tile, that instruction is read into some memory bank. The numbered instructions represent "calls" (or gotos) to other memory banks. One problem I have so far is that there are 2 ways to interact with numbers (step on or execute from memory), but 3 actions associated with them (goto/call another subroutine, write the number to memory, or switch which subroutine to write to). This brings me to realize that I can either have the robot write to where it is reading from (e.g. execute an instruction, but leave behind another), or have a separate indication as to where the "writing" is going. If there are essentially two "instruction pointers", then perhaps I can color the numbers to differentiate whether they move the "writer" or the "reader" between subroutines (so far I assume that they both advance "forward" in memory, which may or may not be looped). One thing that is interesting to note is whether or not all robots would share the same memory (which I like, actually), or whether instructions can be different colors so as to have significance toward certain robots (if there are more than 1 anyway).
A slight (but significant) variation on this would be to have one (smallish) memory location, which the player would modify before starting the "simulation" (the positions of anything physically on the grid is not alterable at this point, and is what would constitute a "level"). After that, the robot is to run the "program" from start to end, and then stop (and then we see if some goal was achieved). HOWEVER, there could be an instruction to "open" a "new" program, which the robot will read instructions into until it is "closed". Each new program would correspond to some number, and after it is "made" (by the robot executing a "make N" [where N is some program number], reading instructions into it from the grid, and then executing a "close"), then the corresponding number-instruction means to execute that program. This is recursive, meaning that while the robot is "writing" a program, it can write OTHER programs to use in that first program; and once it is done writing a program, the number-instructions revert back to the programs they referred to BEFORE that program. I suppose I could make a visual to show the "program being made" next to the current program, and while that program is being made, it can do the same, etc. ... There would be one display showing programs executing (stacked up next to eachother), and another separate display showing programs being made.
Of course there are other things to consider as well: Does movement continue until hitting a wall/block or until another instruction is read, or just result in moving ONE step? Are there movable blocks?
I can add more to my previous "variation": perhaps after "making" a program, that program in its entirety (including its own "local"/inner programs) is placed on the grid where the robot was, so that any other robot can walk over it and thus "read" it into memory as an instruction. This would allow these programs to just sit there and be reused. This would also allow "inner" programs to be made by making the inner program, and then reading it as an instruction into another program-in-the-making. The idea with this variation is that memory is only ever modified for programs being made, and not for already-made programs.
... So that's quite a lot of randomness, but I'd REALLY like to see this done! I can do it in Java; but is anyone else interested in exploring this kind of idea/game or trying their own variations?
(another variation could involve having robots separated by walls, and they somehow have to program eachother, probably by sharing a common memory. The player would/could put instructions for an initial robot, and then...).
Previous ideas have included having the "processing unit" for robots actually be ON the grid, and possibly have their own movement or be "pushable" (and possibly slide like they are on ice), or having robots act as eachothers CPU's (e.g. robot-A executes instructions that robot-B steps on), or having instructions be robot-specific (e.g. the red arrow makes the red robot move; with some rule about robots ignoring their own color or not being able to step on it, or something like that), or having CPU units only be able to move onto their own color, but other colored tiles get pushed by them like blocks ... ... So that's just some ideas from the past, but let's focus on my "Making a program" idea (whether it uses dynamic program creation, or a finite set of shared memory).
...Ideas? Comments? Opinions? ...
However, I have once again found a possible idea for this kind of game (though it's not a complete idea): There could be instructions for moving (whether fixed directions, or rotations and "foward/backward" etc.), and there would be numbered instructions. The robot(s) have their own set of instructions that they are executing (separately from what is on the grid). For every (non-blank) tile that the robot steps on, the corresponding instruction is copied into some kind of "memory" (For now, let's assume that all memory banks are numbered [one per possible number instruction], and that their contents are visible). It is important to distinguish that the robot will be continuously EXECUTING instructions from some memory bank (rather than from the tiles that it steps on directly). As the robot(s) steps on a tile, that instruction is read into some memory bank. The numbered instructions represent "calls" (or gotos) to other memory banks. One problem I have so far is that there are 2 ways to interact with numbers (step on or execute from memory), but 3 actions associated with them (goto/call another subroutine, write the number to memory, or switch which subroutine to write to). This brings me to realize that I can either have the robot write to where it is reading from (e.g. execute an instruction, but leave behind another), or have a separate indication as to where the "writing" is going. If there are essentially two "instruction pointers", then perhaps I can color the numbers to differentiate whether they move the "writer" or the "reader" between subroutines (so far I assume that they both advance "forward" in memory, which may or may not be looped). One thing that is interesting to note is whether or not all robots would share the same memory (which I like, actually), or whether instructions can be different colors so as to have significance toward certain robots (if there are more than 1 anyway).
A slight (but significant) variation on this would be to have one (smallish) memory location, which the player would modify before starting the "simulation" (the positions of anything physically on the grid is not alterable at this point, and is what would constitute a "level"). After that, the robot is to run the "program" from start to end, and then stop (and then we see if some goal was achieved). HOWEVER, there could be an instruction to "open" a "new" program, which the robot will read instructions into until it is "closed". Each new program would correspond to some number, and after it is "made" (by the robot executing a "make N" [where N is some program number], reading instructions into it from the grid, and then executing a "close"), then the corresponding number-instruction means to execute that program. This is recursive, meaning that while the robot is "writing" a program, it can write OTHER programs to use in that first program; and once it is done writing a program, the number-instructions revert back to the programs they referred to BEFORE that program. I suppose I could make a visual to show the "program being made" next to the current program, and while that program is being made, it can do the same, etc. ... There would be one display showing programs executing (stacked up next to eachother), and another separate display showing programs being made.
Of course there are other things to consider as well: Does movement continue until hitting a wall/block or until another instruction is read, or just result in moving ONE step? Are there movable blocks?
I can add more to my previous "variation": perhaps after "making" a program, that program in its entirety (including its own "local"/inner programs) is placed on the grid where the robot was, so that any other robot can walk over it and thus "read" it into memory as an instruction. This would allow these programs to just sit there and be reused. This would also allow "inner" programs to be made by making the inner program, and then reading it as an instruction into another program-in-the-making. The idea with this variation is that memory is only ever modified for programs being made, and not for already-made programs.
... So that's quite a lot of randomness, but I'd REALLY like to see this done! I can do it in Java; but is anyone else interested in exploring this kind of idea/game or trying their own variations?
(another variation could involve having robots separated by walls, and they somehow have to program eachother, probably by sharing a common memory. The player would/could put instructions for an initial robot, and then...).
Previous ideas have included having the "processing unit" for robots actually be ON the grid, and possibly have their own movement or be "pushable" (and possibly slide like they are on ice), or having robots act as eachothers CPU's (e.g. robot-A executes instructions that robot-B steps on), or having instructions be robot-specific (e.g. the red arrow makes the red robot move; with some rule about robots ignoring their own color or not being able to step on it, or something like that), or having CPU units only be able to move onto their own color, but other colored tiles get pushed by them like blocks ... ... So that's just some ideas from the past, but let's focus on my "Making a program" idea (whether it uses dynamic program creation, or a finite set of shared memory).
...Ideas? Comments? Opinions? ...