mirror of
https://github.com/swarm-game/swarm.git
synced 2024-10-27 01:49:15 +03:00
active trapdoor demo (#976)
Towards #1088 ![image](https://github.com/swarm-game/swarm/assets/261693/c48bd24b-23b8-4165-8670-c105301f04c4)
This commit is contained in:
parent
adcb2c75fc
commit
8b46979abc
@ -7,3 +7,4 @@ Fun
|
||||
Speedruns
|
||||
Testing
|
||||
Vignettes
|
||||
Mechanics
|
||||
|
1
data/scenarios/Mechanics/00-ORDER.txt
Normal file
1
data/scenarios/Mechanics/00-ORDER.txt
Normal file
@ -0,0 +1 @@
|
||||
active-trapdoor.yaml
|
31
data/scenarios/Mechanics/_active-trapdoor/gate.sw
Normal file
31
data/scenarios/Mechanics/_active-trapdoor/gate.sw
Normal file
@ -0,0 +1,31 @@
|
||||
/**
|
||||
This mechanic operates by polling.
|
||||
Note that the polling is not naturally "throttled" since
|
||||
the 'whereami' command is intangible (has zero duration).
|
||||
So we insert 'wait' commands to be performance-friendly.
|
||||
*/
|
||||
def waitAndGate = \myCoords. \armed.
|
||||
basePos <- as base {whereami};
|
||||
|
||||
if (basePos == myCoords) {
|
||||
if armed {} {
|
||||
// Warn the player that they have tripped the trap
|
||||
say "ka-chunk"
|
||||
};
|
||||
// The trapdoor is now armed. Wait to spring it.
|
||||
wait 1; // Throttle the polling
|
||||
waitAndGate myCoords true;
|
||||
} {
|
||||
if (armed) {
|
||||
place "boulder";
|
||||
// recursion ends
|
||||
} {
|
||||
// Wait to arm the trapdoor
|
||||
wait 1; // Throttle the polling
|
||||
waitAndGate myCoords false
|
||||
};
|
||||
};
|
||||
end;
|
||||
|
||||
myPos <- whereami;
|
||||
waitAndGate myPos false;
|
4
data/scenarios/Mechanics/_active-trapdoor/solution.sw
Normal file
4
data/scenarios/Mechanics/_active-trapdoor/solution.sw
Normal file
@ -0,0 +1,4 @@
|
||||
def doN = \n. \f. if (n > 0) {f; doN (n - 1) f} {}; end;
|
||||
|
||||
doN 10 move;
|
||||
grab;
|
81
data/scenarios/Mechanics/active-trapdoor.yaml
Normal file
81
data/scenarios/Mechanics/active-trapdoor.yaml
Normal file
@ -0,0 +1,81 @@
|
||||
version: 1
|
||||
name: Active trapdoor
|
||||
author: Karl Ostmo
|
||||
description: |
|
||||
This gate closes once you have passed.
|
||||
|
||||
This is an "active" trapdoor in the sense that a system robot
|
||||
continuously monitors its status and operates it.
|
||||
It is in contrast with a sokoban-style trapdoor
|
||||
that is "passive" in its operation.
|
||||
creative: false
|
||||
objectives:
|
||||
- goal:
|
||||
- Grab the flower.
|
||||
condition: |
|
||||
as base {has "flower"}
|
||||
robots:
|
||||
- name: base
|
||||
display:
|
||||
char: 'ω'
|
||||
attr: robot
|
||||
dir: [0, 1]
|
||||
devices:
|
||||
- treads
|
||||
- 3D printer
|
||||
- ADT calculator
|
||||
- branch predictor
|
||||
- clock
|
||||
- comparator
|
||||
- counter
|
||||
- dictionary
|
||||
- grabber
|
||||
- hearing aid
|
||||
- lambda
|
||||
- logger
|
||||
- mirror
|
||||
- net
|
||||
- scanner
|
||||
- strange loop
|
||||
- string
|
||||
- workbench
|
||||
inventory:
|
||||
- [1, treads]
|
||||
- name: gate
|
||||
system: true
|
||||
dir: [0, 1]
|
||||
display:
|
||||
invisible: true
|
||||
inventory:
|
||||
- [1, boulder]
|
||||
program: |
|
||||
run "scenarios/Mechanics/_active-trapdoor/gate.sw"
|
||||
solution: |
|
||||
run "scenarios/Mechanics/_active-trapdoor/solution.sw"
|
||||
known: [water, boulder, flower]
|
||||
seed: 0
|
||||
world:
|
||||
default: [stone, water]
|
||||
upperleft: [0, 0]
|
||||
offset: false
|
||||
palette:
|
||||
'@': [stone, boulder]
|
||||
'.': [grass]
|
||||
G: [stone, null, gate]
|
||||
Ω: [grass, null, base]
|
||||
f: [grass, flower]
|
||||
map: |
|
||||
.....
|
||||
..f..
|
||||
.....
|
||||
@@.@@
|
||||
.@.@.
|
||||
.@.@.
|
||||
.@G@.
|
||||
.@.@.
|
||||
.@.@.
|
||||
@@.@@
|
||||
.....
|
||||
..Ω..
|
||||
.....
|
||||
|
@ -217,6 +217,10 @@ testScenarioSolution _ci _em =
|
||||
, testSolution Default "Challenges/Sokoban/Gadgets/one-way.yaml"
|
||||
, testSolution Default "Challenges/Sokoban/Simple/trapdoor.yaml"
|
||||
]
|
||||
, testGroup
|
||||
"Mechanics"
|
||||
[ testSolution Default "Mechanics/active-trapdoor.yaml"
|
||||
]
|
||||
]
|
||||
, testGroup
|
||||
"Regression tests"
|
||||
|
Loading…
Reference in New Issue
Block a user