From cc8614e370bfbaa64898e467d8659f253be7aaff Mon Sep 17 00:00:00 2001 From: Karl Ostmo Date: Thu, 12 Jan 2023 14:43:20 -0800 Subject: [PATCH] cleanup, add test --- .../Challenges/_word-search/create-puzzle.sw | 21 ++++++++++++++++--- data/scenarios/Challenges/word-search.yaml | 7 +++++-- test/integration/Main.hs | 1 + 3 files changed, 24 insertions(+), 5 deletions(-) diff --git a/data/scenarios/Challenges/_word-search/create-puzzle.sw b/data/scenarios/Challenges/_word-search/create-puzzle.sw index 7e1a7dc8a..4fb41b339 100644 --- a/data/scenarios/Challenges/_word-search/create-puzzle.sw +++ b/data/scenarios/Challenges/_word-search/create-puzzle.sw @@ -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"; @@ -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); @@ -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; diff --git a/data/scenarios/Challenges/word-search.yaml b/data/scenarios/Challenges/word-search.yaml index d35e70d3c..c587322e6 100644 --- a/data/scenarios/Challenges/word-search.yaml +++ b/data/scenarios/Challenges/word-search.yaml @@ -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. @@ -101,6 +102,8 @@ objectives: robots: - name: base + display: + attr: flower dir: [-1, 0] devices: - treads diff --git a/test/integration/Main.hs b/test/integration/Main.hs index eb1666774..220a67503 100644 --- a/test/integration/Main.hs +++ b/test/integration/Main.hs @@ -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