opendilab/GoBigger

pygame.error: Text has zero width

wduo opened this issue · 5 comments

wduo commented

python3.6 -m gobigger.bin.play --player-num 1 --vision-type full
pygame 2.0.3 (SDL 2.0.16, Python 3.6.8)
Hello from the pygame community. https://www.pygame.org/contribute.html
DEBUG:root:{'team_num': 1, 'player_num_per_team': 1, 'map_width': 1000, 'map_height': 1000, 'match_time': 600, 'state_tick_per_second': 20, 'action_tick_per_second': 5, 'collision_detection_type': 'precision', 'save_video': False, 'save_quality': 'high', 'save_path': '', 'manager_settings': {'food_manager': {'num_init': 2000, 'num_min': 2000, 'num_max': 2500, 'refresh_time': 2, 'refresh_num': 30, 'ball_settings': {'radius_min': 2, 'radius_max': 2}}, 'thorns_manager': {'num_init': 15, 'num_min': 15, 'num_max': 20, 'refresh_time': 2, 'refresh_num': 2, 'ball_settings': {'radius_min': 12, 'radius_max': 20, 'vel_max': 100, 'eat_spore_vel_init': 10, 'eat_spore_vel_zero_time': 1}}, 'player_manager': {'ball_settings': {'acc_max': 100, 'vel_max': 25, 'radius_min': 3, 'radius_max': 300, 'radius_init': 3, 'part_num_max': 16, 'on_thorns_part_num': 10, 'on_thorns_part_radius_max': 20, 'split_radius_min': 10, 'eject_radius_min': 10, 'recombine_age': 20, 'split_vel_init': 30, 'split_vel_zero_time': 1, 'stop_zero_time': 1, 'size_decay_rate': 5e-05, 'given_acc_weight': 10}}, 'spore_manager': {'ball_settings': {'radius_min': 3, 'radius_max': 3, 'vel_init': 250, 'vel_zero_time': 0.3, 'spore_radius_init': 20}}}, 'custom_init': {'food': [], 'thorns': [], 'spore': [], 'clone': []}, 'obs_settings': {'with_spatial': True, 'with_speed': False, 'with_all_vision': False}}
Traceback (most recent call last):
File "/Users/wduo/miniconda3/envs/gobigger/lib/python3.6/runpy.py", line 193, in _run_module_as_main
"main", mod_spec)
File "/Users/wduo/miniconda3/envs/gobigger/lib/python3.6/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/Users/wduo/miniconda3/envs/gobigger/lib/python3.6/site-packages/gobigger/bin/play.py", line 305, in
play_control_by_keyboard()
File "/Users/wduo/miniconda3/envs/gobigger/lib/python3.6/site-packages/gobigger/bin/play.py", line 71, in play_control_by_keyboard
render.fill(server, direction=None, fps=fps_real, last_time=server.last_time)
File "/Users/wduo/miniconda3/envs/gobigger/lib/python3.6/site-packages/gobigger/render/realtime_render.py", line 33, in fill
player_num_per_team=1)
File "/Users/wduo/miniconda3/envs/gobigger/lib/python3.6/site-packages/gobigger/render/env_render.py", line 219, in render_all_balls_colorful
txt = font.render('{}'.format(chr(int(ball.owner)%player_num_per_team+65)), True, WHITE)
pygame.error: Text has zero width

wduo commented

env: macbookpro

conda create -n gobigger python=3.6.8
conda activate gobigger
conda install -c opendilab gobigger

在环境下,报上述错误。请帮忙解决下吧

wduo commented

Temporary solution:
Modify gobigger/render/env_render.py L218:

                font = pygame.font.SysFont('arial', max(font_size, 4), True)

to

                font = pygame.font.SysFont('arial', max(font_size, 10), True)

solved.

Thank you for opening this issue!

I am sorry but I can not reproduce this situation. Could you please give more details about it? Is there a game interface pop up? If it pops up, could you control the ball in the game? By the way, I don't think changing the font_size when calling pygame.font.SysFont() could help. Could you try to re-execute the start command with the original code?

We will also try to reproduce this situation. Hope you enjoy this game!

can reproduce this with latest pygame==2.0.3, downgrade to pygame==2.0.0 works fine.

can reproduce this with latest pygame==2.0.3, downgrade to pygame==2.0.0 works fine.

Oh, thanks for your reply. I reproduce the error with pygame==2.0.3 and 2.0.2. And pygame==2.0.0 & 2.0.1 works fine. Thanks @wduo , we enlarge the font_size when calling pygame.font.SysFont() to avoid the pygame.error as a temporary solution #13. And we create a new issue in pygame repo . We will continue to pay attention to the solution to this problem.