Compare commits
No commits in common. "9cc9b5d0dca515123e9b388f194cf3011a44813a" and "355811be3ace2657fe572bdeb0f5c48e781e4bcb" have entirely different histories.
9cc9b5d0dc
...
355811be3a
2 changed files with 13 additions and 10 deletions
18
README.md
18
README.md
|
@ -1,16 +1,18 @@
|
||||||
# Stupid Worm Languag
|
# sandworm
|
||||||
- program space is an arbitrary sized grid
|
program space is an arbitrary sized grid
|
||||||
- the worm starts where you place the worm head @
|
the worm starts where you place the worm head @
|
||||||
- as it passes over commands, they get moved to the back of the worm
|
as it passes over commands, they get moved to the back of the worm (also depending on the worm length)
|
||||||
- values get pushed to stack (eaten) when passed over, worm body length increases
|
commands to change direction <>^v
|
||||||
- the program gets rearranged every time the worm executes it
|
values get pushed to stack (eaten) when passed over, worm body length increases
|
||||||
|
autosarkophagy/self-cannibalism is possible, cutting off the back of the worm (the lower part of the stack) and pushing the passed value to the stack (front of worm)
|
||||||
|
conditional: pop then side/forward if top of stack is zero
|
||||||
|
|
||||||
## commands
|
## commands
|
||||||
```
|
```
|
||||||
+- pop 2 values *, push sum/difference (uses the order they are popped, so `0 -` negates the top of the stack)
|
+- pop 2 values *, push sum/difference (uses the order they are popped, so `0 -` negates the top of the stack)
|
||||||
><^v change direction
|
><^v change direction
|
||||||
0..9 push number to stack
|
0123456789ABCDEF push number to stack
|
||||||
/\ pop stack, reflect to the side if not zero
|
/\ pop stack, reflect to the side if zero
|
||||||
? reads one byte of input
|
? reads one byte of input
|
||||||
= duplicate top of stack
|
= duplicate top of stack
|
||||||
! pop and write output as ascii char
|
! pop and write output as ascii char
|
||||||
|
|
|
@ -159,19 +159,20 @@ impl SandWormInterpreter {
|
||||||
self.worm_in.push(instruction - 48);
|
self.worm_in.push(instruction - 48);
|
||||||
dont_push_instruction = true;
|
dont_push_instruction = true;
|
||||||
}
|
}
|
||||||
|
// b'0'..=b'9' => self.grow(instruction - 48),
|
||||||
b'+' => {
|
b'+' => {
|
||||||
let a = self.shrink();
|
let a = self.shrink();
|
||||||
self.worm_out.push(instruction);
|
self.worm_out.push(instruction);
|
||||||
let b = self.shrink();
|
let b = self.shrink();
|
||||||
dont_push_instruction = true;
|
dont_push_instruction = true;
|
||||||
self.worm_in.push(a.wrapping_add(b));
|
self.worm_in.push(a + b);
|
||||||
}
|
}
|
||||||
b'-' => {
|
b'-' => {
|
||||||
let a = self.shrink();
|
let a = self.shrink();
|
||||||
self.worm_out.push(instruction);
|
self.worm_out.push(instruction);
|
||||||
dont_push_instruction = true;
|
dont_push_instruction = true;
|
||||||
let b = self.shrink();
|
let b = self.shrink();
|
||||||
self.worm_in.push(a.wrapping_sub(b));
|
self.worm_in.push(a + b);
|
||||||
}
|
}
|
||||||
b'v' => self.direction = Direction::Down,
|
b'v' => self.direction = Direction::Down,
|
||||||
b'^' => self.direction = Direction::Up,
|
b'^' => self.direction = Direction::Up,
|
||||||
|
|
Loading…
Reference in a new issue