Skip to content

Commit

Permalink
full scripted demo
Browse files Browse the repository at this point in the history
  • Loading branch information
kostmo committed Jan 28, 2023
1 parent 0135507 commit 2eb96d2
Show file tree
Hide file tree
Showing 3 changed files with 129 additions and 31 deletions.
5 changes: 3 additions & 2 deletions data/scenarios/Challenges/_dna/solution.sw
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,9 @@ def go =
waitWhileHere sentinel;
moveToPattern;
replicatePattern moveToOtherRow 32;
move;
_ <- grab;

// Activate the switch
drill forward;
end;

go;
78 changes: 59 additions & 19 deletions data/scenarios/Challenges/_dna/verifier.sw
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ def getComplementNumber = \n.
};
end;


def waitWhileHere = \item.
stillHere <- ishere item;
if stillHere {
Expand All @@ -65,32 +64,41 @@ 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.
item <- scan 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;

Expand All @@ -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;
77 changes: 67 additions & 10 deletions data/scenarios/Challenges/dna.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: DNA
author: Karl Ostmo
description: |
Splice organisms
creative: true
creative: false
seed: 1
objectives:
- goal:
Expand All @@ -26,6 +26,7 @@ robots:
- lambda
- logger
- welder
- drill
- hearing aid
- scanner
- strange loop
Expand All @@ -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: |
Expand Down Expand Up @@ -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]
Expand All @@ -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]
Expand All @@ -102,7 +159,7 @@ world:
':': [blank]
'v': [blank, null, verifier]
'B': [stone, null, base]
'0': [blank, bit (0)]
'0': [blank, switch (off)]
map: |
..................................................................
.....┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬.............................
Expand All @@ -114,9 +171,9 @@ world:
..................................................................
..................................................................
..................................................................
.....┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬.............................
...0.::::::::::::::::::::::::::::::::.............................
.....::::::::::::::::::::::::::::::::..┌┐.........................
..┌─.┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬.............................
..0.::::::::::::::::::::::::::::::::.............................
..└─.::::::::::::::::::::::::::::::::..┌┐.........................
.....┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴──┤:.........................
.......................................└┘.........................
..................................................................
Expand Down

0 comments on commit 2eb96d2

Please sign in to comment.