|
|
|
|
|
import gym |
|
from gym.envs.toy_text.frozen_lake import generate_random_map |
|
import random |
|
import os |
|
import numpy as np |
|
|
|
|
|
levels = [3,4,5,6,7,8] |
|
for level in levels: |
|
count = 0 |
|
correct = 0 |
|
invalid = 0 |
|
|
|
yes_c = 0 |
|
yes_w = 0 |
|
|
|
gt_answer_dir = "maps/level%d/answer/"%(level) |
|
check_answer_dir = "output/output_pure_text/level%d/"%(level) |
|
|
|
|
|
for test_id in range(100): |
|
try: |
|
|
|
output_path = check_answer_dir + "%d.txt"%(test_id) |
|
with open(output_path, "r") as f: |
|
contents = f.read() |
|
answer_index = contents.find("<Output>") |
|
answer = contents[answer_index+len("<Output>"):] |
|
|
|
|
|
|
|
answer = answer.replace('"', '') |
|
answer = answer.replace("'", '') |
|
answer = answer.replace("\n", '') |
|
answer = answer.replace(".", '') |
|
answer = answer.replace("(", '') |
|
answer = answer.replace(")", '') |
|
answer = answer.lstrip() |
|
answer = answer.rstrip() |
|
answer = answer.lower() |
|
|
|
assert answer in ['yes', 'no'] |
|
|
|
|
|
gt_path = gt_answer_dir + "%d.txt"%(test_id) |
|
with open(gt_path, "r") as f: |
|
gt = f.read() |
|
key_dict = {'Y': 'yes', 'N': 'no'} |
|
gt = key_dict[gt] |
|
if answer == gt: |
|
correct += 1 |
|
if answer == 'yes': |
|
yes_c += 1 |
|
else: |
|
if answer == 'yes': |
|
yes_w += 1 |
|
count += 1 |
|
|
|
except: |
|
|
|
invalid += 1 |
|
count += 1 |
|
pass |
|
|
|
|
|
|
|
print("=====Curr Level: %d======"%(level)) |
|
print("Total tested: %d"%(count)) |
|
print("Total correct: %d"%(correct)) |
|
print("Total invalid: %d"%(invalid)) |
|
|