In [1]:
from timeit import default_timer as timer
from tqdm import tqdm
import numpy as np
from env import Env2048
In [2]:
env = Env2048()
def experiment():
env.reset()
s = timer()
n = 1000
for t in range(n):
action = env.action_space.sample()
_, _, done, _ = env.step(action)
if done:
env.reset()
e = timer()
env.close()
return n / (e - s)
In [3]:
apss = []
for i in tqdm(range(20), unit="run"):
aps = experiment()
apss.append(aps)
print(f"Mean actions per second : {np.mean(apss)}")
In [ ]: