From c1d0fdd3ad15316b6ea0804a13e79d1d9d1a5281 Mon Sep 17 00:00:00 2001 From: Karl Ostmo Date: Sun, 1 Oct 2023 07:49:54 -0700 Subject: [PATCH] robot wave scenario (#1556) ![image](https://github.com/swarm-game/swarm/assets/261693/5952ccb9-02fe-47af-9a22-b45b130316e2) # Demo scripts/play.sh -i data/scenarios/Challenges/wave.yaml --autoplay --- data/scenarios/Challenges/00-ORDER.txt | 1 + data/scenarios/Challenges/_wave/solution.sw | 15 ++++ data/scenarios/Challenges/wave.yaml | 89 +++++++++++++++++++++ test/integration/Main.hs | 1 + 4 files changed, 106 insertions(+) create mode 100644 data/scenarios/Challenges/_wave/solution.sw create mode 100644 data/scenarios/Challenges/wave.yaml diff --git a/data/scenarios/Challenges/00-ORDER.txt b/data/scenarios/Challenges/00-ORDER.txt index f3cb5c7c5..c538cb710 100644 --- a/data/scenarios/Challenges/00-ORDER.txt +++ b/data/scenarios/Challenges/00-ORDER.txt @@ -11,6 +11,7 @@ hanoi.yaml hackman.yaml lights-out.yaml bucket-brigade.yaml +wave.yaml wolf-goat-cabbage.yaml blender.yaml friend.yaml diff --git a/data/scenarios/Challenges/_wave/solution.sw b/data/scenarios/Challenges/_wave/solution.sw new file mode 100644 index 000000000..3907a8804 --- /dev/null +++ b/data/scenarios/Challenges/_wave/solution.sw @@ -0,0 +1,15 @@ +def go = + move; + go; + end; + +def start = + turn right; + wait 5; + try { + go; + } {}; + grab; + end; + +start; \ No newline at end of file diff --git a/data/scenarios/Challenges/wave.yaml b/data/scenarios/Challenges/wave.yaml new file mode 100644 index 000000000..d2cf80914 --- /dev/null +++ b/data/scenarios/Challenges/wave.yaml @@ -0,0 +1,89 @@ +version: 1 +name: Wave +author: Karl Ostmo +description: | + Ride the wave +creative: false +objectives: + - goal: + - | + Grab the `bitcoin`{=entity} at the east end of the path. + Don't let the patrolling robots catch you! + prerequisite: + not: got_caught + condition: | + as base {has "bitcoin"}; + - id: got_caught + teaser: Got caught + optional: true + hidden: true + goal: + - | + The robots caught you! + condition: | + as base {x <- meet; return $ case x (\_. false) (\_. true)}; +robots: + - name: base + dir: [0, 1] + devices: + - branch predictor + - comparator + - dictionary + - grabber + - hourglass + - clock + - lambda + - logger + - net + - scanner + - strange loop + - treads + - name: wavebot + system: true + dir: [0, 1] + display: + invisible: false + attr: 'plant' + program: | + def crossPath = + move; move; move; move; move; move; + turn back; + wait 5; + end; + def go = + crossPath; + go; + end; + def start = + pos <- whereami; + wait $ fst pos; + go; + end; + start; +solution: | + run "scenarios/Challenges/_wave/solution.sw" +entities: [] +known: [wavy water, water, bitcoin] +world: + dsl: | + overlay + [ {dirt, water} + , if (x + y / 2) % 5 == 0 then {dirt, wavy water} else {blank} + ] + upperleft: [-3, 6] + offset: false + palette: + 'B': [grass, erase, base] + 'w': [grass, erase, wavebot] + 'x': [dirt, water] + 'z': [grass, bitcoin] + '.': [grass, erase] + map: | + xxxxxx..................................................................................................................................................................................................................................................xxxxxx + xxx........................................................................................................................................................................................................................................................xxx + x............................................................................................................................................................................................................................................................x + B............................................................................................................................................................................................................................................................z + x............................................................................................................................................................................................................................................................x + xxx........................................................................................................................................................................................................................................................xxx + xxxxxxwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwxxxxxx + \ No newline at end of file diff --git a/test/integration/Main.hs b/test/integration/Main.hs index 572c94bfd..5993b547a 100644 --- a/test/integration/Main.hs +++ b/test/integration/Main.hs @@ -216,6 +216,7 @@ testScenarioSolutions rs ui = , testSolution (Sec 3) "Challenges/word-search" , testSolution (Sec 10) "Challenges/bridge-building" , testSolution (Sec 5) "Challenges/ice-cream" + , testSolution (Sec 15) "Challenges/wave" , testSolution (Sec 3) "Challenges/arbitrage" , testSolution (Sec 10) "Challenges/gopher" , testSolution (Sec 5) "Challenges/hackman"