Last active
December 11, 2015 16:38
-
-
Save filp/4628644 to your computer and use it in GitHub Desktop.
botbot is the meanest bot in town
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
# 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