Skip to content

Instantly share code, notes, and snippets.

@filp
Last active December 11, 2015 16:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save filp/4628644 to your computer and use it in GitHub Desktop.
Save filp/4628644 to your computer and use it in GitHub Desktop.
botbot is the meanest bot in town
# botbot
# how 2 gridlang
# get initial direction
STORE dir << @WEST
CALL << @wtfmove
# main loop
@botbot
# move around randomly and steal everything we can
CALL << @wtfmove
# move & gather until we can't move any more
@moving
CALL << @gather
CALLFF << @MOVE dir 2
IFFGOTO @stopmoving
GOTO << @moving
@stopmoving
GOTO << @botbot
# routines
@wtfmove
# choose a random direction
PUSH @NORTH
PUSH @WEST
PUSH @EAST
PUSH @SOUTH
# [n, w, e, s, MOVE, RAND]
RAND << 3
PEEK # pop RAND, push one of 4 directions
# store direction constant in keyreg
STORE dir
# cleanup the remaining junk
POPN << 4
RETURN
@gather
CALLFF << @PULL @NORTH 2
CALLFF << @PULL @SOUTH 2
CALLFF << @PULL @EAST 2
CALLFF << @PULL @WEST 2
RETURN
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment