Пример #1
0
    def test(self):
        twenty_forty_eight = TwentyFortyEight(6, 4)
        empty_grid = twenty_forty_eight.generate_empty_grid()
        twenty_forty_eight.grid = empty_grid
        twenty_forty_eight.new_tile()
        self.assertEquals(tiles_greater_zero(twenty_forty_eight._grid), 1)
        self.assertEquals(sum_of_tiles(twenty_forty_eight._grid) > 0, True)

        twenty_forty_eight = TwentyFortyEight()
        empty_grid = twenty_forty_eight.generate_empty_grid()
        twenty_forty_eight.grid = empty_grid
        twenty_forty_eight.new_tile()
        [twenty_forty_eight.new_tile() for dummy_num in range(9)]
        self.assertEquals(tiles_greater_zero(twenty_forty_eight._grid), 10)
        self.assertEquals(sum_of_tiles(twenty_forty_eight._grid) > 0, True)
Пример #2
0
from game_template import TwentyFortyEight

print "DOWN"
game = TwentyFortyEight(4, 3)
game.reset()
game.new_tile()
game.new_tile()
print game.__str__()
game.move(2)
print game.__str__()

print "UP"
game = TwentyFortyEight(4, 3)
game.reset()
game.new_tile()
game.new_tile()
print game.__str__()
print "\n"
game.move(1)
print game.__str__()

print "RIGHT"
game = TwentyFortyEight(4, 3)
game.reset()
game.new_tile()
game.new_tile()
print game.__str__()
print "\n"
game.move(4)
print game.__str__()