Created
October 8, 2021 16:45
-
-
Save byorgey/2e85242a9fdb35bf23d1a67f2e470e0d to your computer and use it in GitHub Desktop.
Harvesting along a line
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def ifC : cmd bool -> cmd a -> cmd a -> cmd a = \test. \then. \else. | |
b <- test; if b then else | |
end | |
def x2 = \c. c;c end | |
def x4 = \c. x2 c; x2 c end | |
def x8 = \c. x4 c; x4 c end | |
def x16 = \c. x8 c; x8 c end | |
def x32 = \c. x16 c; x16 c end | |
def x64 = \c. x32 c; x32 c end | |
def x128 = \c. x64 c; x64 c end | |
def x256 = \c. x128 c; x128 c end | |
def x512 = \c. x256 c; x256 c end | |
def x1024 = \c. x512 c; x512 c end | |
// Harvest a specific item for a certain distance along a straight line, | |
// then turn around and come back. Use it as in 'harvestline x32 "rock"'. | |
// This is useful in the early game | |
// since it only requires a lambda and a branch predictor, and doesn't | |
// require you to know the exact distances to specific items, just that | |
// there are some items along a line. | |
def harvestline = \rep. \thing. | |
rep { | |
ifC (ishere thing) (grab; return ()) noop; | |
move | |
}; | |
turn back; | |
rep move | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment