Created
August 3, 2016 19:24
-
-
Save llSourcell/743c82771c5aca4c915e5534014c97ea to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """ | |
| Once a model is learned, use this to play it. | |
| """ | |
| from flat_game import carmunk | |
| import numpy as np | |
| from nn import neural_net | |
| NUM_SENSORS = 3 | |
| def play(model): | |
| car_distance = 0 | |
| game_state = carmunk.GameState() | |
| # Do nothing to get initial. | |
| _, state = game_state.frame_step((2)) | |
| # Move. | |
| while True: | |
| car_distance += 1 | |
| # Choose action. | |
| action = (np.argmax(model.predict(state, batch_size=1))) | |
| # Take action. | |
| _, state = game_state.frame_step(action) | |
| # Tell us something. | |
| if car_distance % 1000 == 0: | |
| print("Current distance: %d frames." % car_distance) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment