From 2eb96d2df1da59abaf3d05c1d1c029d11a8cb0d8 Mon Sep 17 00:00:00 2001 From: Karl Ostmo Date: Fri, 27 Jan 2023 22:05:54 -0800 Subject: [PATCH] full scripted demo --- data/scenarios/Challenges/_dna/solution.sw | 5 +- data/scenarios/Challenges/_dna/verifier.sw | 78 ++++++++++++++++------ data/scenarios/Challenges/dna.yaml | 77 ++++++++++++++++++--- 3 files changed, 129 insertions(+), 31 deletions(-) diff --git a/data/scenarios/Challenges/_dna/solution.sw b/data/scenarios/Challenges/_dna/solution.sw index 5672b9430..01e50944c 100644 --- a/data/scenarios/Challenges/_dna/solution.sw +++ b/data/scenarios/Challenges/_dna/solution.sw @@ -60,8 +60,9 @@ def go = waitWhileHere sentinel; moveToPattern; replicatePattern moveToOtherRow 32; - move; - _ <- grab; + + // Activate the switch + drill forward; end; go; \ No newline at end of file diff --git a/data/scenarios/Challenges/_dna/verifier.sw b/data/scenarios/Challenges/_dna/verifier.sw index c115d8f36..ed71decdb 100644 --- a/data/scenarios/Challenges/_dna/verifier.sw +++ b/data/scenarios/Challenges/_dna/verifier.sw @@ -48,7 +48,6 @@ def getComplementNumber = \n. }; end; - def waitWhileHere = \item. stillHere <- ishere item; if stillHere { @@ -65,13 +64,23 @@ def waitUntilHere = \item. }; end; +def waitUntilHas = \item. + hasNow <- has item; + if hasNow {} { + wait 2; + waitUntilHas item; + }; + end; + def myStandby = teleport self (1, -4); - _flower <- grab; + entToClone <- grab; teleport self (3, -11); - waitWhileHere "bit (0)"; + waitWhileHere "switch (off)"; teleport self (36, -11); turn back; + + return entToClone; end; def waitForItem : dir -> cmd text = \d. @@ -79,18 +88,17 @@ def waitForItem : dir -> cmd text = \d. case item (\_. waitForItem d) return; end; -def placeComplements = \n. +def placeComplements = \d. \n. if (n > 0) { - item <- waitForItem left; + item <- waitForItem d; baseNumber <- getNumberForBase item; complementNumber <- getComplementNumber baseNumber; newItem <- getBaseForNumber complementNumber; - create newItem; place newItem; move; - placeComplements $ n - 1; + placeComplements d $ n - 1; } { - selfdestruct; + // selfdestruct; }; end; @@ -104,36 +112,68 @@ def placeBase = \standbyFunc. \n. place ent; move; - placeBase standbyFunc $ n - 1; + clonedOrganism <- placeBase standbyFunc $ n - 1; - place ent; - move; + // Verifies the original placement order + placedEnt <- scan down; + isGood <- case placedEnt (\_. return false) (\x. return $ x == ent); + + move; + if isGood { + return clonedOrganism; + } { + return "organic sludge"; + }; } { + // Returns the clonedOrganism standbyFunc; - }; end; def spawnComplementer = - create "treads"; - create "scanner"; - _buddy <- build { + buddy <- build { + + require 64 "guanine"; + require 64 "cytosine"; + require 64 "adenine"; + require 64 "thymine"; + + appear "U"; + turn right; move; turn left; - placeComplements 32; + placeComplements left 32; + + turn right; + doN 9 move; + turn right; + move; + + waitUntilHas "gold coin"; + placeComplements right 32; + + appear "x"; }; + return buddy; end; def makeDnaStrand = teleport self (5, -2); - spawnComplementer; - placeBase myStandby 32; + r <- spawnComplementer; + clonedOrganism <- placeBase myStandby 32; + drill forward; + teleport self (36, -12); + give r "gold coin"; + + return clonedOrganism end; def go = waitUntilHere "flower"; - makeDnaStrand; + clonedOrganism <- makeDnaStrand; + teleport self (40, -13); + place clonedOrganism; end; go; \ No newline at end of file diff --git a/data/scenarios/Challenges/dna.yaml b/data/scenarios/Challenges/dna.yaml index 8003f43cf..9c9d99c71 100644 --- a/data/scenarios/Challenges/dna.yaml +++ b/data/scenarios/Challenges/dna.yaml @@ -3,7 +3,7 @@ name: DNA author: Karl Ostmo description: | Splice organisms -creative: true +creative: false seed: 1 objectives: - goal: @@ -26,6 +26,7 @@ robots: - lambda - logger - welder + - drill - hearing aid - scanner - strange loop @@ -39,13 +40,34 @@ robots: system: true dir: [1, 0] display: - invisible: false + invisible: true attr: 'robot' + devices: + - drill inventory: - - [64, guanine] - - [64, cytosine] - - [64, adenine] - - [64, thymine] + - [128, guanine] + - [128, cytosine] + - [128, adenine] + - [128, thymine] + - [1, gold coin] + - [1, organic sludge] + - [1, branch predictor] + - [1, treads] + - [1, beaglepuss] + - [1, antenna] + - [1, comparator] + - [1, clock] + - [1, workbench] + - [1, grabber] + - [1, ADT calculator] + - [1, dictionary] + - [1, lambda] + - [1, logger] + - [1, welder] + - [1, hearing aid] + - [1, scanner] + - [1, strange loop] + - [1, solar panel] program: | run "data/scenarios/Challenges/_dna/verifier.sw" solution: | @@ -83,6 +105,40 @@ entities: - One of the four nucleobases in DNA. - Is paired with "adenine". properties: [portable, known] + - name: switch (off) + display: + attr: red + char: '•' + description: + - A control in the deactivated position. + properties: [known] + - name: switch (on) + display: + attr: green + char: '•' + description: + - A control in the activated position. + properties: [known] + - name: organic sludge + display: + attr: green + char: 'S' + description: + - A repulsive, shuddering mass of slime. + properties: [portable] +recipes: + - in: + - [1, switch (off)] + out: + - [1, switch (on)] + required: + - [1, drill] + - in: + - [1, switch (on)] + out: + - [1, switch (off)] + required: + - [1, drill] known: [bit (0), bit (1)] world: default: [grass] @@ -92,6 +148,7 @@ world: '┬': [stone, down and horizontal wall] '┴': [stone, up and horizontal wall] '─': [stone, horizontal wall] + '│': [stone, vertical wall] '├': [stone, right and vertical wall] '┐': [stone, upper right corner] '┘': [stone, lower right corner] @@ -102,7 +159,7 @@ world: ':': [blank] 'v': [blank, null, verifier] 'B': [stone, null, base] - '0': [blank, bit (0)] + '0': [blank, switch (off)] map: | .................................................................. .....┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬............................. @@ -114,9 +171,9 @@ world: .................................................................. .................................................................. .................................................................. - .....┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬............................. - ...0.::::::::::::::::::::::::::::::::............................. - .....::::::::::::::::::::::::::::::::..┌┐......................... + ..┌─.┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬............................. + ..│0.::::::::::::::::::::::::::::::::............................. + ..└─.::::::::::::::::::::::::::::::::..┌┐......................... .....┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴──┤:......................... .......................................└┘......................... ..................................................................