From 9643610d0a12397242f7a8cdef8cebb9474eebb2 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 24 Jun 2024 10:45:59 +0100 Subject: [PATCH 1/6] Add play function --- animalai/play.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 animalai/play.py diff --git a/animalai/play.py b/animalai/play.py new file mode 100644 index 0000000..3e6895f --- /dev/null +++ b/animalai/play.py @@ -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), # use a random port to avoid problems if a previous version exits slowly + 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() \ No newline at end of file From 83a01f83e5e432b3b0bb180ee771fe6f633155cb Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 24 Jun 2024 10:51:00 +0100 Subject: [PATCH 2/6] Add test script --- test/play.py | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 test/play.py diff --git a/test/play.py b/test/play.py new file mode 100644 index 0000000..a942e74 --- /dev/null +++ b/test/play.py @@ -0,0 +1,4 @@ +from animalai.play import play + +if __name__ == "__main__": + play() \ No newline at end of file From c9fafffc37db8f9e04642ece7ec174b457a0c7a4 Mon Sep 17 00:00:00 2001 From: Ibrahim Alhas <65875290+alhasacademy96@users.noreply.github.com> Date: Mon, 24 Jun 2024 21:45:18 +0100 Subject: [PATCH 3/6] updated version to 4.1.0 and added changes to README. @kozzy97 can you take a look at the readme to make sure i've recapped the changes you made? --- README.md | 6 ++++++ pyproject.toml | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index e1a721b..81eeb94 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,12 @@ For more information about the ways you can contribute to Animal-AI, visit our w If you are new to contributing to open source, [this](https://github.com/Kinds-of-Intelligence-CFI/animal-ai/blob/main/CONTRIBUTING.md) guide helps explain why, what, and how to successfully get involved. ## Version History +* v4.1.0 + + Updated `RaycastParser` to accept new object: + - `HollowBox`. + - Added a new low-level random agent implemented on Braitenberg model. + - Bug fixes and performance improvements, specifically on improving the reliability of the Braitenberg model. + - Added built-in functionality to run yaml configuration files directly via Python. * v4.0.1 + Updated RaycastParser to accept two new objects: - `DecoyGoal` and `DecoyGoalBounce`. diff --git a/pyproject.toml b/pyproject.toml index 38a919d..ca8a27d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "animalai" -version = "4.0.1" +version = "4.1.0" description = "Animal AI Python API" license = "MIT" readme = "README.md" From 43680da331273af1a9567e1cc6ed1361934ac8d8 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 25 Jun 2024 13:47:08 +0100 Subject: [PATCH 4/6] Fix version log formatting --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 81eeb94..4330b52 100644 --- a/README.md +++ b/README.md @@ -22,9 +22,9 @@ If you are new to contributing to open source, [this](https://github.com/Kinds-o * v4.1.0 + Updated `RaycastParser` to accept new object: - `HollowBox`. - - Added a new low-level random agent implemented on Braitenberg model. - - Bug fixes and performance improvements, specifically on improving the reliability of the Braitenberg model. - - Added built-in functionality to run yaml configuration files directly via Python. + + Added a new low-level random agent implemented on Braitenberg model. + + Bug fixes and performance improvements, specifically on improving the reliability of the Braitenberg model. + + Added built-in functionality to run yaml configuration files directly via Python. * v4.0.1 + Updated RaycastParser to accept two new objects: - `DecoyGoal` and `DecoyGoalBounce`. From 470baea39055a2985bec090b592325a01e7fe5ea Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 25 Jun 2024 13:50:30 +0100 Subject: [PATCH 5/6] Remove unnecessary comment --- animalai/play.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/animalai/play.py b/animalai/play.py index 3e6895f..4febeb6 100644 --- a/animalai/play.py +++ b/animalai/play.py @@ -16,7 +16,7 @@ def play(configuration_file: str = None, env_path: str = None) -> 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), # use a random port to avoid problems if a previous version exits slowly + 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, ) From 55042c2bef6649790d3ef133bc70da2418f04e8b Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 25 Jun 2024 13:52:39 +0100 Subject: [PATCH 6/6] Fix spelling errors for decoygoal raycast parsing --- animalai/raycastparser.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/animalai/raycastparser.py b/animalai/raycastparser.py index 5dd27a6..020d02b 100644 --- a/animalai/raycastparser.py +++ b/animalai/raycastparser.py @@ -26,8 +26,8 @@ class RayCastObjects(enum.Enum): RAMP = 9 PILLARBUTTON = 10 SIGNPOSTER = 11 - DECAYGOAL = 12 - DECAYGOALBOUNCE = 13 + DECOYGOAL = 12 + DECOYGOALBOUNCE = 13 HOLLOWBOX = 14