forked from sshegheva/smart-agent
/
solver.py
31 lines (26 loc) · 900 Bytes
/
solver.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
from Agent import Agent
from ProblemSet import ProblemSet
import logging
import problem_utils
logging.basicConfig()
LOGGER = logging.getLogger(__name__)
LOGGER.setLevel(logging.DEBUG)
agent = Agent()
n_correct = 0
n_total = len(ProblemSet("Basic Problems B").problems)
for p in ProblemSet("Basic Problems B").problems:
LOGGER.info('=================================')
LOGGER.info('Solving problem {}'.format(p.name))
if problem_utils.is_problem2x2(p):
source = p.figures['A']
destination = p.figures['B']
guess = agent.Solve(p)
answer = p.checkAnswer(guess)
if guess == answer:
LOGGER.info('{}++++++++++++Correct+++++++++++++'.format(p.name))
n_correct += 1
else:
LOGGER.error('Wrong')
else:
print 'Not 2x2 problem'
print('Total correct answers {} out of {}'.format(n_correct, n_total))