Skip to content

Commit

Permalink
forging paths through different mediums
Browse files Browse the repository at this point in the history
  • Loading branch information
kostmo committed Mar 4, 2023
1 parent 4dba124 commit 6960946
Show file tree
Hide file tree
Showing 5 changed files with 1,203 additions and 0 deletions.
1 change: 1 addition & 0 deletions data/scenarios/Challenges/00-ORDER.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
chess_horse.yaml
bridge-building.yaml
teleport.yaml
2048.yaml
word-search.yaml
Expand Down
62 changes: 62 additions & 0 deletions data/scenarios/Challenges/_bridge-building/flower-ring-check.sw
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
def doN = \n. \f. if (n > 0) {f; doN (n - 1) f} {}; end;


def isItemInDirection = \direction. \item.
x <- scan direction;
return $ case x (\_. false) (\y. y == item);
end;

def isFlankedByItem = \item.
hasLeft <- isItemInDirection left item;
hasRight <- isItemInDirection right item;
return $ hasLeft && hasRight;
end;

def flowersInCardinalDirections = \item. \n.
if (n > 0) {
x <- isItemInDirection forward item;
if x {
turn left;
flowersInCardinalDirections item $ n - 1;
} {
return false;
};
} {
return true;
}
end;

def flowersAround = \item.
hasCardinals <- flowersInCardinalDirections item 4;
if hasCardinals {
move;
isFlanked1 <- isFlankedByItem item;
turn back;
move;
if isFlanked1 {
move;
isFlanked2 <- isFlankedByItem item;
turn back;
move;
return isFlanked2;
} {
return false;
}
} {
return false;
}
end;

// loop until condition is met
def waitUntilSurrounded =
isSurrounded <- flowersAround "flower";
if isSurrounded {} {
wait 2;
waitUntilSurrounded;
}
end;

waitUntilSurrounded;

_t <- swap "painted plate";
selfdestruct;

0 comments on commit 6960946

Please sign in to comment.