Skip to content

Instantly share code, notes, and snippets.

@popey456963
Created November 10, 2016 21:17
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 popey456963/c549c94e5cc90084996c411b64b2cd24 to your computer and use it in GitHub Desktop.
Save popey456963/c549c94e5cc90084996c411b64b2cd24 to your computer and use it in GitHub Desktop.
from hlt import *
from networking import *
myID, gameMap = getInit()
sendInit("PythonBot")
while True:
moves = []
gameMap = getFrame()
for y in range(gameMap.height):
for x in range(gameMap.width):
if gameMap.getSite(Location(x, y)).owner == myID:
movedPiece = False
if not movedPiece and gameMap.getSite(Location(x, y)).strength < gameMap.getSite(Location(x, y)).production * 5:
moves.append(Move(Location(x, y), STILL))
movedPiece = True
if not movedPiece:
moves.append(Move(Location(x, y), NORTH if bool(int(random.random() * 2)) else WEST))
movedPiece = True
sendFrame(moves)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment