Esempio n. 1
0
    def getFreeStones(self):
        """return the list of the stones which can move ordered"""
        stones1 = []
        stones2 = []
        x = y = 0
        while x < self.board.cols:
            while y < self.board.rows:
                if self.board.stoneExists(x, y):
                    stone = Stone(self.board, x, y)
                    if (stone.color == self.color
                            or stone.color == utils.getSelectedColor(
                                self.color)) and stone.canMove():
                        if stone.canBeCaptured() or x == 0 or (
                                y + 1) == self.board.rows or y == 0 or (
                                    y + 1) == self.board.cols:
                            stones1.append((x, y))
                        else:
                            stones2.append((x, y))
                y += 1
            x += 1
            y = 0

        stones1 = utils.random_list(stones1)
        for a in stones2:
            stones1.append(a)

        return stones1
Esempio n. 2
0
    def __init__(self, board, x, y):
        self.x = self.y = self.color = -1
        if board.stoneExists(x, y):
            self.x = x
            self.y = y
            self.color = board.getStoneColor(x, y)
            self.selected_color = utils.getSelectedColor(self.color)
            self.board = board
            self.history = {}

            self.historix = zeros((self.board.cols, self.board.rows))

        else:
            print "Initialization failed"
Esempio n. 3
0
    def __init__(self, board , x , y) :
        self.x = self.y = self.color = -1
        if board.stoneExists(x,y) :
            self.x = x
            self.y = y
            self.color = board.getStoneColor(x,y)
            self.selected_color = utils.getSelectedColor(self.color)
            self.board = board
            self.history = {}

            self.historix = zeros( (self.board.cols , self.board.rows ) )

        else:
            print "Initialization failed"
Esempio n. 4
0
    def getFreeStones(self):
        """return the list of the stones which can move ordered"""
        stones1 = []
        stones2 = []
        x = y = 0
        while x < self.board.cols :
            while y < self.board.rows :
                if self.board.stoneExists(x,y) :
                    stone = Stone(self.board , x,y)
                    if (stone.color == self.color or stone.color == utils.getSelectedColor(self.color) ) and stone.canMove() :
                        if stone.canBeCaptured() or x == 0 or (y + 1) == self.board.rows or y == 0 or (y + 1 ) == self.board.cols :
                            stones1.append((x,y))
                        else:
                            stones2.append((x,y) )
                y+=1
            x+=1
            y=0

        stones1 = utils.random_list(stones1)
        for a in stones2:
            stones1.append(a)

        return stones1