-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from Kinds-of-Intelligence-CFI/add-play
Add play function (and fix spelling errors with decoyGoal raycast parsing)
- Loading branch information
Showing
5 changed files
with
46 additions
and
3 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import random | ||
|
||
from pathlib import Path | ||
|
||
from animalai import AnimalAIEnvironment, arenas | ||
from animalai.executable import find_executable | ||
|
||
def play(configuration_file: str = None, env_path: str = None) -> None: | ||
""" | ||
Load a config file and play | ||
:param configuration_file: str path to a yaml configuration. Plays animalai.arenas.GoodGoal_Random.yml by default | ||
:param env_path: str path to AAI environment executable. Looks for it in root by default. | ||
:return: None | ||
""" | ||
|
||
print("Initializing AAI environment") | ||
environment = AnimalAIEnvironment( | ||
file_name=env_path if env_path is not None else str(find_executable(Path(""))), | ||
base_port=5005 + random.randint(0, 1000), | ||
arenas_configurations=configuration_file if configuration_file is not None else arenas.GOOD_GOAL_RANDOM_POS, | ||
play=True, | ||
) | ||
|
||
print("Press Q in the Unity window then Ctrl+C in the command line to close the environment effectively.") | ||
|
||
# Run the environment until signal is lost | ||
try: | ||
while environment._process: # type: ignore | ||
continue | ||
except KeyboardInterrupt: | ||
pass | ||
finally: | ||
environment.close() |
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
from animalai.play import play | ||
|
||
if __name__ == "__main__": | ||
play() |