Skip to content

Commit

Permalink
adding scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
Ubuntu committed Feb 10, 2017
1 parent bbe7d5d commit bbc3a76
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 1 deletion.
46 changes: 46 additions & 0 deletions MyAmbiturner.py
Original file line number Diff line number Diff line change
@@ -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)
2 changes: 2 additions & 0 deletions clean.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
rm *.hlt
rm *.log
10 changes: 10 additions & 0 deletions games.sh
Original file line number Diff line number Diff line change
@@ -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
7 changes: 6 additions & 1 deletion install.sh
Original file line number Diff line number Diff line change
@@ -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
7 changes: 7 additions & 0 deletions runGame.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit bbc3a76

Please sign in to comment.