Skip to content

Commit

Permalink
fix vs wolve
Browse files Browse the repository at this point in the history
  • Loading branch information
[email protected] authored and [email protected] committed Jun 7, 2020
1 parent fd919ab commit cb88c45
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions agent1_zero_dnn/vs_wolve.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import sys
import math
from keras.models import load_model
from agent1_zero_dnn.game import print_board, winner, best_move, new_board, fix_probabilities
from agent1_zero_dnn.tree_search import TreeSearchPredictor
from agent1_zero_dnn.game import print_board, winner, flip, flip_move, best_move, new_board, sample_move, shlomo_move, fix_probabilities
from agent1_zero_dnn.tree_search import TreeSearchPredictor, temperature
from agent1_zero_dnn.config import CompareConfig

from agent1_zero_dnn.wolve_integration import WolveProcess
Expand Down Expand Up @@ -41,7 +43,9 @@ def compare(config, num_games, temp, Temp, name):
alpha_wins = 0
wolve_wins = 0

# while True:
for i in range(num_games):
# alpha_agent = TreeSearchPredictor(config.search_config, model, new_board(config.size), True, t, T)
alpha_agent = TreeSearchPredictor(config.search_config, model, new_board(config.size), True, temp, Temp)

# make sure wolve have new clear board
Expand All @@ -54,24 +58,35 @@ def compare(config, num_games, temp, Temp, name):
# alpha turn
alpha_agent.run(config.iterations)
value, probabilities = alpha_agent.predict()
#print(probabilities)
#probabilities = fix_probabilities(alpha_agent.board, probabilities)
probabilities = fix_probabilities(alpha_agent.board, probabilities)
#print(probabilities)
alpha_move = best_move(probabilities)
#print('alphaaaaa: ', alpha_move)
alpha_agent.make_move(alpha_move)
# insert move to wolve
letter, number = alpha_move
alpha_move = str(num_to_letter[letter]) + str(number + 1)
#print(f'alpha(B): {alpha_move}')
wolve.insert_move("black", alpha_move)
if winner(alpha_agent.board):
print("alpha wins!!!")
alpha_wins += 1
continue
# wolve turn
wolve_move = wolve.genmove("white")
#print(f'wolve(W): {wolve_move}')
letter = letter_to_num[wolve_move[0]]
number = int(wolve_move[1:]) - 1
#wolve_move = (letter, number)
wolve_move = (number, letter)
# insert wolve move to alpha
alpha_agent.make_move(wolve_move)
#print('wove board:')
#print(wolve.showboard())
# print('alpha board:')
# print_board(flip(alpha_agent.board), wolve_move, file=sys.stderr)
if winner(alpha_agent.board):
print("wolve wins!!!")
wolve_wins += 1
Expand All @@ -87,7 +102,9 @@ def compare(config, num_games, temp, Temp, name):


if __name__ == '__main__':
# multi_compare(CompareConfig(), sys.argv[1], sys.argv[2])
model = load_model('/home/avshalom/PycharmProjects/zeroHex/agent1_zero_dnn/model')
# /home/avshalom/PycharmProjects/benzene-vanilla-cmake
wolve = WolveProcess("/home/avshalom/PycharmProjects/benzene-vanilla-cmake/build/src/wolve/wolve")
res = wolve.boardsize("11")
# limit wolves thinking
Expand All @@ -97,6 +114,7 @@ def compare(config, num_games, temp, Temp, name):
wolve.param_wolve('ply_width', 1)
wolve.param_wolve('tt_bits', 2)


# competition
num_games = 10
players_arr = [[0.01, 0.01, 'Lisa'], [0.24, 0.08, 'Bart'], [0.44, 0.3, 'Maggie'], [0.49, 0.38, 'Homer']]
Expand All @@ -106,6 +124,7 @@ def compare(config, num_games, temp, Temp, name):
print(player[2], 'percent is: ', wolve_vic*100, '%')



'''
param_wolve
=
Expand Down

0 comments on commit cb88c45

Please sign in to comment.