diff --git a/MyAmbiturner.py b/MyAmbiturner.py new file mode 100644 index 0000000..698268c --- /dev/null +++ b/MyAmbiturner.py @@ -0,0 +1,46 @@ +import hlt +from hlt import NORTH, EAST, SOUTH, WEST, STILL, Move, Square +import random + +myID, game_map = hlt.get_init() +hlt.send_init("SaltBot") +CARDINALS = [NORTH, EAST, SOUTH, WEST] + +def findNearestOther(square): + direction = NORTH + maxDistance = min(game_map.width,game_map.height)/2 + + for thisDirection in CARDINALS: + distance = 0 + current = square + site = game_map.get_target(current, thisDirection) + while ((site.owner == myID) and (distance < maxDistance)): + distance += 1 + current = site + site = game_map.get_target(current, thisDirection) + + if distance < maxDistance: + direction = thisDirection + maxDistance = distance + + return direction + +def assignMove(square): + squareIsBorder = False + for direction, neighbor in enumerate(game_map.neighbors(square)): + if neighbor.owner != myID: + squareIsBorder=True + if neighbor.strength < square.strength: + return Move(square,direction) + + if square.strength < 5 * square.production: + return Move(square, STILL) + elif not squareIsBorder: + return Move(square, findNearestOther(square)) + else: + return Move(square,STILL) + +while True: + game_map.get_frame() + moves = [assignMove(square) for square in game_map if square.owner == myID] + hlt.send_frame(moves) diff --git a/clean.sh b/clean.sh new file mode 100755 index 0000000..e40da0e --- /dev/null +++ b/clean.sh @@ -0,0 +1,2 @@ +rm *.hlt +rm *.log diff --git a/games.sh b/games.sh new file mode 100755 index 0000000..2e658af --- /dev/null +++ b/games.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +for i in `seq 1 10`; +do + if hash python3 2>/dev/null; then + halite -d "30 30" "python3 MyBot.py" "python3 RandomBot.py" > game$i.log + else + halite -d "30 30" "python MyBot.py" "python RandomBot.py" > game$i.log + fi +done diff --git a/install.sh b/install.sh index 63bee99..f37813e 100755 --- a/install.sh +++ b/install.sh @@ -1 +1,6 @@ -pip install numpy scipy sckit-learn pillow h5py +pip3 install numpy scipy scikit-learn pillow h5py +pip3 install --upgrade --no-deps git+git://github.com/Theano/Theano.git +#pip3 install keras +export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.11.0-cp35-cp35m-linux_x86_64.whl +#export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.11.0-cp27-none-linux_x86_64.whl +pip3 install --upgrade $TF_BINARY_URL diff --git a/runGame.sh b/runGame.sh new file mode 100755 index 0000000..60868be --- /dev/null +++ b/runGame.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +if hash python3 2>/dev/null; then + halite -d "30 30" "python3 MyBot.py" "python3 RandomBot.py" +else + halite -d "30 30" "python MyBot.py" "python RandomBot.py" +fi