Skip to content

Commit

Permalink
Merge pull request #10 from yaacov/main
Browse files Browse the repository at this point in the history
update readme
  • Loading branch information
yaacov committed Jan 10, 2024
2 parents 158bd94 + 73741db commit 9abdc15
Show file tree
Hide file tree
Showing 4 changed files with 100 additions and 134 deletions.
68 changes: 68 additions & 0 deletions README.md
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
```
134 changes: 0 additions & 134 deletions README.rst

This file was deleted.

Binary file added ai.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
32 changes: 32 additions & 0 deletions examples/driver.py
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

0 comments on commit 9abdc15

Please sign in to comment.