Skip to content

Commit

Permalink
cleanup, add test
Browse files Browse the repository at this point in the history
  • Loading branch information
kostmo committed Jan 12, 2023
1 parent e5b65ff commit cc8614e
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 5 deletions.
21 changes: 18 additions & 3 deletions data/scenarios/Challenges/_word-search/create-puzzle.sw
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,18 @@ def intersperse = \n. \f2. \f1. if (n > 0) {
} {};
end;

/**
Call a function repeatedly with the numeric argument,
in descending order.
*/
def iterN = \n. \f.
if (n > 0) {
let newNum = n - 1 in
f newNum;
iterN newNum f;
} {};
end;

def chooseLetter = \i.
if (i == 0) {
return "capital C";
Expand Down Expand Up @@ -94,6 +106,11 @@ def layTilesRow = \expectedFwdOrdinal. \expectedBkwdOrdinal. \n.
} {};
end;

def giveLetterNumbered = \n.
letter <- chooseLetter n;
give base letter;
end;

def removeBoulder =
baseLoc <- as base {whereami};
teleport self (fst baseLoc - 1, snd baseLoc);
Expand All @@ -103,9 +120,7 @@ def removeBoulder =

// Make sure the base "knows" about the letters
// to get rid of the question marks ("?").
give base "capital C";
give base "capital O";
give base "capital W";
iterN 3 giveLetterNumbered;

selfdestruct;
end;
Expand Down
7 changes: 5 additions & 2 deletions data/scenarios/Challenges/word-search.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ objectives:
- |
First, wait for the playfield to be set up,
and then your path forward will be cleared.
- |
You can speed this process up with CTRL+x.
condition: |
r <- robotnamed "lettersetter";
as r {has "boulder"};
as base {knows "capital C"};
- goal:
- Use the `drill` command to mark the sequence of letters that
spells COW within the designated playfield.
Expand Down Expand Up @@ -101,6 +102,8 @@ objectives:
robots:
- name: base
display:
attr: flower
dir: [-1, 0]
devices:
- treads
Expand Down
1 change: 1 addition & 0 deletions test/integration/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ testScenarioSolution _ci _em =
[ testSolution Default "Challenges/chess_horse"
, testSolution Default "Challenges/teleport"
, testSolution (Sec 5) "Challenges/2048"
, testSolution Default "Challenges/word-search"
, testSolution (Sec 10) "Challenges/hanoi"
, testSolution Default "Challenges/friend"
, testGroup
Expand Down

0 comments on commit cc8614e

Please sign in to comment.