diff options
author | Bryan Bishop <kanzure@gmail.com> | 2013-11-02 14:00:04 -0500 |
---|---|---|
committer | Bryan Bishop <kanzure@gmail.com> | 2013-11-02 14:00:04 -0500 |
commit | 1f185185ca15389417474f6becfddde56e8e80eb (patch) | |
tree | 788232c57676da300e8a4999c4c455b59043dae8 | |
parent | 016d0b886444f864cf494c8d91f9de883ec9a57d (diff) |
autoplayer.bootstrap to call skip_intro
There are situations other than just testing where making a bootstrapped
game state is a useful ability.
-rw-r--r-- | pokemontools/vba/autoplayer.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/pokemontools/vba/autoplayer.py b/pokemontools/vba/autoplayer.py index 2d62433..a20744e 100644 --- a/pokemontools/vba/autoplayer.py +++ b/pokemontools/vba/autoplayer.py @@ -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. |