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

polish(yzj): polish render and add practice demo #56

Merged
merged 3 commits into from
Aug 30, 2023
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
14 changes: 7 additions & 7 deletions gobigger/render/realtime_render.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
txt_rect = txt.get_rect(center=(x, y))
self.screen.blit(txt, txt_rect)

def fill(self, food_balls, thorns_balls, spore_balls, players, player_num_per_team=1, fps=20):
def fill(self, food_balls, thorns_balls, spore_balls, players, player_num_per_team=1, fps=20, leaderboard=None):
self.screen.fill(BACKGROUND)
self.render_all_balls_colorful(food_balls, thorns_balls, spore_balls, players, player_num_per_team)
# add line
Expand All @@ -67,13 +67,13 @@
pygame.draw.line(self.screen, RED, (self.game_screen_width-self.padding, self.padding),
(self.game_screen_width-self.padding, self.game_screen_width-self.padding), width=1)
# for debug
# font = pygame.font.SysFont('Menlo', 15, True)
font = pygame.font.SysFont('Menlo', 15, True)

Check warning on line 70 in gobigger/render/realtime_render.py

View check run for this annotation

Codecov / codecov/patch

gobigger/render/realtime_render.py#L70

Added line #L70 was not covered by tests

# assert len(leaderboard) > 0, 'leaderboard could not be None'
# leaderboard = sorted(leaderboard.items(), key=lambda d: d[1], reverse=True)
# for index, (team_id, team_size) in enumerate(leaderboard):
# pos_txt = font.render('{}: {:.5f}'.format(team_id, team_size), 1, RED)
# self.screen.blit(pos_txt, (20, 10+10*(index*2+1)))
if leaderboard is not None:
leaderboard = sorted(leaderboard.items(), key=lambda d: d[1], reverse=True)
for index, (team_id, team_size) in enumerate(leaderboard):
pos_txt = font.render('{}: {:.5f}'.format(team_id, team_size), 1, RED)
self.screen.blit(pos_txt, (20, 10+10*(index*2+1)))

Check warning on line 76 in gobigger/render/realtime_render.py

View check run for this annotation

Codecov / codecov/patch

gobigger/render/realtime_render.py#L72-L76

Added lines #L72 - L76 were not covered by tests

# fps_txt = font.render('fps: ' + str(fps), 1, RED)
# last_frame_txt = font.render('frame_count: {} / {}'.format(frame_count, int(frame_count/20)), 1, RED)
Expand Down
26 changes: 26 additions & 0 deletions practice/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
## Practice
We offer multiple gameplay modes for players to enjoy, including development, battle (Bot and AI) and spectator mode. Our platform supports both single-player and two-player matches. Welcome to explore and enjoy the experience.

### Download Weight
```bash
wget https://opendilab.net/download/GoBigger/solo_agent.pth.tar
wget https://opendilab.net/download/GoBigger/cooperative_agent.pth.tar
```
### Quick Start

#### Installation
```bash
git clone https://github.com/opendilab/GoBigger.git
pip install -e .
```

#### Usage
```bash
python battle.py --mode single --map farm # Single-player development
python battle.py --mode single --map vsbot # Single-player vs. Bot
python battle.py --mode single --map vsai # Single-player vs. Single-AI
python battle.py --mode team --map farm # Two-player development
python battle.py --mode team --map vsbot # Two-player vs. Bot
python battle.py --mode team --map vsai # Two-player vs. Team-AI
python battle.py --mode watch # Spectator mode: Team-AI vs. Team-AI
```
Loading
Loading