Skip to content

Commit

Permalink
polish(yzj): polish render and add practice demo (#56)
Browse files Browse the repository at this point in the history
* polish(yzj): polish render and add practice demo

* doc(hus):update download weight online link

* updaate cooperative agent path

---------

Co-authored-by: Norman <74552232+TuTuHuss@users.noreply.github.com>
  • Loading branch information
jayyoung0802 and TuTuHuss committed Aug 30, 2023
1 parent 71eb660 commit 630a703
Show file tree
Hide file tree
Showing 25 changed files with 4,042 additions and 7 deletions.
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 @@ def render_all_balls_colorful(self, food_balls, thorns_balls, spore_balls, playe
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 @@ def fill(self, food_balls, thorns_balls, spore_balls, players, player_num_per_te
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)

# 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)))

# 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

0 comments on commit 630a703

Please sign in to comment.