void compute_all_status(Position *pos, int owner_map[BOARDSIZE], int score_count[], Status block_status[], Status point_status[]) // Compute status of of points and blocks (based on owner_map) // - the points : OWN_BY_BLACK, OWN_BY_WHITE or UNKNOWN // - the blocks : DEAD, ALIVE or UNKNOWN { Color c; int b; Status new_g_st, p_st; TreeNode *tree=new_tree_node(); // Launch a full depth MCTS search in order to compute owner_map double FASTPLAY20_THRES_sav = FASTPLAY20_THRES; double FASTPLAY5_THRES_sav = FASTPLAY5_THRES; memset(owner_map, 0, BOARDSIZE*sizeof(int)); nplayouts_real = 0; tree_search(pos, tree, 2*N_SIMS, owner_map, score_count, 0); FASTPLAY20_THRES = FASTPLAY20_THRES_sav; FASTPLAY5_THRES = FASTPLAY5_THRES_sav; sprintf(buf, "nsims: %d", nplayouts_real); log_fmt_s('I',buf,NULL); // Reset status of points and blocks FORALL_POINTS(pos, pt) point_status[pt] = UNKNOWN; for (b=1 ; b<MAX_BLOCKS ; b++) block_status[b] = UNKNOWN; // Try to evaluate block status FORALL_POINTS(pos, pt) { b = point_block(pos, pt); if (b != 0) { c = point_color(pos, pt); point_status[pt] = p_st = mcts_point_status(pt, owner_map); if (p_st == UNKNOWN) block_status[b] = UNKNOWN; else { new_g_st = UNKNOWN; if ((p_st == OWN_BY_WHITE && c==BLACK) || (p_st == OWN_BY_BLACK && c==WHITE)) new_g_st = DEAD; else if ((p_st == OWN_BY_BLACK && c==BLACK) || (p_st == OWN_BY_WHITE && c == WHITE)) new_g_st = ALIVE; if(block_status[b] == UNKNOWN) block_status[b] = new_g_st; else if (block_status[b] != new_g_st) block_status[b] = UNKNOWN; } } else point_status[pt] = mcts_point_status(pt, owner_map); }
// --------------------- Evaluation of the final Position --------------------- void final_status_list(Position *pos, Status block_status[MAX_BLOCKS], Status point_status[BOARDSIZE], char *str_st, Point points[BOARDSIZE]) // Compute the status of all points (evaluation from owner_map[]) { Block b; Status st; for (char *p=str_st ; *p != 0 ; p++) *p = tolower(*p); if (strcmp(str_st, "dead") == 0) st = DEAD; else if (strcmp(str_st, "alive") == 0) st = ALIVE; else st = UNKNOWN; slist_clear(points); FORALL_POINTS(pos, pt) { b = point_block(pos, pt); if (b != 0 && block_status[b] == st) slist_push(points, pt); }