Esempio n. 1
0
def cpu_move():
    global board, decision, last, first, current, moving, cpucaptured
    if moving: return
    if first:
        first = False
        decision = ai.decide(board, cpu)
        cpucaptured = logic.captured(board, decision[1], decision[2][0])
        board.remove(cpucaptured)
        board.move(decision[1], decision[2][0][0])
        last = decision[2][0][0]
        grid.move(decision[1], decision[2][0][0])
        moving = True
    else:
        grid.remove(cpucaptured)
        chain = decision[2]
        del chain[0]
        if chain:
            cpucaptured = logic.captured(board, last, chain[0])
            board.remove(cpucaptured)
            board.move(last, chain[0][0])
            grid.move(last, chain[0][0])
            last = chain[0][0]
            moving = True
        else:
            first = True
            current = player
            board.children = ai.successors(board, player)
Esempio n. 2
0
def init():
    global rgroup, ggroup, clock, board, grid, current
    board = Board()
    board.children = ai.successors(board, current)
    grid = gfxgrid.Grid(board)
    rgroup = pygame.sprite.Group()
    ggroup = pygame.sprite.Group()
    clock = pygame.time.Clock()