def do_placement(pos, i, mtm, pos_score, m_bb, o_bb): n_pos = bb.pos_place_i(pos, i, mtm) if n_pos not in scores: n_m_bb = bb.pos_to_m_bb(n_pos) n_o_bb = bb.pos_to_o_bb(n_pos) pre_prow_score = bb.score_prow_i(m_bb, o_bb, i) - bb.score_prow_i( o_bb, m_bb, i) post_prow_score = bb.score_prow_i(n_m_bb, n_o_bb, i) - bb.score_prow_i( n_o_bb, n_m_bb, i) scores[n_pos] = pos_score - pre_prow_score + post_prow_score return n_pos
def make_children(pos, mtm): children = [] c_bb = bitboard.pos_to_c_bb(pos) for i in range(64): if not bitboard.get_i(c_bb, i): new_pos = bitboard.pos_place_i(pos, i, mtm) score = get_move_score(new_pos, i, mtm) if mtm and score > 5000: # if this move will make me win return [new_pos] elif not mtm and score < -5000: return [new_pos] else: children.append(new_pos) children.sort(key=lambda c: get_score(c), reverse=mtm) return children
def get_move_score(pos, i, mtm): new_pos = bitboard.pos_place_i(pos, i, mtm) if new_pos not in m_scores: get_score(pos) score_move(pos, i, mtm) return m_scores[new_pos] - o_scores[new_pos]