コード例 #1
0
    def test_bb_to_from_ch_state(self):
        # corner case: empty board.
        ch_state = ' ' * 64
        psns = bb.bboards_from_char_state(ch_state)
        self.assertEquals(psns, dict((ch, 0) for ch in 'wbemhdcr'))
        self.assertEquals(ch_state, bb.char_state_from_bboards(psns))

        # test all piece types.
        ch_state = [' '] * 64
        pieces = 'rcdhmeRCDHME'
        for idx, p in enumerate(pieces, 10):
            ch_state[idx] = p
        psns = bb.bboards_from_char_state(ch_state)
        self.assertEquals(''.join(ch_state), bb.char_state_from_bboards(psns))
コード例 #2
0
def play_archive_game(allmoves):
    '''
    allmoves is a list starting with 1w, 1b (the game setup moves), followed by
    2w, 2b and following (the move playouts).

    '''

    if len(allmoves) < 2:
        return bitboards.bboards_from_char_state(EMPTY_BOARD)
    wmove1, bmove1 = allmoves[:2]
    board = game_setup_from_move_1(wmove1, bmove1)
    bbs = bitboards.bboards_from_char_state(board)
    for move in allmoves[2:]:
        label, steps = move[0], move[1:]
        for step in steps:
            bitboards.apply_step(step, bbs)
    return bbs
コード例 #3
0
 def setUp(self):
     ch_state = [' '] * 64
     ch_state[0] = 'e'
     self.ch_state = ch_state
     self.bbds = bb.bboards_from_char_state(ch_state)