Skip to content

Commit

Permalink
Merge pull request #46 from opendilab/playback-dev
Browse files Browse the repository at this point in the history
Playback dev
  • Loading branch information
mingzhang96 authored Aug 7, 2022
2 parents b682057 + a6d68ba commit c644046
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
8 changes: 5 additions & 3 deletions gobigger/bin/demo_bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@ def demo_bot():
env = GoBiggerEnv(dict(
team_num=4,
player_num_per_team=3,
frame_limit=60*20*10,
frame_limit=60*20*1,
playback_settings=dict(
save_video=True,
save_all=True,
save_partial=True,
),
))
obs = env.reset()
Expand All @@ -39,8 +41,8 @@ def demo_bot():
obs, reward, done, info = env.step(actions=actions)
t2 = time.time()
time_step_all += t2-t1
logging.debug('{} {:.4f} envstep {:.3f} / {:.3f}, (step: {:.3f} / {:.3f}, obs: {:.3f} / {:.3f}), leaderboard={}'\
.format(i, obs[0]['last_frame_count'], t2-t1, time_step_all/(i+1), *info, obs[0]['leaderboard']))
logging.debug('{} {:.4f} envstep {:.3f} / {:.3f}, leaderboard={}'\
.format(i, obs[0]['last_frame_count'], t2-t1, time_step_all/(i+1), obs[0]['leaderboard']))
if done:
logging.debug('Game Over')
break
Expand Down
3 changes: 2 additions & 1 deletion gobigger/render/env_render.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ def render_all_balls_colorful(self, screen, food_balls, thorns_balls, spore_ball
y = ball.position.y * self.scale_ratio_h + self.padding
r = ball.radius * self.scale_ratio_w
pygame.draw.circle(screen, PLAYER_COLORS[int(ball.team_id)][0], Vector2(x, y), r)
# pygame.draw.polygon(screen, PLAYER_COLORS[int(ball.team_id)][0], to_arrow(Vector2(x, y), r, ball.direction))
point_list = to_arrow(Vector2(x, y), r, ball.direction)
pygame.draw.polygon(screen, PLAYER_COLORS[int(ball.team_id)][0], point_list)
font_size = int(r/1.6)
font = pygame.font.SysFont('arial', max(font_size, 8), True)
txt = font.render('{}'.format(chr(int(ball.player_id%player_num_per_team)+65)), True, WHITE)
Expand Down

0 comments on commit c644046

Please sign in to comment.