示例#1
0
 def _clear(self):
     self.piece_bbs = {}
     for pc in piece.all():
         self.piece_bbs[pc] = 0L
     self.color_bbs = {}
     self.color_bbs[0] = 0L
     self.color_bbs[1] = 0L
     self.squares = {}
     for sq in square.all():
         self.squares[sq] = 0L
     self.castle = castle.parse('KQkq')
     self.enp = square.sq()
     self.halfmove_clock = 0
     self.move_num = 1
示例#2
0
 def _clear(self):
     self.piece_bbs = {}
     for pc in piece.all():
         self.piece_bbs[pc] = 0L
     self.color_bbs = {}
     self.color_bbs[0] = 0L
     self.color_bbs[1] = 0L
     self.squares = {}
     for sq in square.all():
         self.squares[sq] = 0L
     self.castle = castle.parse('KQkq')
     self.enp = square.sq()
     self.halfmove_clock = 0
     self.move_num = 1
示例#3
0
                        else:
                            self.num_promotions += 1

                    if movegen.king_attacked(self, self.color):
                        self.num_checks += 1
                        if self._game_over():
                            self.num_mates += 1
            self.unmake_move()
        return nodes


# NOTE(vish): insert constants into locals
for sq in square.all():
    locals()[square.str(sq)] = sq

for pc in piece.all():
    locals()[piece.str(pc)] = pc

#fen = 'r3k2r/p1ppqpb1/bn2pnp1/3PN3/1p2P3/2N2Q1p/PPPBBPPP/R3K2R w KQkq - 0 1'
fen = '8/2p5/3p4/KP5r/1R3p1k/8/4P1P1/8 w - - 0 1'
p1 = Position(fen)
print piece.str(p1.squares[square.sq('a8')])
import time
import prettytable
pt = prettytable.PrettyTable()
pt.field_names = [
    'Depth', 'Nodes', 'Captures', 'E.p.', 'Castles', 'Promotions', 'Checks',
    'Mates', 'Time'
]
pt.align = 'l'
#import cProfile
示例#4
0
                            self.num_castles += 1
                        else:
                            self.num_promotions += 1

                    if movegen.king_attacked(self, self.color):
                        self.num_checks += 1
                        if self._game_over():
                            self.num_mates += 1
            self.unmake_move()
        return nodes

# NOTE(vish): insert constants into locals
for sq in square.all():
    locals()[square.str(sq)] = sq

for pc in piece.all():
    locals()[piece.str(pc)] = pc

#fen = 'r3k2r/p1ppqpb1/bn2pnp1/3PN3/1p2P3/2N2Q1p/PPPBBPPP/R3K2R w KQkq - 0 1'
fen = '8/2p5/3p4/KP5r/1R3p1k/8/4P1P1/8 w - - 0 1'
p1 = Position(fen)
print piece.str(p1.squares[square.sq('a8')])
import time
import prettytable
pt = prettytable.PrettyTable()
pt.field_names = ['Depth', 'Nodes', 'Captures', 'E.p.', 'Castles',
                  'Promotions', 'Checks', 'Mates', 'Time']
pt.align = 'l'
#import cProfile
#cProfile.run('nodes = p1.perft(4)')
for i in xrange(1, 6):