Skip to content

Commit

Permalink
test v1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
frankilepro committed Apr 24, 2020
1 parent dcd2eb7 commit e6c611c
Showing 1 changed file with 22 additions and 33 deletions.
55 changes: 22 additions & 33 deletions play.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,40 +2,29 @@
from blokus_gym.envs.blokus_env import BlokusEnv
import gym
import random
import pkg_resources

if __name__ == "__main__":
# version = pkg_resources.get_distribution("compare_with_remote").version
# split_version = version.split('.')
# try:
# split_version[-1] = str(int(split_version[-1]) + 1)
# except ValueError:
# # do something about the letters in the last field of version
# pass
# new_version = '.'.join(split_version)
new_version = float(pkg_resources.get_distribution("blokus_gym").version) + 0.01
print(f"{new_version:0.2f}")
# # env = BlokusEnv()
# env = gym.make("blokus_gym:blokus-hard-greedy-v0") # Make sure to do: pip install -e . in root
# print(f"number of possible moves {env.action_space}")
# for _ in range(100000):
# while True:
# # input()
# action = env.action_space.sample()
# # action = random.randint(0, 918)
# observation, reward, done, info = env.step(action)
# env.render("human")
# # print(env.ai.all_ids_to_move.keys())
# print(reward)
# env = BlokusEnv()
env = gym.make("blokus_gym:blokus-simple-v0") # Make sure to do: pip install -e . in root
print(f"number of possible moves {env.action_space}")
for _ in range(100000):
while True:
# input()
action = env.action_space.sample()
# action = random.randint(0, 918)
observation, reward, done, info = env.step(action)
env.render("human")
# print(env.ai.all_ids_to_move.keys())
print(reward)

# if done:
# # print(env.ai.all_ids_to_move.keys())
# # input()
# print(f"{'won' if reward == 2 else ('tie-won' if reward == 0 else 'lost')}")
# # print(env.ai.all_ids_to_move.keys())
# observation = env.reset()
# # input()
# break
if done:
# print(env.ai.all_ids_to_move.keys())
# input()
print(f"{'won' if reward == 2 else ('tie-won' if reward == 0 else 'lost')}")
# print(env.ai.all_ids_to_move.keys())
observation = env.reset()
# input()
break

# print(f"Starter won {env.starter_won / env.games_played * 100:.2f}%")
# env.close()
print(f"Starter won {env.starter_won / env.games_played * 100:.2f}%")
env.close()

0 comments on commit e6c611c

Please sign in to comment.