black&real5d

This commit is contained in:
bale-go committed 2020-06-27 14:22:26 +02:00
1 parent 2703618f3d
commit ee38505e60
2 files changed
+37 -10

No files matched your search

+22 -3
View File
@@ -188,10 +188,29 @@ def generate_ai_move(game: Game, ai_mode: str, ai_settings: Dict) -> Tuple[Move,
if ai_mode != AI_RANK: if ai_mode != AI_RANK:
n_moves = int(ai_settings["pick_frac"] * len(legal_policy_moves) + ai_settings["pick_n"]) n_moves = int(ai_settings["pick_frac"] * len(legal_policy_moves) + ai_settings["pick_n"])
else: else:
orig_calib_avemodrank = 0.063015 + 0.7624 * board_squares/(10**(-0.05737*ai_settings["kyu_rank"]+1.9482)) orig_calib_avemodrank = 0.063015 + 0.7624 * board_squares / (
10 ** (-0.05737 * ai_settings["kyu_rank"] + 1.9482)
)
norm_leg_moves = len(legal_policy_moves) / board_squares norm_leg_moves = len(legal_policy_moves) / board_squares
modified_calib_avemodrank = (0.3931+0.6559*norm_leg_moves*math.exp(-1*(3.002*norm_leg_moves*norm_leg_moves-norm_leg_moves-0.034889*ai_settings["kyu_rank"]-0.5097)**2)-0.01093*ai_settings["kyu_rank"]) * orig_calib_avemodrank modified_calib_avemodrank = (
n_moves = int(round(board_squares * norm_leg_moves/(1.31165*(modified_calib_avemodrank+1)-0.082653))) 0.3931
+ 0.6559
* norm_leg_moves
* math.exp(
-1
* (
3.002 * norm_leg_moves * norm_leg_moves
- norm_leg_moves
- 0.034889 * ai_settings["kyu_rank"]
- 0.5097
)
** 2
)
- 0.01093 * ai_settings["kyu_rank"]
) * orig_calib_avemodrank
n_moves = int(
round(board_squares * norm_leg_moves / (1.31165 * (modified_calib_avemodrank + 1) - 0.082653))
)
if ai_mode in [AI_INFLUENCE, AI_TERRITORY, AI_LOCAL, AI_TENUKI]: if ai_mode in [AI_INFLUENCE, AI_TERRITORY, AI_LOCAL, AI_TENUKI]:
if cn.depth > ai_settings["endgame"] * board_squares: if cn.depth > ai_settings["endgame"] * board_squares:
+15 -7
View File
@@ -163,8 +163,10 @@ def averagemod(data):
(int(lendata * 0.8) + 1) - int(lendata * 0.2) (int(lendata * 0.8) + 1) - int(lendata * 0.2)
) # average without the best and worst 20% of ranks ) # average without the best and worst 20% of ranks
def gauss(data): def gauss(data):
return math.exp(-1*(data)**2) return math.exp(-1 * (data) ** 2)
class RankGraph(Graph): class RankGraph(Graph):
black_rank_points = ListProperty([]) black_rank_points = ListProperty([])
@@ -195,15 +197,21 @@ class RankGraph(Graph):
num_legal, rank, value = zip(*non_obvious_moves) num_legal, rank, value = zip(*non_obvious_moves)
rank = list(rank) rank = list(rank)
for (i, item) in enumerate(rank): for (i, item) in enumerate(rank):
if item > num_legal[i]*0.09: if item > num_legal[i] * 0.09:
rank[i] = num_legal[i]*0.09 rank[i] = num_legal[i] * 0.09
rank = tuple(rank) rank = tuple(rank)
averagemod_rank = averagemod(rank) averagemod_rank = averagemod(rank)
averagemod_len_legal = averagemod(num_legal) averagemod_len_legal = averagemod(num_legal)
norm_avemod_len_legal = (averagemod_len_legal/num_intersec) norm_avemod_len_legal = averagemod_len_legal / num_intersec
rank_kyu = -0.97222*math.log(averagemod_rank)/(0.24634+averagemod_rank*gauss(3.3208*(norm_avemod_len_legal)))+12.703*(norm_avemod_len_legal)+11.198*math.log(averagemod_rank)+12.28*gauss(2.379*(norm_avemod_len_legal))-16.544 rank_kyu = (
if rank_kyu<-5: -0.97222 * math.log(averagemod_rank) / (0.24634 + averagemod_rank * gauss(3.3208 * (norm_avemod_len_legal)))
rank_kyu=-5 + 12.703 * (norm_avemod_len_legal)
+ 11.198 * math.log(averagemod_rank)
+ 12.28 * gauss(2.379 * (norm_avemod_len_legal))
- 16.544
)
if rank_kyu < -4:
rank_kyu = -4
return 1 - rank_kyu # dan rank return 1 - rank_kyu # dan rank
@staticmethod @staticmethod