MS 0: Modifying the Teaching Machine
As you may have seen in lecture, the TeachingMachine.py program works as a rudimentary Adventure-style game if you simply change the data file. The results of doing so, however, does not constitute a useful basis for building up a more sophisticated Adventure game. If nothing else, the metaphors used in the code are entirely inappropriate to the new context. The teaching machine program talks about courses, questions and answers, none of which make sense in the Adventure world. The corresponding concepts in Adventure are games, rooms, and passages. Your first step is to take the code for the teaching machine and adapt it so that it makes sense for the Adventure-game model.
You have two starting points for this phase of the project. The TeachingMachine folder contains the code for the teaching machine application presented in class. The main repository folder contains the starter versions of the files you need in order to implement the Adventure classes used in the Adventure game. Your task for this milestone is to adapt the code from the TMCourse.py and TMQuestion.py files into their AdvGame.py and AdvRoom.py counterparts (you do not have to do anything with AdvItem.py until Milestone 3).
The code you need to complete this milestone is almost entirely there already, at least in a functional sense. All you have to do is copy the code from the teaching machine application into the corresponding classes in the Adventure game, changing the names of the fields and methods so that they fit the Adventure game metaphor and making the small changes discussed here. The new names of the exported methods are given to you as part of the starter files, but you will also need to change the names of a few variables so that they make sense in the context of the game.
This milestone has two primary purposes:
- To ensure that you understand what is going on in the teaching machine application.
- To give you some practice in debugging. Even though the structure of the code remains exactly the same, this milestone is not as easy as you might think. Indeed, many students consider it one of the most difficult! Nearly all the variable and method names will have to change, and you will need to be careful to make sure that your changes are consistent. Since you will probably make some mistakes along the way, you will need to polish up your debugging skills to figure out what exactly you did wrong or missed.
There are two important differences that you should be aware of!
AdvRoomobjects have 4 pieces of information associated with them, whereasTMQuestionobjects only had three. You need to account for that, both in the constructor and in theread_roomfunction.- In the teaching machine example, the
read_coursefunction was used to read in and construct the originalTMCourseobject. If you look atAdventure.pyhowever, you will note a similar model is not being employed here. Instead, theAdvGameclass will open the necessary files directly in its constructor function, and that constructor is passed the file prefix as an argument. This is more convenient since you will need to eventually load multiple different files using the same prefix, and so it makes more sense to handle this all within theAdvGameconstructor instead of a separate function. Note that you will still need to read in all the game and room information, just like was done in the teaching machine function, but in this case you will want to set the needed attributes directly in the constructor.
When you finish this milestone, you should be able to wander a bit around the surface of the Adventure world, heading up to the top of the hill, inside the building, and down to the grate. You will not, unfortunately, be able to get past this grate until Milestone 6.