autoplayer.bootstrap to call skip_intro

There are situations other than just testing where making a bootstrapped
game state is a useful ability.
This commit is contained in:
Bryan Bishop
2013-11-02 14:00:04 -05:00
parent 016d0b8864
commit 1f185185ca

View File

@@ -551,6 +551,26 @@ class SpeedRunner(Runner):
self.cry.move("d")
self.cry.move("d")
def bootstrap(runner=None, cry=None):
"""
Setup the initial game and return the state. This skips the intro and
performs some other actions to get the game to a reasonable starting state.
"""
if not runner:
runner = SpeedRunner(cry=cry)
runner.setup()
# skip=False means always run the skip_intro function regardless of the
# presence of a saved after state.
runner.skip_intro(skip=True)
# keep a reference of the current state
state = runner.cry.vba.state
cry.vba.shutdown()
return state
def main():
"""
Setup a basic ``SpeedRunner`` instance and then run the runner.