Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adventure game scenario #1136

Merged
merged 1 commit into from
Mar 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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;