BurnySc2 / python-sc2

A StarCraft II bot api client library for Python 3
MIT License
472 stars 156 forks source link

when run_game(Bot,Bot) face problem #178

Open histmeisah opened 10 months ago

histmeisah commented 10 months ago

When i test the game with Bot AI vs Bot AI.I find the two Bots played in two different game in the same map,and even could send messages to each other.

My systerm is win11 python version python3.10 s2clientprotocol 5.0.11.90870.0 burnysc2 6.4.0

Then ,when i check the replay,it shows replay didnt synchronous

BurnySc2 commented 10 months ago

Can you include a minimally failing example, or a bigger code snippet on how you are calling the functions? Also have you tried the GameMatch runner? https://github.com/BurnySc2/python-sc2/blob/76e4a435732d4359e5bd9e15b6283a0498e212ca/sc2/main.py#L40 An example can be found here: https://github.com/BurnySc2/python-sc2/blob/76e4a435732d4359e5bd9e15b6283a0498e212ca/examples/bot_vs_bot.py#L30-L44

histmeisah commented 10 months ago

ok,sir. And 2 bots play different games in the same map(maybe start 2 games),but can type words to each other my failure example is here:

def protoss_agent_vs_rule(transaction, lock, map_name, isReadyForNextStep, game_end_event, done_event, opposite_race, opposite_bot, replay_folder, process_id, args): map = map_name

if not os.path.exists(replay_folder):
    try:
        os.makedirs(replay_folder)
    except OSError:
        print(f"create dictionary {replay_folder} failure,please check and run program again.")
        return

result = run_game(maps.get(map),
                  [Bot(Race.Protoss, Protoss_Bot(transaction, lock, isReadyForNextStep)),
                   Bot(map_race(opposite_race), map_rule_bot(opposite_bot))],
                  realtime=True,
                  save_replay_as=f'{replay_folder}/{args.current_time}_{map}_Player_race_PROTOSS_VS_RULE_AI_{opposite_bot}_{opposite_race}_process_{process_id}.SC2Replay')

with lock:

    transaction['done'] = True
    transaction['result'] = result
done_event.set()  # Set done_event when the game is over
game_end_event.set()  # Set game_end_event when the game is over

this code runs well in bot vs build in ai,but bugs occurs in bot vs bot.