swarm-0.7.0.0: data/scenarios/Testing/684-swap.yaml
version: 1
name: Swap in one tick
description: |
Swapping an entity should be done in one tick.
https://github.com/swarm-game/swarm/issues/684
objectives:
- condition: |
try {
as base {
l <- has "lambda";
b <- has "bitcoin";
pure $ l && b
}
} {
pure false
}
solution: |
swap "bitcoin"; swap "gold coin";
robots:
- name: base
loc: [0, 0]
dir: east
devices:
- logger
- scanner
- grabber
- fast grabber
inventory:
- [1, gold coin]
- [1, bitcoin]
- name: watcher
loc: [0, 0]
dir: east
system: true
devices:
- logger
program: |
def repeat = \c. c; repeat c end;
repeat (
d <- scan down;
case d (\_.
say "Fatal error: swap does not work atomically!"
) (\_.
pure ()
)
)
world:
palette:
'+': [stone, wall]
'λ': [grass, lambda]
upperleft: [-1, 1]
map: |
+++
+λ+
+++