Merge pull request #103 from bale-go/user_data_based_AI

User data based ai
This commit is contained in:
sanderland authored and GitHub committed 2020-06-26 23:08:42 +02:00
commit 33804225d0
2 files changed
+8 -2

No files matched your search

+1 -1
View File
@@ -143,7 +143,7 @@ def generate_ai_move(game: Game, ai_mode: str, ai_settings: Dict) -> Tuple[Move,
if ai_mode != AI_RANK:
n_moves = int(ai_settings["pick_frac"] * len(legal_policy_moves) + ai_settings["pick_n"])
else:
n_moves = int(round(board_squares / 361 * 10 ** (-0.05737 * ai_settings["kyu_rank"] + 1.9482)))
n_moves = int(round(board_squares / 361 * len(legal_policy_moves)/(1.311648546930214*((0.31164467+0.55726218*(len(legal_policy_moves)/board_squares)*math.exp(-1*(3.0308747*(len(legal_policy_moves)/board_squares)*(len(legal_policy_moves)/board_squares)-(len(legal_policy_moves)/board_squares)-0.045792218*ai_settings["kyu_rank"]-0.31164467)**2)-0.0064860256*ai_settings["kyu_rank"])*(0.0630149+0.762399*board_squares/(10**(-0.05737*ai_settings["kyu_rank"]+1.9482))))-0.08265346672884874)))
if ai_mode in [AI_INFLUENCE, AI_TERRITORY, AI_LOCAL, AI_TENUKI]:
if cn.depth > ai_settings["endgame"] * board_squares:
+7 -1
View File
@@ -191,6 +191,11 @@ class RankGraph(Graph):
if not non_obvious_moves:
return None
num_legal, rank, value = zip(*non_obvious_moves)
rank = list(rank)
for (i, item) in enumerate(rank):
if item > num_legal[i]*0.07:
rank[i] = num_legal[i]*0.07
rank = tuple(rank)
averagemod_rank = averagemod(rank)
averagemod_len_legal = averagemod(num_legal)
# the averagemod_rank is the outlier free average of the best move from a selection of n_moves with averagemod_len_legal of total legal moves
@@ -226,7 +231,8 @@ class RankGraph(Graph):
for segment_mid in range(0, len(nodes), dx):
bounds = (max(0, segment_mid - half_seg), min(segment_mid + half_seg, len(nodes)))
for pl, rank in self.calculate_ranks(policy_stats[bounds[0] : bounds[1] + 1], num_intersec).items():
ranks[pl].append((segment_mid, rank))
if bounds[1]-bounds[0]>self.segment_length * .75:
ranks[pl].append((segment_mid, rank))
self.rank_by_player = ranks
self.redraw_trigger()