def test_place_piece(self): b = pentominoes.Board(8, 8) p = pentominoes.make_piece('f') b.place_piece(p, 0, 0) b.print_()
def test_equal(self): p = pentominoes.make_piece('f') q = p.moveto(10, 10) self.assertTrue(p == p) self.assertFalse(p == q)
def test_generate(self): b = pentominoes.Board() p = pentominoes.make_piece('i') for i in pentominoes.orientations(p): print '=' * 33 print i
def test_translation(self): p = pentominoes.make_piece('f') x = y = 0 p = p.moveto(x, y) while p._maxy < 8: while p._maxx < 8: print '[minx = %d, miny = %d, maxx = %d, maxy = %d]' % (p._minx, p._miny, p._maxx, p._maxy) x += 1 p = p.moveto(x, y) x = 0 y += 1 p = p.moveto(x, y)
def spin(size=5): ''' generate 3-space coordes for every orientation of a piece ''' ypiece = pentominoes.make_piece('y') for o in pentominoes.orientations(ypiece): for p in pentominoes.piece_placements(o, size, size): for plane in range(size): three_d = translate_to_plane(p, zplane=plane) yield three_d for plane in range(size): three_d = translate_to_plane(p, xplane=plane) yield three_d for plane in range(size): three_d = translate_to_plane(p, yplane=plane) yield three_d
def test_translate_to_plane(self): ypiece = pentominoes.make_piece('y') with self.assertRaises(ValueError): gaya.translate_to_plane(ypiece, xplane=0, yplane=0) for p in ypiece: print p print ypiece print gaya.translate_to_plane(ypiece, zplane=0) print gaya.translate_to_plane(ypiece, xplane=3) yp = gaya.translate_to_plane(ypiece, yplane=4) for p in yp: print p,gaya.xyz_to_cell(p) knob = gaya.find_outlier(yp) print knob,gaya.xyz_to_cell(knob)
def test_print(self): p = pentominoes.make_piece('f') p = p.moveto(0, 0) print p