-
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 #10 from yaacov/main
update readme
- Loading branch information
Showing
4 changed files
with
100 additions
and
134 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
# rose-game-ai | ||
[ROSE game](https://github.com/RedHat-Israel/ROSE) template for self driving AI module. | ||
|
||
This component is a template for building self driving modules for the ROSE game. | ||
|
||
See the [examples](/examples) directory for more information about creating your own | ||
driving module. | ||
|
||
<p align="center"> | ||
<img src="ai.png" alt="rose game components diagram" width="400"/> | ||
</p> | ||
|
||
ROSE project: https://github.com/RedHat-Israel/ROSE | ||
|
||
## Requirements | ||
|
||
Requires | Version | | | ||
----------|---------| ---- | | ||
Podman (or Docker) | >= 4.8 | For running containerized | | ||
Python | >= 3.9 | For running the code loally | | ||
|
||
## ROSE game components | ||
|
||
Component | Reference | | ||
----------|-----------| | ||
Game engine | https://github.com/RedHat-Israel/rose-game-engine | | ||
Game web based user interface | https://github.com/RedHat-Israel/rose-game-web-ui | | ||
Game car driving module | https://github.com/RedHat-Israel/rose-game-ai | | ||
|
||
## Running a self driving module | ||
|
||
Clone this repository, and make sure you have a game engine running. | ||
|
||
Write your own driving module, you can use the file `mydriver.py`: | ||
|
||
```bash | ||
vi mydriver.py | ||
``` | ||
|
||
Run using `mydriver.py` as the driving module: | ||
|
||
```bash | ||
make run | ||
``` | ||
|
||
## Running ROSE game components containerized | ||
|
||
### Running the game engine ( on http://127.0.0.1:8880 ) | ||
|
||
``` bash | ||
podman run --rm --network host -it quay.io/rose/rose-game-engine:latest | ||
``` | ||
|
||
### Running the game web based user interface ( on http://127.0.0.1:8080 ) | ||
|
||
``` bash | ||
podman run --rm --network host -it quay.io/rose/rose-game-web-ui:latest | ||
``` | ||
|
||
### Running your self driving module, requires a local `driver.py` file with your driving module. ( on http://127.0.0.1:8081 ) | ||
|
||
``` bash | ||
# NOTE: will mount mydriver.py from local directory into the container file system | ||
podman run --rm --network host -it \ | ||
-v $(pwd)/mydriver.py:/mydriver.py:z \ | ||
-e DRIVER /mydriver.py \ | ||
quay.io/rose/rose-game-ai:latest | ||
``` |
This file was deleted.
Oops, something went wrong.
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,32 @@ | ||
""" | ||
This driver does not do any action. | ||
""" | ||
from rose.common import obstacles, actions # NOQA | ||
|
||
driver_name = "Driver" | ||
|
||
|
||
def drive(world): | ||
""" | ||
This method controls the car's movement based on the obstacle it encounters. | ||
Parameters: | ||
world (World): The game world object containing the car and obstacles. | ||
Returns: | ||
Action: An action to perform based on the obstacle encountered. | ||
""" | ||
x = world.car.x | ||
y = world.car.y | ||
obstacle = world.get((x, y - 1)) | ||
|
||
if obstacle == obstacles.PENGUIN: | ||
return actions.PICKUP | ||
elif obstacle == obstacles.WATER: | ||
return actions.BRAKE | ||
elif obstacle == obstacles.CRACK: | ||
return actions.JUMP | ||
elif obstacle == obstacles.NONE: | ||
return actions.NONE | ||
else: | ||
return actions.RIGHT if (x % 3) == 0 else actions.LEFT |