Skip to content

Commit

Permalink
fix gallery
Browse files Browse the repository at this point in the history
  • Loading branch information
byorgey committed Jan 5, 2025
1 parent ce710bd commit 61dc815
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 17 deletions.
30 changes: 16 additions & 14 deletions data/scenarios/Challenges/_gallery/setup.sw
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,21 @@ def naiveRandomStack = \valueFunc. \maxval. \bitmask. \n.
valueFunc val;
end;

def getEntName = \idx.
result <- tagmembers "bust" idx;
return $ snd result;
end;
def index : Int -> (rec l. Unit + a * l) -> a = \i. \l.
case l
(\_. fail "bad index")
(\cons. if (i == 0) {fst cons} {index (i-1) (snd cons)})
end

def length : (rec l. Unit + a * l) -> Int = \l.
case l (\_. 0) (\cons. 1 + length (snd cons))
end

def busts : (rec l. Unit + Text * l) = tagmembers "bust" end
def bustCount : {Int} = {length busts} end

def placeThing = \entIdx.
entName <- getEntName entIdx;
let entName = index entIdx busts in
create entName;
place entName;
end;
Expand All @@ -116,13 +124,10 @@ bust in the base's inventory increases monotonically.
"idx" counts upwards.
*/
def populateInventory = \baseCount. \idx.

result <- tagmembers "bust" idx;
let total = fst result in

if (idx < total) {
if (idx < force bustCount) {

let item = snd result in
let item = index idx busts in

// Give copies to the base
baseExtras <- random 5;
Expand All @@ -143,12 +148,9 @@ def populateInventory = \baseCount. \idx.
end;

def setup =
result <- tagmembers "bust" 0;
let totalCount = fst result in

populateInventory 0 0;

naiveRandomStack placeEntByIndex totalCount 0 totalCount;
naiveRandomStack placeEntByIndex (force bustCount) 0 (force bustCount);
turn back;
move;
create "bitcoin";
Expand Down
10 changes: 7 additions & 3 deletions data/scenarios/Challenges/gallery.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,18 @@ objectives:
);
end;
def length : (rec l. Unit + a * l) -> Int = \l.
case l (\_. 0) (\cons. 1 + length (snd cons))
end
j <- robotnamed "judge";
as j {
// Flag that setup is done
hasBitcoin <- has "bitcoin";
if hasBitcoin {
result <- tagmembers "bust" 0;
let itemCount = fst result in
ensureMonotonicDecreasing itemCount $ itemCount + 1;
let busts = tagmembers "bust" in
let bustCount = length busts in
ensureMonotonicDecreasing bustCount $ bustCount + 1;
} {
return false;
}
Expand Down

0 comments on commit 61dc815

Please sign in to comment.