Exemple #1
0
                    draw.reset()
                    ai_first = False
                    gameover = False
                    clearstatusbar()
                    continue
                elif pygame.Rect(menu1).collidepoint(point):
                    draw.reset()
                    ai_first = True
                    gameover = False
                    clearstatusbar()
                    remove_list = core.caculate(draw.getmap())
                    draw.remove(remove_list)
                else:
                    pos = draw.getpos(point)
                    if pos != (-1, -1):
                        if draw.isfree(pos):
                            draw.set(pos)
                        else:
                            draw.unset(pos)
            elif press_btn[2] == 1: # 右键移除棋子
                if draw.remove() == True: #有棋子移除
                    if core.gameover(draw.getmap()) == True:
                        gameover = True
                        setstatusbar('you win!')
                    else:
                        remove_list = core.caculate(draw.getmap())
                        draw.remove(remove_list)
                        if core.gameover(draw.getmap()) == True:
                            gameover = True
                            setstatusbar('ai win!')
Exemple #2
0
                clearstatusbar()
            elif pygame.Rect(menu1).collidepoint(point):
                draw.reset()
                clearstatusbar()
                ai_first = True
                gameover = False
                (x, y) = core.caculate(draw.getmap())
                draw.setai((x, y))
                draw.drawX((x, y), red, 4)

            else:

                if ai_first == False:  # player first
                    pos = draw.getpos(point)
                    #print "get (%d, %d)" %(pos[0], pos[1])
                    if draw.isfree(pos) == True and gameover == False:
                        draw.setplayer(pos)
                        draw.drawcircle(pos, green, -1, 4)
                        #print "setplayer"
                        if core.iswin(draw.getmap(), pos[0], pos[1]):
                            #print "player win!"
                            gameover = True
                            setstatusbar('Player Win')
                            continue
                        if draw.isover() == True:
                            gameover = True
                            #print "game over, draw game"
                            setstatusbar('Draw Game')
                            continue
                        (x, y) = core.caculate(draw.getmap())
                        #print "ai (%d, %d)" %(x, y)
Exemple #3
0
                    draw.reset()
                    ai_first = False
                    gameover = False
                    clearstatusbar()
                    continue
                elif pygame.Rect(menu1).collidepoint(point):
                    draw.reset()
                    ai_first = True
                    gameover = False
                    clearstatusbar()
                    remove_list = core.caculate(draw.getmap())
                    draw.remove(remove_list)
                else:
                    pos = draw.getpos(point)
                    if pos != (-1, -1):
                        if draw.isfree(pos):
                            draw.set(pos)
                        else:
                            draw.unset(pos)
            elif press_btn[2] == 1:  # 右键移除棋子
                if draw.remove() == True:  # 有棋子移除
                    if core.gameover(draw.getmap()) == True:
                        gameover = True
                        setstatusbar("you win!")
                    else:
                        remove_list = core.caculate(draw.getmap())
                        draw.remove(remove_list)
                        if core.gameover(draw.getmap()) == True:
                            gameover = True
                            setstatusbar("ai win!")
Exemple #4
0
                clearstatusbar()
            elif pygame.Rect(menu1).collidepoint(point):
                draw.reset()
                clearstatusbar()
                ai_first = True
                gameover = False
                (x, y) = core.caculate(draw.getmap())
                draw.setai((x, y))
                draw.drawX((x, y), red, 4)

            else:

                if ai_first == False:           # player first
                    pos = draw.getpos(point)
                    #print "get (%d, %d)" %(pos[0], pos[1])
                    if draw.isfree(pos) == True and gameover == False:
                        draw.setplayer(pos)
                        draw.drawcircle(pos, green, -1, 4)
                        #print "setplayer"
                        if core.iswin(draw.getmap(), pos[0], pos[1]):
                            #print "player win!"
                            gameover = True
                            setstatusbar('Player Win')
                            continue
                        if draw.isover() == True:
                            gameover = True
                            #print "game over, draw game"
                            setstatusbar('Draw Game')
                            continue
                        (x, y) = core.caculate(draw.getmap())
                        #print "ai (%d, %d)" %(x, y)