Python Question

Description

Having Trouble Meeting Your Deadline?

Get your assignment on Python Question  completed on time. avoid delay and – ORDER NOW

1. For this project you need python 3.6 and the pycosat module, which is a Python wrapper around the picoSAT librar (Links to an external site.).

2. you will only edit logicPlan.py only and run auto-grader file to check if the implementation is correct

3. This project consists of 8 questions and i only need answer for questions 6 and 7, where is the actual questions

Helper Functions for the rest of the Project

For the remaining questions, we will rely on the following helper functions, which will be referenced by the pseudocode for localization, mapping, and SLAM.

Add pacphysics, action, and percept information to KB

  • Add to KB: pacphysics_axioms(...), which you wrote in q3. Use sensorAxioms and allLegalSuccessorAxioms for localization and mapping, and SLAMSensorAxioms and SLAMSuccessorAxioms for SLAM only.
  • Add to KB: Pacman takes action prescribed by agent.actions[t]
  • Get the percepts by calling agent.getPercepts() and pass the percepts to fourBitPerceptRules(...) for localization and mapping, or numAdjWallsPerceptRules(...) for SLAM. Add the resulting percept_rules to KB.

Find possible pacman locations with updated KB

  • possible_locations = []
  • Iterate over non_outer_wall_coords.
    • Can we prove whether Pacman is at (x, y)? Can we prove whether Pacman is not at (x, y)? Use entails and the KB.
    • If there exists a satisfying assignment where Pacman is at (x, y) at time t, add (x, y) to possible_locations.
    • Add to KB: (x, y) locations where Pacman is provably at, at time t.
    • Add to KB: (x, y) locations where Pacman is provably not at, at time t.
    • Hint: check if the results of entails contradict each other (i.e. KB entails A and entails ¬ A). If they do, print feedback to help debugging.

Find provable wall locations with updated KB

  • Iterate over non_outer_wall_coords.
    • Can we prove whether a wall is at (x, y)? Can we prove whether a wall is not at (x, y)? Use entails and the KB.
    • Add to KB and update known_map: (x, y) locations where there is provably a wall.
    • Add to KB and update known_map: (x, y) locations where there is provably not a wall.
    • Hint: check if the results of entails contradict each other (i.e. KB entails A and entails ¬ A). If they do, print feedback to help debugging.

Observation: we add known Pacman locations and walls to KB so that we don’t have to redo the work of finding this on later timesteps; this is technically redundant information since we proved it using the KB in the first place.


Question 6 (5 points): Localization

Pacman starts with a known map, but unknown starting location. It has a 4-bit sensor that returns whether there is a wall in its NSEW directions. (For example, 1001 means there is a wall to pacman’s North and West directions, and these 4-bits are represented using a list with 4 booleans.) By keeping track of these sensor readings and the action it took at each timestep, Pacman is able to pinpoint its location. You will code up the sentences that help Pacman determine the possible locations it can be at each timestep by implementing:

  • localization(problem, agent): Given an instance of logicPlan.LocalizationProblem and an instance of logicAgents.LocalizationLogicAgent, repeatedly yields for timesteps t between 0 and agent.num_steps-1 a list of possible locations (x_i, y_i) at t: [(x_0_0, y_0_0), (x_1_0, y_1_0), …]. Note that you don’t need to worry about how generators work as that line is already written for you.

For Pacman to make use of sensor information during localization, you will use two methods already implemented for you: sensorAxioms — i.e. Blocked[Direction]_t ? [(P[x_i, y_j]_t ? WALL[x_i+dx, y_j+dy]) ? (P[x_i’, y_j’]_t ? WALL[x_i’+dx, y_j’+dy]) … ] — and fourBitPerceptRules, which translate the percepts at time t into logic sentences.

Please implement the function according to our pseudocode:

  • Add to KB: where the walls are (walls_list) and aren’t (not in walls_list).
  • for t in range(agent.num_timesteps):
    • Add pacphysics, action, and percept information to KB.
    • Find possible pacman locations with updated KB.
    • Call agent.moveToNextState(action_t) on the current agent action at timestep t.
    • yield the possible locations.

Note on display: the yellow Pacman is where he is at the time that’s currently being calculated, so possible locations and known walls and free spaces are from the previous timestep.

To test and debug your code run:

python autograder.py -q q6

Question 7 (4 points): Mapping

Pacman now knows his starting location, but does not know where the walls are (other than the fact that the border of outer coordinates are walls). Similar to localization, it has a 4-bit sensor that returns whether there is a wall in its NSEW directions. You will code up the sentences that help Pacman determine the location of the walls by implementing:

  • mapping(problem, agent): Given an instance of logicPlan.MappingProblem and an instance of logicAgents.MappingLogicAgent, repeatedly yields for timesteps t between 0 and agent.num_steps-1 knowledge about the map [[1, 1, 1, 1], [1, -1, 0, 0], … ] at t. Note that you don’t need to worry about how generators work as that line is already written for you.
  • known_map:
    • known_map is a 2D-array (list of lists) of size (problem.getWidth()+2, problem.getHeight()+2), because we have walls around the problem.
    • Each entry of known_map is 1 if (x, y) is guaranteed to be a wall at timestep t, 0 if (x, y) is guaranteed to not be a wall, and -1 if (x, y) is still ambiguous at timestep t.
    • Ambiguity results when one cannot prove that (x, y) is a wall and one cannot prove that (x, y) is not a wall.

Please implement the function according to our pseudocode:

  • Get initial location (pac_x_0, pac_y_0) of Pacman, and add this to KB. Also add whether there is a wall at that location.
  • for t in range(agent.num_timesteps):
    • Add pacphysics, action, and percept information to KB.
    • Find provable wall locations with updated KB.
    • Call agent.moveToNextState(action_t) on the current agent action at timestep t.
    • yield known_map

To test and debug your code run:

python autograder.py -q q7

Explanation & Answer

Our website has a team of professional writers who can help you write any of your homework. They will write your papers from scratch. We also have a team of editors just to make sure all papers are of HIGH QUALITY & PLAGIARISM FREE. To make an Order you only need to click Order Now and we will direct you to our Order Page at Litessays. Then fill Our Order Form with all your assignment instructions. Select your deadline and pay for your paper. You will get it few hours before your set deadline.

Fill in all the assignment paper details that are required in the order form with the standard information being the page count, deadline, academic level and type of paper. It is advisable to have this information at hand so that you can quickly fill in the necessary information needed in the form for the essay writer to be immediately assigned to your writing project. Make payment for the custom essay order to enable us to assign a suitable writer to your order. Payments are made through Paypal on a secured billing page. Finally, sit back and relax.

Do you need an answer to this or any other questions?

Similar Posts