feat: q4
This commit is contained in:
parent
b396766976
commit
a5c3673356
19
logicPlan.py
19
logicPlan.py
@ -407,7 +407,24 @@ def positionLogicPlan(problem) -> List:
|
||||
KB = []
|
||||
|
||||
"*** BEGIN YOUR CODE HERE ***"
|
||||
util.raiseNotDefined()
|
||||
KB.append(PropSymbolExpr(pacman_str, x0, y0, time=0))
|
||||
for step in range(50):
|
||||
print(f"step={step}")
|
||||
|
||||
# KB: Pacman can only be at exactlyOne of the locations in non_wall_coords at timestep t (from docs)
|
||||
KB.append(exactlyOne([ PropSymbolExpr(pacman_str, loc[0], loc[1], time=step) for loc in non_wall_coords ]))
|
||||
|
||||
# goal
|
||||
model = findModel( logic.conjoin(KB) & PropSymbolExpr(pacman_str, xg, yg, time=step) )
|
||||
if model:
|
||||
return extractActionSequence(model, actions)
|
||||
|
||||
# KB: Pacman takes exactly one action per timestep.
|
||||
KB.append(exactlyOne([ PropSymbolExpr(action, time=step) for action in actions ]))
|
||||
|
||||
# KB: Transition Model sentences: call pacmanSuccessorAxiomSingle(...) for all possible pacman positions in non_wall_coords
|
||||
KB += [ pacmanSuccessorAxiomSingle(loc[0], loc[1], step+1, walls_grid) for loc in non_wall_coords ]
|
||||
|
||||
"*** END YOUR CODE HERE ***"
|
||||
|
||||
#______________________________________________________________________________
|
||||
|
||||
Loading…
Reference in New Issue
Block a user