Wampus Mac OS
Wampus Mac OS
Boot Camp Control Panel User Guide
The Wampus The Wampus is a bot that randomly shows up in races. It is the rarest bot. If a racer successfully beats The Wampus in a race, they will receive an extra $50,000. The story of my personal experience with the Wampus Cat. I've also added some information about this legendary creature.http://www.appalachianhistory.net/20.
After you use Boot Camp Assistant to install Windows on your Intel-based Mac, you can set the default operating system to either macOS or Windows. The default operating system is the one you want to use when you turn on or restart your Mac.
Set the default operating system
In Windows on your Mac, click in the right side of the taskbar, click the Boot Camp icon , then choose Boot Camp Control Panel.
If a User Account Control dialog appears, click Yes.
Select the startup disk that has the default operating system you want to use.
If you want to start up using the default operating system now, click Restart. Otherwise, click OK.
You can’t change your startup volume to an external drive while you’re using Windows.
To learn how to change the default operating system using macOS, see Get started with Boot Camp.
Restart in macOS
In Windows on your Mac, do one of the following:
Restart using Startup Manager: Restart your Mac, then immediately press and hold the Option key. When the Startup Manager window appears, release the Option key, select your macOS startup disk, then press Return.
If you’re using a Mac notebook computer with an external keyboard, make sure you press and hold the Option key on the built-in keyboard.
Restart using Boot Camp Control Panel: Click in the right side of the taskbar, click the Boot Camp icon , then choose Restart in macOS.
This also sets the default operating system to macOS.
For more information about restarting in macOS, see the Apple Support article Restart your Mac in macOS or Windows.
Project 3: Using Logic to Hunt the Wumpus
I smell a wumpus,
Time to infer my next move,
Find gold, and escape.
Introduction
A total of 32 points can be earned over the course of thisproject, but only 24 points are needed to get full credits; any pointsover (8 more possible) will count as extra credit. (There is nospecific part of the project that is extra credit; complete everythingyou can!)
In this project, you will build a propositional logic (PL) agentcapable of solving a variant of the Hunt TheWumpus game. This will include constructing the agent's knowledgebase and implementing simple search routines the agent uses forplanning.
The code for this project consists of several Python files, some ofwhich you will need to read and understand in order to complete theassignment, and some of which you can mostly ignore. You can downloadall the code an supporting files (including this description) as a zip archive.
NOTE: The abreviation AIMA used below refers to theStuart Russell and Peter Norvig's book Artificial Intelligence: A ModernApproach, 3rd Edition, as well as the associated python codeavailable from their google coderepository (However, all files needed for Project 3 are includedin the zip archive; do not replace thefiles here with the AIMA files as in two cases I have slightly modifiedthe AIMA code).
Files you will edit and submit
wumpus_kb.py | Contains code to generate the wumpus knowledge base. You need to fill in most of these functions! |
wumpus_planners.py | Contains code to perform plan_route and plan_shot . You need to fill in code to implement the PlanRouteProblem and PlanShotProblem . See search.py for Problem parent class and examples. |
Files you will likely want to look at:
wumpus.py | The main file to execute the Hunt The Wumpus game. Contains code for generating WumpusWorldScenario s that combine a WumpusEnvironment and agent (either Explorer or HybridWumpusAgent ) to play the game. Includes agent programs to drive game play manually (with and without a knowledge base). Also includes __main__ command-line interface. |
wumpus_environment.py | Implements main classes of the wumpus domain. The Explorer agent is a simple wumpus hunter agent that does not have a knowledge base. The WumpusEnvironment implements the physics and game play of the Hunt The Wumpus game. |
wumpus_agent.py | Defines the HybridWumpusAgent (extends Explorer ). This agent includes a knowledge base. The agent_program implements a hierarchy of reflexes that are executed depending on the percepts and knowledge state. This includes calls to plan_route and plan_shot that you will implement in wumpus_planners.py . |
logic.py | AIMA code implementing propositional (PL) and first-order (FOL) logic language components and various inference algorithms. You will want to look at the relevant PL implementation. NOTE: I have modified this file slightly from the original AIMA release. |
search.py | AIMA code setting up basic search facilities; includes Problem class that you will implement in wumpus_planners.py for plan_route and plan_shot . |
Files you likely don't need to look at:
minisat.py | Implements the interface to MiniSat, including translating AIMA PL clauses into DIMACS CNF, generating the DIMACS file read by MiniSat, using python's sys interface to call MiniSat, and reading the MiniSat results. |
agents.py | AIMA code for the generic Agent and Environment framework. |
utils.py | AIMA code providing utilities used by other AIMA modules. NOTE: I have modified this file slightly from the original AIMA release. |
What to submit: You will fill in portions ofwumpus_kb.py
and wumpus_planners.py
during the assignment. You should submit these two files alongwith a partners.txt
file. Here are directions forsubmitting.
Evaluation: Your code will be autograded for technicalcorrectness. Please do not change the names of any providedfunctions or classes within the code, or you will wreak havoc on theautograder. However, the correctness of your implementation -- not theautograder's output -- will be the final judge of your score. Ifnecessary, we will review and grade assignments individually to ensurethat you receive due credit for your work.
Academic Dishonesty: We will be checking your codeagainst other submissions in the class for logical redundancy. If youcopy someone else's code and submit it with minor changes, we willknow. These cheat detectors are quite hard to fool, so please don'ttry. We trust you all to submit your own work only; pleasedon't let us down. If you do, we will pursue the strongestconsequences available to us.
Getting Help: You are not alone! If you findyourself stuck on something, contact me for help. If youcan't make our office hours, let us know and we will schedule ameeting time. We want these projects to be rewarding andinstructional, not frustrating and demoralizing. But, we don't knowwhen or how to help unless you ask. One more piece of advice: if youdon't know what a variable does or what kind of values it takes, printit out.
Notes on terminology
In the discussion and comments/docs in the code I freely switchbetween referring to the agent knowledge base, KB,kb and agent.kb. These are all the same thing: thecollective facilities for storing propositional logic sentences.
I sometimes abbreviate propositional logic as PL.
PL sentences expressed in full propositional logic aresentences that may include all of the standard PL connectives:And/Conjunction ('&
'),Or/Disjunction (''), Not/Negation('
~
'), Conditional ('>>
'),and Biconditional ('<=>
') (see logic.py
for full details about thePL python implementation). In the context of providing full PLsentences to the KB as rules for updating the agent's knowledge state,I will refer to these sentences as axioms.
When PL sentences are added to the KB, they are immediatelyconverted to conjunctive normal form, CNF. This CNFrepresentation is stored in the KB as a list of theindividual disjunctive clauses (the list is treated as an implicitconjunction of its member clauses), and I will refer to the clauses inthe list collectively as the KB clauses.
Setup: Install MiniSat, download project code, and run test
This project relies on the light weight, open source, crossplatform SAT solver MiniSat (http://minisat.se). There are a varietyof ways to obtain MiniSat; here are methods for the popular threeplatforms:
- Mac OS X: Several options:
(a) install using brew (recommended: Homebrew; may require first installing gcc$ brew install gcc
then$ brew install minisat
(b) install using port (http://macports.org); or
(c) install from source following these instructions. - Linux: Debian package; or take a look at this discussion
- Windows: see these instructions
After installing MiniSat, download the Project 3 zip archive (wumpus.zip) and unzip it (if you haven't already), and change to the wumpus directory. You can then test the connection to MiniSat by executing the following from the command-line:
The three simple tests should pass. If they do not, or you getunexpected behavior, please contact me for help.
Welcome to the Wumpus Caves!
Having verified that the connection to MiniSat works, the next stepis to familiarize yourself with the Hunt The Wumpus game. Execute thefollowing at the command-line to to play the game:
This launches the interactive command-line interface to the game,running in 'Manual' mode: you control the wumpus hunting agent.Entering 'env
' at any point will display an ascii-artrepresentation of the current Wumpus enviroment state. For example, whenexecuted in the first time tick, you will see:
At the top, the current score of the Wumpus hunting agent (in thedefault manual mode, represented as an <Explorer>) is displayed.The x coordinates of the Wumpus environment are displayed across therow above the grid, and the y coordinates are displayed down theright-side of the grid. Each grid cell represents a wumpus cave room.'#' represents a wall, and 'W', 'P', and 'G' represent the Wumpus, aPit, and the Gold, respectively. The position of the wumpus hunteragent are represented by '^', '>
', 'v', and'<
', each of which show the direction (heading) thehunter agent is currently facing. At the start, the agent is inlocation (1,1).
Enter'?
' at any time to see a complete list of commands.
The goal of the game is to achieve the highest score. Each movecosts one point, shooting the arrow (irrespective of whether it killsthe Wumpus) costs 10 points, and leaving the caves (accomplished byexecuting 'Climb
' in the same location that the hunteragent started in (the cave 'entrance') with the Gold (i.e.,having previously successfuly 'Grab
'bed the Gold), earns1000 points. Dying, by entering a square with the Wumpus or a Pit,costs 1000 points.
At each time step, the current percepts are represented by a listof the percept propositions ('~' represents that the proposition iscurrently False). For example, at time 0 (indicated in the bracketson the left) the percepts for the environment depicted above are:
Play several games and see how the Wumpus environment statedetermines the percepts. Try dying by moving into the Wumpus squareor a Pit. Shoot the Wumpus: you must execute 'Shoot
'while facing the Wumpus; when successful, the Wumpus will die and thefollowing time step you will perceive the 'Scream
'; alsonote that the Wumpus is no longr represented by 'W', instead replacedby an 'X'. It is now safe to move into the Wumpus square. Also solvethe game by moving to the Gold, executing 'Grab
', andmove back to the exit/entrance and execute 'Climb
'.
You can load different Wumpus environment layouts by specifyingeither the name of an existing layout in the wumpus/layouts/ directory (currently there areonly two provided), or by specifying the path to a layout, using thiscommand-line option:
(You can optionally specify the layout extension '.lay'.) Theformat of a layout specification file is very simple; here's anexample:
The file format specifies the Wumpus environment grid as a seriesof comma-separated wumpus-room specifications, with each rowrepresenting a row of rooms in the Wumpus environment. '.' representsan empty wumpus room, 'W' places a Wumpus (the knowledge base you willcreate below can only accommodate presence of exactly 1 Wumpus, nomore or less, but in the manual game you can have multiple Wumpi), 'P'places a Pit, 'G' places the Gold (again, the KB will only supportGrabbing 1 Gold), and 'A' is the location of the Wumpus hunting Agent(The Agent's heading is specified separately in code; North, or '^',is the default). You can also add Walls, represented by '#'. Bydefault, the specified layout will be automatically surrounded byWalls when the Wumpus environment is constructed.
Take a look at the code comments and examples in wumpus.py
to see how to constructa WumpusWorldScenario from a layout file or by specifying directly incode by constructing objects and assigning them to Wumpus environmentlocations.
General comments about the code structure and command-line options
There are two main classes that together make a working version ofthe Hunt the Wumpus game: the WumpusEnvironment
and aninstance of an agent are combined in aWumpusWorldScenario
, defined in wumpus.py
.
- The
WumpusEnvironment
, defined inwumpus_environment.py
,represents the Wumpus cave environment, the position and state of allobjects, and enforces the rules of the game (the game 'physics'), suchas the effects of agent actions. Thestep()
methodadvances the game one time step and includes calling the Wumpus hunteragent'sagent_program
. - There are two classes that define Wumpus hunter agents. The
Explorer
, also defined inwumpus_environment.py
,provides a minimal hunter agent skeleton, while theHybridWumpusAgent
, defined inwumpus_agent.py
,is a full agent implementation and includes a knowledge base and setof reflexes sufficient to solve any Hunt the Wumpus game (once youprovide some code).
The main action of a wumpus hunter agent happens in itsagent_program
. There are three differentagent_program
s provided:
- The function
with_manual_program
(inwumpus.py
) takes an agent as input and replaces itsagent_program
with a 'manual'agent_program
in which the agent waits for commands from the command-line at each step. This is the agent that is run when launching the game from the command-line with (with or without the '-l
' layout file option): This version is most useful for playing the game and verifying you understand the 'physics' of the Wumpus environment (i.e., the effects ofa ctions of states of the world and subsequent percepts). - The function
with_manual_kb_program
(also inwumpus.py
) works similar towith_manual_program
except the agent also creates a knowledge base and theagent_program
updates a knowledge base with new percepts and the action selected (by the human user) at each step. The user can also issue any relevant query about propositions in the knowledge base. This option is most useful for developing and debugging the axioms you provide for initializing and updating the knowledge-based. This version of the agent program can be run by executing the following from the command-line (inside the wumpus/ directory): (You can also combine this with the '-l
' option to load a specific layout.) Once launched, enter '?
' to get thelist of commands and complete list of available query types. - The
HybridWumpusAgent
(HWA) class is defined inwumpus_agent.py
(it is asubclass of theExplorer
). The HWA defines anagent_program
that implements the Wumpus agent asspecified in Figure 7.20, page 270 of AIMA. Once you have correctly implemented the knowledge baseaxiom generators (inwumpus_kb.py
), and thePlanRouteProblem
andPlanShotProblem
methods (allinwumpus_planners.py
), theHWAagent_program
will be able to solve any (solvable)instance of the Hunt The Wumpus game. The HWA and itsagent_program
can be run from the command-line (insidethe wumpus/ directory) with:(Again, you can also combine this with the '-l
' option;however, '-y
' option will override the '-k
'option, if included). When run, the HWAagent_program
will select all actions, so there is nothing for the human user to dobut watch. As with the above options, the output to screen isintentionally very verbose so that you can follow along with each stepin the execution.
To see what 'correct' behavior should look like, I have provided theoutput of two runs of the fully-implemented HWA, running on the twoprovided layouts: HWA_lay_book_run.txt and HWA_lay_2_run.txt.
Also note that the number of clauses in the KB grows as the agenttakes actions in the environment. This is expected: at each time step,new axioms are added to the knowledge base in order to representchange (based on percepts and actions). You will be implementingthese axiom generators. The following two figures graphically showthe growth in the number of clauses and the time it takes to make onekind of query (current location) over the 30 steps of the HWA_lay_2_run.txt run.
NOTE: While you can construct layout sepcifications (eitherin layout files or in code) in any dimensions, it is recommend thatyou follow these general constraints (mainly due to working with theknowledge base; for general manual play without a KB, any size is fine):
- Do not create environments smaller than two rooms, as the knowledgebase assumes there is 1 and only 1 Wumpus, so a 1-room cave wouldnecessarily put the Wumpus in the same location as the entrance,leading to a contradiction!
- Do not create environments greater than 16 rooms, as the KB willgrow in size too quickly and inference will bog down.)
Development
As the knowledge base and agent planner(s) developer, you haveseveral choices as to how to proceed with development. The manualcommand-line interfaces to the wumpus game, defined above andimplemented in wumpus.py
,were designed to be a way by which you can directly observe the impactof code changes on knowledge base inference and agent behavior.However, you may find some or all development easier by incrementallyinstantiating and testing parts of the code; in this case, start withthe WumpusWorldScenario
to see how the main pieces areput together.
Propositional logic in python
The two agent programs you will be working with (found either in with_manual_kb_program
in wumpus.py
or the HybridWumpusAgent
(HWA) class defined in wumpus_agent.py
) make use of the PropKB_SAT
knowledge base. This is defined in wumpus_agent.py
and is a subclass the PropKB
class defined in logic.py
. As you'll see, these are actually quite simple, implementing the tell()
method to add new sentences to the knowledge base, and the ask()
method to query the knowledge base (ask()
is an interface MiniSat). Assertions made to the knowledge base (often starting as PL syntax expressed in a string) are stored in the clauses
field of the KB, and that is just a python list! (Robust implementations of propositional KBs have much more sophisticated storage). Representation of the assertions (sentences) themselves are built on top of the AIMA implementation of propositional logic. As you will be implementing axiom generators, it is important you understand how propositional sentences, initially expressed in strings, are turned into the underlying propositional logic representations. Take a look in logic.py
. In particular, the following excerpt from the python prompt demonstrates some of the basic functionality.
On line 2, I express a propositional sentence in a string, in thesyntax of the AIMA propositional language. See the Expr
class in logic.py
. Thefunction expr()
parses that string and builds anExpr
. The Expr
object is designed to have a'pretty' python representation, an example of which is on line 4 above(this is accomplished by the definition of the __repr__()
method in Expr; see thisexplanation). But keep in mind that this is an object! It hastwo main fields: the operator, op
, and a list ofarguments to the operator, args
. Since the variablee
currently references the Expr, we can inspect theop
and args
as follows:
This shows that the Expr e
refers to has as itsoperator the conditional symbol, and its args have two entries, thefirst being the antecedent to the conditional, in this case A& B
, and the second is is the consequent, ~(C D)<=> E
. Each of these are also Exprs, with the first having theconjunction operator, '&'
, with two argsA
and B
. In this way, our original Exprreferred to by e
is actually the root of an Expr tree,allowing for representation of arbitrarily complex sentences.
Be sure to look at the docs for Expr
andexpr()
in logic.py
to understand how the PLsyntax will be parsed from a string, in particular the note in thedocs of expr()
about operator precedence: expr('P &Q > R & S')
will be parsed as ((P & (Q >> R)) &S)
, which may not be what you intended! To get the expectedoperator precedence enforced (i.e., &
with higherprecedence than >
), you must use expr('(P & Q)> (R & S)')
. In general, it is best to use parentheses toenforce the precedence you intend!
Moving on with the original example, on line 5 I convert the fullPL sentence into conjunctive normal form using theto_cnf()
function; line 6 shows the result. This is stillan Expr
object; also it is completely logicallyequivalent to the previous form expressed on lines 2 and 4. Wheneveran Expr is tell()
ed to the KB, the Expr will be convertedto CNF. Then the conjuncts of the CNF will be extracted so that whatis stored in the clauses
store of the KB is a list of theindividual clauses of the CNF. This is demonstrated on line 7.
Finally, a note about the use of MiniSat. MiniSat is a SAT solver,meaning that it searches for the a satisfying assignment to a set ofCNF clauses, return True if such an assignment is found (and inMiniSat's case, it also returns the satisfying assignment), or Falseif no assignment is found. This is a good building block but not byitself sufficient for propositional inference. In our case, we willnot be doing full proposition inference, but instead asking whetherindividual propositions are entailed (True) or not (False) by the KB,or whether their truth cannot be determined. In order to determinewhich of these three possible outcomes is the case, theask()
method of PropKB_SAT
make twocalls to minisat, one which which the query variable (the propositionwho's truth we're trying to determine) is assumed to be True, and onewhere it is assume to be False, and in both cases minisat determineswhether that assertion conjuncted with all of the clauses in the KB issatisfiable. If the clauses + query are satisfiable in bothcases, then that means the KB cannot determine whether the propositionis True or False. On the other hand, if one call to minisat issatisfiable, but the other not, then the proposition's truth is whichof the calls was satisfiable. In general you won't have to worryabout these details, but it is important to understand how this isworking!
Construct the knowledge base
OK, time to get to work! The first set of tasks is to fill in theaxiom generators for the knowledge base. For this part of the projectyou will work in wumpus_kb.py
, adding your codeto all locations indicated by '*** YOUR CODE HERE ***'
.You will notice a pattern here, all of the methods you areimplementing start with 'axiom_generator_...' in their name. The docstrings to these functions describe the knowledge that you need toassert in propositional logic, with explanations of what the functionarguments represent. The return values are assumed to be stringsrepresenting the PL assertions.
Section 7.7 of AIMA, starting on page 265, is a good guide for anumber of the axioms you are required to implement. But beware, it isincomplete!
After the current percept sentence generator (which converts perceptvectors into a sentence asserting percept propositions), there are twogeneral classes of axiom generators you will construct: a set thatgenerate axioms describing the initial state of knowledge, and axiomsthat represent changes over time (in particular, the successor-stateaxioms).
The assertions your generators will make will be built out ofpropositions. The first section of wumpus_kb.py
defines everyproposition that will appear in the KB. Because it would be very easyto add a malformed proposition symbol to the KB without knowing it, Ihave provided a set of proposition string builder functions, one foreach type of proposition. Even though it is more verbose to usefunction calls like percept_breeze_str(3)
rather thanjust 'Breeze3
', you'll be better off, as the KB itselfwon't tell you if you happened to have mistakenly asserted'Breez3
' (that's a misspelling!) -- the KB will happilyaccept it and you'll be left to find your mistake through painfuldebugging! However, the choice is entirely up to you -- nothing aboutthe grading will check whether you use these string-builders
You will be working a lot with strings in this part of theproject. Here are general python string functions that I found usefulwhile building my solution:
- The plus sign is overloaded:
'a' + 'b'
results in'ab'
- The
join
method is very handy; the first string the join being called on will be inserted between the listed strings being joined (use an empty string to just concatenate the list of strings):'.join(['a','b','c'])
results in'abc'
'-'.join(['a','b','c'])
results in 'a-b-c'
- The
format
method is your friend:'string with {0}{1}'.format('stu', 'ff')
results in'string with stuff'
Points will be awarded, pending correct implementation, as follows (for a total of 24 points):
axiom_generator_percept_sentence
= 1 ptaxiom_generator_initial_location_assertions
= 0.5 ptaxiom_generator_pits_and_breezes
= 1 ptaxiom_generator_wumpus_and_stench
= 1 ptaxiom_generator_at_least_one_wumpus
= 1 ptaxiom_generator_at_most_one_wumpus
= 1 ptaxiom_generator_only_in_one_location
= 1 ptaxiom_generator_only_one_heading
= 1 ptaxiom_generator_have_arrow_and_wumpus_alive
= 0.5 ptaxiom_generator_location_OK
= 1 ptaxiom_generator_breeze_percept_and_location_property
= 1 ptaxiom_generator_stench_percept_and_location_property
= 1 ptaxiom_generator_at_location_ssa
= 4 ptsaxiom_generator_have_arrow_ssa
= 1 ptaxiom_generator_wumpus_alive_ssa
= 1 ptaxiom_generator_heading_{north,east,south,west}_ssa
= 3 pts (for the set)axiom_generator_heading_only_{north,east,south,west}
= 2 pts (for the set)axiom_generator_only_one_action_axioms
= 2 pts
NOTE: While you are constructing the knowledge basegenerators, the KB should always be satisfiable. If it ever becomesunsat, then something you have added is leading to a contradiction!That is always a problem. To check for satisfiability of the KB, callthe minisat()
function in wumpus_agent.py
with justthe KB clauses, e.g., minisat(kb.clauses)
; when runningthe wumpus.py with a KB (option -k
) from thecommand-line, you can enter the 'kbsat
' command to do thesame thing. Note, however, that just because the KB is satsifiabledoes not mean there are not other problems.
Implement route and shot planning
Wampus Mac Os Download
The second major task of Project 3 is to complete the implementation of the route and shot planning for the Hybrid Wumpus Agent. Your coding will take place in wumpus_planners.py
. The docs for plan_route
and plan_shot
outline the problem, but the code to be added will be in the PlanRouteProblem
and PlanShotProblem
classes, both of which extend the search Problem
class (defined in search.py
) that serves as the interface to the AIMA search code.
Wampus Mascot
The goal_test
in both problems is initially set to always return True, and both plan_route
and plan_shot
will return empty action lists if finding a solution fails. This allows you to run the full Hybrid Wumpus Agent even before these planning facilities are implemented, but obviously you'll be changing things.
Once implemented, both plan_route
and plan_shot
will use the AIMA implementation of A*, which is also defined in search.py
(as astar_search()
).
It is recommended that you implement PlanRouteProblem
first, as much of the solution there can be used in PlanShotProblem
. Remember, for the PlanShotProblem
, you only need to plan a path to the closest location in which you will be facing the Wumpus.
As noted in plan_route
and plan_shot
, therepresentation of a state is a triple representing the x, ylocation and heading, of the agent. The heading is an integer of 0,1, 2, or 3, representing North, West, South, and East, respectively.Goals and allowed states, however, ignore heading, and thus are justlists of x,y tuples. manhattan_distance_with_heading()
has been provided; as the name suggests, it computes the Manhattandistance, but also adds in the cost of having to change the heading(i.e., turn to the correct orientation) before following the Manhattanpath.
Correct implementation of each search problems is worth 4 points each,for a total of 8 points.
Wampus Mac OS