Skip to content

Commit

Permalink
geological battery scenario
Browse files Browse the repository at this point in the history
  • Loading branch information
kostmo committed Nov 27, 2023
1 parent 44c2e60 commit 2d12f82
Show file tree
Hide file tree
Showing 2 changed files with 290 additions and 0 deletions.
44 changes: 44 additions & 0 deletions data/scenarios/Challenges/_polar/solution.sw
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@

def doN = \n. \f. if (n > 0) {f; doN (n - 1) f} {}; end;

def moveUntilBlocked =
b <- blocked;
if b {} {move; moveUntilBlocked}
end;

def drillUntilStuck : cmd (unit + text) =
try {
maybeRetrieved <- drill forward;
case maybeRetrieved (\_. return $ inL ()) (\_.
move;
drillUntilStuck;
);
return maybeRetrieved;
} {
return $ inL ();
}
end;

def go =
turn west;
doN 47 move;
turn right;

doN 6 (
moveUntilBlocked;
maybeItem <- drillUntilStuck;

case maybeItem return (\x.
iCount <- count x;
if (iCount < 3) {
turn left; drill forward; turn left
} {
turn back;
}
);


);
end;

go;
246 changes: 246 additions & 0 deletions data/scenarios/Challenges/polar.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,246 @@
version: 1
name: Geo-battery
author: Karl Ostmo
description: |
Harness resources from polar opposite regions
creative: false
seed: 4
attrs:
- name: anode
fg: "#dddddd"
bg: "#333333"
- name: cathode
fg: "#333333"
bg: "#dddddd"
- name: layer1a
fg: "#a6cee3"
bg: "#1f78b4"
- name: layer2a
fg: "#fb9a99"
bg: "#e31a1c"
- name: layer3a
fg: "#b2df8a"
bg: "#33a02c"
- name: layer1b
fg: "#fdbf6f"
bg: "#ff7f00"
- name: layer2b
fg: "#ffff99"
bg: "#b15928"
- name: layer3b
fg: "#cab2d6"
bg: "#6a3d9a"
objectives:
- teaser: Something
goal:
- |
Something
condition: |
return false
robots:
- name: base
dir: [1, 0]
devices:
- 3D printer
- blueprint
- branch predictor
- ADT calculator
- clock
- comparator
- compass
- counter
- dictionary
- drill
- fast grabber
- GPS receiver
- harvester
- hearing aid
- keyboard
- lambda
- logger
- net
- rolex
- scanner
- strange loop
- toolkit
- treads
- welder
- workbench
inventory:
- [3, bell jar]
solution: |
run "scenarios/Challenges/_polar/solution.sw"
entities:
- name: bell jar
display:
attr: device
char: 'J'
description:
- Can store one unit of substance
properties: [known, portable]
- name: anode
display:
attr: anode
char: 'A'
description:
- anode
properties: [known]
- name: cathode
display:
attr: cathode
char: 'C'
description:
- cathode
properties: [known]
- name: layer1a
display:
attr: layer1a
char: '*'
description:
- layer1a
properties: [known, unwalkable, portable]
- name: layer2a
display:
attr: layer2a
char: '*'
description:
- layer2a
properties: [known, unwalkable, portable]
- name: layer3a
display:
attr: layer3a
char: '*'
description:
- layer3a
properties: [known, unwalkable, portable]
- name: layer1b
display:
attr: layer1b
char: '*'
description:
- layer1b
properties: [known, unwalkable, portable]
- name: layer2b
display:
attr: layer2b
char: '*'
description:
- layer2b
properties: [known, unwalkable, portable]
- name: layer3b
display:
attr: layer3b
char: '*'
description:
- layer3b
properties: [known, unwalkable, portable]
- name: layer1a unit
display:
attr: layer1a
char: '*'
description:
- layer1a unit
properties: [known, unwalkable, portable]
- name: layer2a unit
display:
attr: layer2a
char: '*'
description:
- layer2a unit
properties: [known, unwalkable, portable]
- name: layer3a unit
display:
attr: layer3a
char: '*'
description:
- layer3a unit
properties: [known, unwalkable, portable]
- name: layer1b unit
display:
attr: layer1b
char: '*'
description:
- layer1b unit
properties: [known, unwalkable, portable]
- name: layer2b unit
display:
attr: layer2b
char: '*'
description:
- layer2b unit
properties: [known, unwalkable, portable]
- name: layer3b unit
display:
attr: layer3b
char: '*'
description:
- layer3b unit
properties: [known, unwalkable, portable]
recipes:
- in:
- [1, "bell jar"]
- [1, "layer1a"]
out:
- [1, "layer1a unit"]
required:
- [1, drill]
- in:
- [1, "layer1a unit"]
- [1, "layer1b"]
out:
- [1, "layer1b unit"]
required:
- [1, drill]
- in:
- [1, "layer1b unit"]
- [1, "layer2a"]
out:
- [1, "layer2a unit"]
required:
- [1, drill]
- in:
- [1, "layer2a unit"]
- [1, "layer2b"]
out:
- [1, "layer2b unit"]
required:
- [1, drill]
- in:
- [1, "layer2b unit"]
- [1, "layer3a"]
out:
- [1, "layer3a unit"]
required:
- [1, drill]
- in:
- [1, "layer3a unit"]
- [1, "layer3b"]
out:
- [1, "layer3b unit"]
required:
- [1, drill]
known: [tree, rock, flower, boulder]
world:
dsl: |
let
lakeNoise = perlin seed 1 0.04 0.0
in
overlay
[ {grass}
, mask (lakeNoise < -0.60) {layer1a}
, mask (lakeNoise < -0.70) {layer2a}
, mask (lakeNoise < -0.80) {layer3a}
, mask (lakeNoise < -0.90) {cathode}
, mask (lakeNoise > 0.60) {layer1b}
, mask (lakeNoise > 0.70) {layer2b}
, mask (lakeNoise > 0.80) {layer3b}
, mask (lakeNoise > 0.90) {anode}
]
upperleft: [0, 0]
offset: false
palette:
'B': [grass, erase, base]
'.': [grass, erase]
map: |
B..
...

0 comments on commit 2d12f82

Please sign in to comment.