def test_gen_steps_frozen(self):
        camel_loc = (1<<32)
        dog_loc = (1<<33)
        bbds = bb.empty_bboards()
        bbds['m'] = bbds['w'] = camel_loc
        bbds['d'] = bbds['b'] = dog_loc

        self.assertFalse(bb._free_pieces('b', bbds))
        self.assertTrue(camel_loc & bb._free_pieces('w', bbds))

        self.assertEquals(bb._allowed_steps('b', bbds),
                          dict((ch, 0) for ch in 'NSEW'))
        self.assertEquals(bb._allowed_steps('w', bbds),
                          dict(N=camel_loc, S=camel_loc, E=0, W=0))
 def test_gen_steps_rabbits(self):
     from random import randrange
     for color, dir in ('wS', 'bN'):
         bbds = bb.empty_bboards()
         for _ in range(10):
             rabbit_loc = (1<<randrange(64))
             bbds['r'] |= rabbit_loc
             bbds[color] |= rabbit_loc
         r_steps = bb._allowed_steps(color, bbds)
         self.assertFalse(r_steps[dir])
 def test_gen_simple_steps_middle(self):
     for j in range(1, 7):
         for i in range(1, 7):
             loc = (1<<((8*j)+i))
             dirs = 'NSEW'
             bbds = bb.empty_bboards()
             bbds['e'] = bbds['b'] = loc
             self.assertTrue(loc & bb._free_pieces('b', bbds))
             dir_to_psns = dict((ch, loc) for ch in dirs)
             self.assertEquals(dir_to_psns, bb._allowed_steps('b', bbds))
 def test_gen_simple_steps_corner(self):
     # all the corner positions.
     locs = (1<<56, 1<<63, 1<<7, 1)
     # the free directions from each corner.
     dirs = ('SE', 'SW', 'NW', 'NE')
     for loc, dd in zip(locs, dirs):
         bbds = bb.empty_bboards()
         bbds['e'] = bbds['b'] = loc
         self.assertTrue(loc & bb._free_pieces('b', bbds))
         dir_to_psns = dict((ch, 0) for ch in 'NSEW')
         for d in dd:
             dir_to_psns[d] = loc
         self.assertEquals(dir_to_psns, bb._allowed_steps('b', bbds))