-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Ubuntu
committed
Feb 10, 2017
1 parent
bbe7d5d
commit bbc3a76
Showing
5 changed files
with
71 additions
and
1 deletion.
There are no files selected for viewing
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
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) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
rm *.hlt | ||
rm *.log |
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
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 |
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
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 |
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
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 |