This commit is contained in:
snsd0805 2024-04-23 02:04:28 +08:00
parent 5267fb4808
commit b396766976
Signed by: snsd0805
GPG Key ID: 569349933C77A854

View File

@ -235,7 +235,7 @@ def pacmanSuccessorAxiomSingle(x: int, y: int, time: int, walls_grid: List[List[
return None
"*** BEGIN YOUR CODE HERE ***"
util.raiseNotDefined()
return PropSymbolExpr(pacman_str, x, y, time=now) % logic.disjoin(possible_causes)
"*** END YOUR CODE HERE ***"
@ -306,7 +306,37 @@ def pacphysicsAxioms(t: int, all_coords: List[Tuple], non_outer_wall_coords: Lis
pacphysics_sentences = []
"*** BEGIN YOUR CODE HERE ***"
util.raiseNotDefined()
# condition 1:
# if a wall is at (x, y) --> pacman is not at (x, y)
pacphysics_sentences = [
PropSymbolExpr(wall_str, loc[0], loc[1]) >> ~logic.PropSymbolExpr(pacman_str, loc[0], loc[1], time=t) # time=t ?
for loc in all_coords
]
# condition 2:
# pacman is at exatly one of the squares at timestamp t.
condition2 = exactlyOne([ logic.PropSymbolExpr(pacman_str, loc[0], loc[1], time=t) for loc in non_outer_wall_coords ])
pacphysics_sentences.append(condition2)
# condition 3:
# pacman takes exactly one action at timestep t.
condition3 = exactlyOne([ logic.PropSymbolExpr(action, time=t) for action in DIRECTIONS])
pacphysics_sentences.append(condition3)
## condition 4
# results of calling sensorModel(...), unless None
if sensorModel:
pacphysics_sentences.append(sensorModel(t, non_outer_wall_coords))
# condition 5
# result of calling successorAxioms(...), describing how pacman can end in various locations on this time step. consider edge case. dont call if None
if successorAxioms and walls_grid and t>0:
pacphysics_sentences.append(successorAxioms(t, walls_grid, non_outer_wall_coords))
"*** END YOUR CODE HERE ***"
return conjoin(pacphysics_sentences)
@ -340,7 +370,17 @@ def checkLocationSatisfiability(x1_y1: Tuple[int, int], x0_y0: Tuple[int, int],
KB.append(conjoin(map_sent))
"*** BEGIN YOUR CODE HERE ***"
util.raiseNotDefined()
KB.append(pacphysicsAxioms(0, all_coords, non_outer_wall_coords, walls_grid, None, allLegalSuccessorAxioms))
KB.append(pacphysicsAxioms(1, all_coords, non_outer_wall_coords, walls_grid, None, allLegalSuccessorAxioms))
KB.append(PropSymbolExpr(pacman_str, x0, y0, time=0))
KB.append(PropSymbolExpr(action0, time=0))
KB.append(PropSymbolExpr(action1, time=1))
model1 = findModel( logic.conjoin(KB) & PropSymbolExpr(pacman_str, x1, y1, time=1) )
model2 = findModel( logic.conjoin(KB) & ~PropSymbolExpr(pacman_str, x1, y1, time=1) )
return (model1, model2)
"*** END YOUR CODE HERE ***"
#______________________________________________________________________________