diff --git a/data/scenarios/Challenges/_pied-piper/rat.sw b/data/scenarios/Challenges/_pied-piper/rat.sw new file mode 100644 index 000000000..65310b82a --- /dev/null +++ b/data/scenarios/Challenges/_pied-piper/rat.sw @@ -0,0 +1,37 @@ +def findGoodDirection = + isBlocked <- blocked; + if isBlocked { + turn left; + findGoodDirection; + } {}; + end; + +def moveUntilBlocked = + isBlocked <- blocked; + if isBlocked { + } { + move; + moveUntilBlocked; + }; + end; + +def pauseAtRandom = + r <- random 3; + if (r == 0) { + r2 <- random 8; + wait $ 4 + r2; + } {} + end; + +def doMovement = + findGoodDirection; + moveUntilBlocked; + pauseAtRandom + end; + +def go = + doMovement; + go; + end; + +go; \ No newline at end of file diff --git a/data/scenarios/Challenges/_pied-piper/solution.sw b/data/scenarios/Challenges/_pied-piper/solution.sw new file mode 100644 index 000000000..e69de29bb diff --git a/data/scenarios/Challenges/pied-piper.yaml b/data/scenarios/Challenges/pied-piper.yaml new file mode 100644 index 000000000..9bade0837 --- /dev/null +++ b/data/scenarios/Challenges/pied-piper.yaml @@ -0,0 +1,165 @@ +version: 1 +name: Pied Piper +author: Karl Ostmo +description: | + Rid the village of pests. +creative: false +attrs: + - name: oats + fg: "#444444" + bg: "#F5DEB3" + - name: bridge + bg: "#806040" +terrains: + - name: bridge + attr: bridge + description: | + Wooden raised path +robots: + - name: base + dir: north + devices: + - 3D printer + - ADT calculator + - antenna + - branch predictor + - clock + - comparator + - counter + - dictionary + - grabber + - lambda + - logger + - net + - scanner + - strange loop + - string + - workbench + - name: rat + system: true + dir: west + display: + invisible: false + char: 'r' + devices: + - logger + program: | + run "scenarios/Challenges/_pied-piper/rat.sw" + - name: helper + loc: [0, 0] + system: true + dir: west + display: + invisible: false + devices: + - logger + program: | + teleport base (12, -13); +objectives: + - goal: + - Rats have infested the dwellings. Clear them out! + condition: | + try { + r <- robotNamed "rat"; + return false; + } {return true} +solution: | + run "scenarios/Challenges/_pied-piper/solution.sw" +entities: + - name: door + display: + char: 'X' + description: + - door + properties: [known] + - name: oats + display: + attr: oats + char: 'a' + description: + - Grain + properties: [known, pickable, growable] + growth: + duration: [20, 30] +known: [water] +seed: 0 +world: + structures: + - name: house + structure: + palette: + 'd': [stone, door] + 'x': [stone, boulder] + '.': [stone] + 'r': [stone, erase, rat] + map: | + xxxxxxxxxx + x........x + d........x + x........x + x.....r..x + x........x + x........x + xxxxxxxxxx + - name: street pair + structure: + palette: + 's': [stone] + '.': [grass] + placements: + - src: house + offset: [-9, 0] + orient: + up: south + - src: house + offset: [17, 0] + orient: + flip: true + map: | + ..ssss.. + ..ssss.. + ..ssss.. + ..ssss.. + ..ssss.. + ..ssss.. + ..ssss.. + ..ssss.. + ..ssss.. + ..ssss.. + ..ssss.. + - name: block + structure: + placements: + - src: street pair + offset: [0, 0] + orient: + flip: true + - src: street pair + offset: [0, 6] + map: "" + palette: + 'Ω': [grass, erase, base] + 's': [stone, erase] + '.': [grass] + 'b': [bridge, erase] + placements: + - src: block + offset: [-7, -11] + upperleft: [0, 7] + dsl: | + overlay + [ {grass} + , mask (y > -2 && y < 2) {water} + ] + map: | + ....ssss.. + ....ssss.. + ....ssss.. + ....ssss.. + Ω...ssss.. + ....bbbb.. + ....bbbb.. + ....bbbb.. + ....bbbb.. + ....bbbb.. + ....ssss..