I'm currently writing an AI assignment for class, and each time I try to debug (using ipdb or pdb) pdb closes immediately. The program takes a map as input, and right now I'm just piping the text file in and grabbing the lines from stdin.
python value_iteration.py < l_track.txt
This works fine, but I think it's causing pdb.set_trace()
to close, is there a way to explicitly make sure that stdin is freed or something?
Current map grabbing code segment:
def map_input():
...
control_line = sys.stdin.readline().rstrip('\n')
height, width = control_line.split(",")
height = int(height)
width = int(width)
print "Map:"
while row < height:
for line in sys.stdin:
create MDP from states
...
return mdp
Then:
def value_iteration(mdp, epsilon):
....
for state in mdp.states.keys():
print mdp.actions[state]
ipdborpdb.set_trace()
utils_prime[state] = R(state) + gamma * max([
sum([
p * mdp.utilities[ns] for (p, ns) in T(state, a)
]) for a in mdp.actions[state]
])
if abs(utils_prime[state] - mdp.utilities[state]) > delta:
delta = abs(utils_prime[state] - mdp.utilities[state])
...
return mdp with utilities