Skip to content
This repository has been archived by the owner on Jun 28, 2022. It is now read-only.

Add ability to replay tournament using seed #29

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion tournament.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,17 @@ def play_matches(cpu_agents, test_agents, num_matches):


def main():
parser = argparse.ArgumentParser()

# Use parsed --seed argument for random number generation
# If no seed is given as an argument, create a new one by default
parser.add_argument('--seed', type=float, dest='seed', nargs='?', const=1, default=random.random())

parsed_args = parser.parse_args()

# Seed PRNG
random_seed = parsed_args.seed
random.seed(random_seed)

# Define two agents to compare -- these agents will play from the same
# starting position against the same adversaries in the tournament
Expand All @@ -150,10 +161,12 @@ def main():

print(DESCRIPTION)
print("{:^74}".format("*************************"))
print("{:^74}".format("Playing Matches"))
print("{:^74}".format("Playing Matches with random seed "+str(random_seed)))
print("{:^74}".format("*************************"))
play_matches(cpu_agents, test_agents, NUM_MATCHES)


if __name__ == "__main__":
# Only import argument parser if this file is being run directly
import argparse
main()