Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor adhoc modifications #34

Merged
merged 2 commits into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Run pytest
name: Tests

on:
push:
Expand Down Expand Up @@ -26,6 +26,6 @@ jobs:
python -m pip install --upgrade pip
pip install -r requirements.txt # Assuming you have a requirements.txt file

- name: Run pytest
- name: Run Pytest
run: |
pytest
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

[![CodeFactor](https://www.codefactor.io/repository/github/strakam/generals-rl/badge)](https://www.codefactor.io/repository/github/strakam/generals-rl)
[![CodeQL](https://github.com/strakam/Generals-RL/actions/workflows/codeql.yml/badge.svg)](https://github.com/strakam/Generals-RL/actions/workflows/codeql.yml)
[![CI](https://github.com/strakam/Generals-RL/actions/workflows/tests.yml/badge.svg)](https://github.com/strakam/Generals-RL/actions/workflows/tests.yml)




Expand Down Expand Up @@ -65,7 +67,7 @@ game_config = GameConfig(
)

# Create environment
env = pz_generals(game_config, render_mode="human") # render_mode {"none", "human"}
env = pz_generals(game_config, render_mode="human") # render_modes are ["none", "human"]
observations, info = env.reset()

# How fast we want rendering to be
Expand Down Expand Up @@ -95,11 +97,12 @@ game_config = GameConfig(
mountain_density=0.2,
city_density=0.05,
general_positions=[(2, 12), (8, 9)],
agent_names=[agent.name]
agent_names=[agent.name],
gymnasium_npc="expander" # available options as of now: ["expander", "random"]
)

# Create environment
env = gym_generals(game_config, render_mode="human") # render_mode {"none", "human"}
env = gym_generals(game_config, render_mode="human") # render_modes are ["none", "human"]
observation, info = env.reset()

# How fast we want rendering to be
Expand Down
4 changes: 2 additions & 2 deletions TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
- [x] Random agent new parameters

### Improvements
- [ ] Let user change game speed even when the game is paused; make 'Paused' text separate in the side panel.
- [x] Let user change game speed even when the game is paused; make 'Paused' text separate in the side panel.
- [x] Revisit types for observation space (np.float32 vs np.bool)
- [x] Make ExpanderAgent a bit more readable if possible
- [x] Test IDLE actions
Expand All @@ -18,4 +18,4 @@
- [ ] Create more examples of usage (Stable Baselines3 demo)
- [x] Pre-commit hooks for conventional commit checks (enforcing conventional commits)
- [x] Add CI for running tests (pre commit)
- [ ] Add CI passing badge to README
- [x] Add CI passing badge to README
4 changes: 2 additions & 2 deletions generals/rendering.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,10 @@ def handle_events(self):
# Control game speed, pause, and replay frames if the game is from a replay
if event.type == pygame.KEYDOWN and self.from_replay:
# Speed up game right arrow is pressed
if event.key == pygame.K_RIGHT and not self.paused:
if event.key == pygame.K_RIGHT:
self.game_speed = max(1 / 128, self.game_speed / 2)
# Slow down game left arrow is pressed
if event.key == pygame.K_LEFT and not self.paused:
if event.key == pygame.K_LEFT:
self.game_speed = min(32, self.game_speed * 2)
# Toggle play/pause
if event.key == pygame.K_SPACE:
Expand Down
Loading