Skip to content

Instantly share code, notes, and snippets.

@sirpengi
Last active December 10, 2015 23:28
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 sirpengi/4509092 to your computer and use it in GitHub Desktop.
Save sirpengi/4509092 to your computer and use it in GitHub Desktop.
slightly smarter bot
# This bot will continually travel south
# pulling from all directions. if it encounters
# any obstacles, it'll move out of the way
@LOOPSTART
# look around for resources
CALLFF << @LOOK @NORTH 2
EQUAL << @CELL_RESOURCE
IFTGOTO << @PULLNORTH
CALLFF << @LOOK @EAST 2
EQUAL << @CELL_RESOURCE
IFTGOTO << @PULLEAST
CALLFF << @LOOK @WEST 2
EQUAL << @CELL_RESOURCE
IFTGOTO << @PULLWEST
CALLFF << @LOOK @SOUTH 2
EQUAL << @CELL_RESOURCE
IFTGOTO << @PULLSOUTH
#look around for free path to move
CALLFF << @LOOK @SOUTH 2
EQUAL << @CELL_ROBOT
IFTGOTO << @PUSHSOUTH
CALLFF << @LOOK @EAST 2
EQUAL << @CELL_ROBOT
IFTGOTO << @PUSHEAST
CALLFF << @LOOK @WEST 2
EQUAL << @CELL_ROBOT
IFTGOTO << @PUSHWEST
CALLFF << @LOOK @SOUTH 2
EQUAL << @CELL_ROBOT
IFTGOTO << @PUSHSOUTH
@MOVESOUTH
PUSH @SOUTH
GOTO << @DOMOVE
@MOVEWEST
PUSH @WEST
GOTO << @DOMOVE
@MOVEEAST
PUSH @EAST
GOTO << @DOMOVE
@DOMOVE
PUSH @MOVE
SWAP
CALLFF << 2
POP
GOTO << @LOOPEND
@PUSHSOUTH
PUSH @SOUTH
GOTO << @DOPUSH
@PUSHWEST
PUSH @WEST
GOTO << @DOPUSH
@PUSHEAST
PUSH @EAST
GOTO << @DOPUSH
@DOPUSH
PUSH @PUSH
SWAP
CALLFF << 2
POP
GOTO << @LOOPEND
@PULLNORTH
PUSH @NORTH
GOTO << @DOPULL
@PULLSOUTH
PUSH @SOUTH
GOTO << @DOPULL
@PULLEAST
PUSH @EAST
GOTO << @DOPULL
@PULLWEST
PUSH @WEST
GOTO << @DOPULL
@DOPULL
PUSH @PULL
SWAP
CALLFF << 2
POP
GOTO << @LOOPEND
@LOOPEND
GOTO << @LOOPSTART
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment