Ejemplo n.º 1
0
    def init_layout(self):

        # Create the layout and fill it with pieces.
        self.layout = SquareGridLayout(highlight_color="^I")
        self.layout.resize(self.size)

        black_count = 0
        white_count = 0
        self.black.data.root_list = []
        self.white.data.root_list = []

        # There are three different layouts depending on the size.  All of them
        # alternate between black and white pieces; the two larger ones have 16
        # roots, whereas the smallest size has 4.  (There's a 5x5 grid for
        # testing as well.)
        if self.size == 5:
            jump_delta = 4
            extent = 2
            offset = 0
        elif self.size == 7:
            jump_delta = 6
            extent = 2
            offset = 0
        elif self.size == 9:
            jump_delta = 6
            extent = 2
            offset = 1
        elif self.size == 13:
            jump_delta = 4
            extent = 4
            offset = 0
        elif self.size == 19:
            jump_delta = 6
            extent = 4
            offset = 0
        else:  # size == 21
            jump_delta = 4
            extent = 6
            offset = 0
        for i in range(extent):
            for j in range(extent):
                if (i + j) % 2:
                    p = self.get_root_piece(self.black, black_count)
                    self.black.data.root_list.append(p)
                    black_count += 1
                else:
                    p = self.get_root_piece(self.white, white_count)
                    self.white.data.root_list.append(p)
                    white_count += 1
                row = offset + i * jump_delta
                col = offset + j * jump_delta
                p.data.start = (row, col)
                self.layout.place(p, row, col, update=False)
        self.layout.update()
Ejemplo n.º 2
0
    def init_layout(self):

        # Create the layout and fill it with pieces.
        self.layout = SquareGridLayout(highlight_color="^I")
        self.layout.resize(self.size)

        for i in range(self.size):
            for j in range(self.size):
                if (i + j) % 2:
                    self.layout.place(self.rp, i, j, update=False)
                else:
                    self.layout.place(self.bp, i, j, update=False)

        self.layout.update()
Ejemplo n.º 3
0
    def init_board(self):

        # Create the layout and the pieces it uses as well.  Note that we
        # can be ultra-lazy with the pieces, as Breakthrough doesn't distinguish
        # between them, so there's no reason to create a bunch of identical
        # bits.
        self.layout = SquareGridLayout()
        self.layout.resize(self.width, self.height)
        last_row = self.height - 1
        next_last_row = last_row - 1

        for i in range(self.width):
            self.layout.place(self.bp, 0, i, update=False)
            self.layout.place(self.bp, 1, i, update=False)
            self.layout.place(self.wp, next_last_row, i, update=False)
            self.layout.place(self.wp, last_row, i, update=False)

        # Set the piece counts.
        self.white.data.piece_count = self.width * 2
        self.black.data.piece_count = self.width * 2
        self.layout.update()
Ejemplo n.º 4
0
    def init_layout(self):

        # Create the layout.  Empty, so easy.
        self.layout = SquareGridLayout(highlight_color="^I")
        self.layout.resize(self.width, self.height)