Skip to content

Multiprocess Autorun#4

Open
alexlamgit wants to merge 1 commit intodmeger:mainfrom
alexlamgit:autorun
Open

Multiprocess Autorun#4
alexlamgit wants to merge 1 commit intodmeger:mainfrom
alexlamgit:autorun

Conversation

@alexlamgit
Copy link

Add parallel processing support for autoplay testing

This does not affect functionality. It is purely QoL, but I think everyone will appreciate it. (10x faster on my macbook pro!)

Changes

  • Added multiprocessing to run autoplay games in parallel
  • Added --num_cores argument (defaults to using all CPU cores)

Usage

# Use all cores
python simulator.py --autoplay --autoplay_runs 100

# Specify core count
python simulator.py --autoplay --autoplay_runs 100 --num_cores 4

@@ -146,11 +227,13 @@ def autoplay(self):
+ ".csv"
)
with open(fname, "w") as fo:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I recommend adding tournament_results/ dir creation here, so that people don't need to do it manually. E.g. importing from pathlib import Path and then something like:

fname = Path("tournament_results") / f"{self.world.player_1_name}_vs_{self.world.player_2_name}_at_{datetime.datetime.now().strftime('%Y-%m-%d-%H-%M-%S')}.csv"
fname.parent.mkdir(exist_ok=True)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants