def test_player(): game_mock = Mock() game_mock.read_grid = Mock(return_value = GRID) game_mock.read_score = Mock(return_value = SCORE) solver_mock = Mock() solver_mock.solve = Mock(return_value = [Keys.UP]) player = Player(game_mock, solver_mock) player.play() game_mock.finish.assert_called_with()
#!/usr/bin/env python from argparse import ArgumentParser from lib2048.solve.heuristic_solver import HeuristicSolver from lib2048.game.browser import Browser from lib2048.play.player import Player if __name__ == '__main__': parser = ArgumentParser(description='Tired of playing 2048? Let your computer do it for you!') parser.add_argument('-b', '--browser', dest='browser', type=str, help='Browser to use for the simulation.', default='phantomjs') args = parser.parse_args() player = Player(Browser(args.browser), HeuristicSolver()) player.play()