You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Originally posted by jdonwells April 23, 2022
As proposed here #349 I am trying out moving the projects around. In this instance the Interactive Fiction (aka text adventure) to Unit 6.
The biggest issue was how much starter code to give. I decided they should need to add about 80 lines of code. 80 lines of code for a project is about what I have been doing at each unit.
The following days after the introduction a command is discussed. I usually start with the starter code and program it in front of the class. And explain how it works in detail. The code created this way is not shared in any copy paste form. They must watch, listen, ask questions, then replicate the code. The order I used was north(), south(), east(), west() then get() then fight().
Last I go through the loop in play_game(). I show them two ways to do it. The first is the way they already know with a cascading if else. Then I show them how to do it with a dictionary full of functions. Since this unit is about dictionaries it makes sense, but they can still turn in the way they already know.
The starter code looks like this:
"""Interactive Fiction GameThe goal of this game is to beat the monsters and claim the prize at the end ofthe dungeon.""""""The map and descriptions of various rooms and items. 5 character abbreviations so youcan see what the map is easily. None is used to indicate a solid wall. I have put Nonearound the entire map so I don't have to code exceptions for off the map indexing."""dungeon_map= [
[None, None, None, None, None, None, None, None, None, None],
[None, "start", "sword", "empty", "tapes", "plant", "sword", "orc", "empty", None],
[None, None, None, "tarot", None, None, "maze", None, None, None],
[None, "kitch", "sword", "orc", None, "maze", "maze", "maze", "maze", None],
[None, "leavs", None, None, None, "maze", None, "maze", "maze", None],
[None, "tapes", None, "plant", None, "spidr", "maze", None, "maze", None],
[None, "libry", "tunlN", "store", None, None, None, "maze", "maze", None],
[None, None, "tunnl", None, None, "halbd", "mazOW", "maze", None, None],
[None, "sword", "tunlS", "puddl", None, None, "hole", None, None, None],
[None, None, None, "bigNW", "bigNE", "plant", "kitch", "troll", "tapes", None],
[None, "stnes", "thron", "bigSW", "bigSE", "sword", None, None, "empty", None],
[None, None, None, "troll", None, None, None, "prize", "troll", None],
[None, None, None, None, None, None, None, None, None, None],
]
room_descriptions= {
# describe the different rooms# things you can pick up"sword": "This is an unremarkable room. There is a rusty old sword here!",
"halbd": "So many rusted and broken weapons. There is one that stands out. ""A halberd decorated with gold and silver that glows with some ""kind of magic.",
"stnes": "There are mysterious glowing stones here.",
"prize": "You have found a prize!",
# an empty room after you pick up the thing that was here"empty": "You are in an empty room.",
# some different rooms that just have discriptions and can be used and reused"start": "You are stuck at the bottom of a dry well. There is a moldy"" door to the East that you forced open.",
"thron": "You are in a throne room complete with a large gaudy chair. ""You imagine it was resplendent in gold and red before it all ""faded to brown and grey.",
"tapes": "You have found a room with large faded tapestries on the walls. ""Moths have chewed holes in some of them.",
"puddl": "A foul smelling puddle makes you feel a bit ill.",
"kitch": "This room has a very large cauldron over a burnt out fire pit. ""From the bones piled neatly in the corner you surmise adventurers"" are cooked and eaten here.",
"tarot": "A goblin with gaudy makeup is sitting at a table with tarot cards"" laid out in front of her. She looks up as you enter. She flips a "'card and gives you your fortune: "Death".',
"store": "This was once a room full of crates and barrels to store ""important things. Everything has been broken open and emptied. ""What a mess.",
"libry": "This library is in poor condition. The books crumble to dust when ""you touch them. Ironically, as you pick up a novel by Margaret ""Mitchell it turns to dust and blows away in a cool draft of air.",
# a tight tunnel that takes up 3 spaces"tunlN": "A small tunnel goes South. You might be able to squeeze through.",
"tunnl": "You are in a tunnel just big enough to squeeze through.",
"tunlS": "A small tunnel goes North. You might be able to squeeze through.",
# The maze uses the same discription over and over to confuse the player.# There is a way to get out with the halberd and get to the prize."maze" : "You are in a maze of twisty little passages, all alike.",
"mazOW": "You are in a maze of twisty little passages. There is a hole in"" the wall to the South with a ladder to reach it. If you go ""through it you may not get back.",
"hole" : "There is a hole near the ceiling to the North, if you stack a few ""dead bodies up you might be able to reach it.",
# a big cave that takes up 4 locations on the map. It discribes an orc troll war."bigNW": "This is an enormous cave. It looks like a war between orcs and ""trolls has been going on here for a while. You are in the North"" West corner.",
"bigNE": "This is an enormous cave. The war between orcs and trolls has ""been brutal. You are in the North East corner.",
"bigSW": "This is an enormous cave. Dead orcs and trolls are every where. ""You are in the South West corner.",
"bigSE": "This is an enormous cave. It looks like a war between orcs and ""trolls started here. You are in the South East corner.",
# monsters that want to kill you."orc" : "There is an angry orc here! He is going to kill you without ""any further discussion.",
"troll": "An extraordinarily large, unhappy troll is sitting here. He ""isn't going to let you pass without extracting a cost.",
"plant": "There is a huge carnivorous plant growing out of a large crack ""in the floor. It is snapping at you. You could try sneaking around ""it, but it will probably eat you.",
"spidr": "A very large spider sits motionless in an even larger web.",
# dead versions of all the monsters that didn't kill you."corpse": "You find a dead orc just laying there.",
"troll corpse": "A dead troll is sprawled out across the room. ""You will need to climb over him.",
"leavs": "This room is littered with very large dried up leaves.",
"gooey web": "There is a large spider web with some kind of goo all over it.",
}
item_descriptions= {
# descriptions of things in your bag"sword": "a rusty sword",
"stnes": "some mysterious glowing stones",
"halbd": "a glowing ceremonial halberd",
"prize": "The Final Prize",
}
death_by_monster= {
# describe how you died."orc" : "The orc kills you in a most horrible way.",
"troll": "You are unprepared. The surprisingly big troll cheerfully kills you.",
"plant": "You are grabbed by the large plant and slowly digested over the next ""couple of days.",
"spidr": "The spider grabs you with amazing speed and agility. You will be ""eaten in a few days. Enjoy hanging out with the spider.",
}
kill_the_monster= {
# describe how the monster died."orc" : "You manage to kill the orc.",
"troll": "The surprisingly big troll also dies surprisingly easy.",
"plant": "You hack the plant into pieces. The large leaves are ""already turning brown.",
"spidr": "You stab the overgrown spider and it oozes in a disgusting way.",
}
monster_to_corpse= {
# change the room description after the monster is dead."orc" : "corpse",
"troll": "troll corpse",
"plant": "leavs",
"spidr": "gooey web",
}
help_text= (
"You may go west (w), east (e), north (n) or south (s) if there is an exit. "+"You can get (g) and fight (f). You may also check your bag (b). "+"To repeat the room description use look (l). To repeat this type help."+"\n"
)
"""Room locations and code to manipulate them.A room location is a list of two integers. The first or 0 elementis the north-south index. The second or 1 element is the east-westindex."""moves= {
"east" : [ 0, 1],
"west" : [ 0, -1],
"north": [-1, 0],
"south": [ 1, 0]
}
defstart_location():
return [1, 1]
defroom_to_the(direction):
return [room[0] +moves[direction][0], room[1] +moves[direction][1]]
defroom_type(a_room):
returndungeon_map[a_room[0]][a_room[1]]
defset_this_room_type(type):
globaldungeon_mapdungeon_map[room[0]][room[1]] =typedefthis_room():
returnroom_type(room)
defroom_exists(a_room):
returnroom_type(a_room) !=Nonedefis_there_a_room_to_the(direction):
returnroom_exists(room_to_the(direction))
defset_room_to_the(direction):
globalprevious_room, roomprevious_room=roomroom=room_to_the(direction)
defgoing_back(direction):
returnprevious_room==room_to_the(direction)
defempty_this_room():
set_this_room_type("empty")
defdescription_of_this_room():
returnroom_descriptions[this_room()]
defmonster_died_in_this_room():
set_this_room_type(monster_to_corpse[this_room()])
definitialize_map():
globalroom, previous_roomroom=start_location()
previous_room=start_location()
"""Functions to run the various commands you can enter."""defhelp():
print(help_text)
defwest():
passdefeast():
passdefnorth():
passdefsouth():
passdeflook():
print(description_of_this_room())
print(exits())
defget():
passdeffight():
passdefbag_contents():
passdefunknown():
print('Command not recognized. Type "help" to see commands.')
"""Functions that help other functions in some way."""defexits():
good_exits= [
directionfordirectionin ["east", "west", "north", "south"]
ifis_there_a_room_to_the(direction)
]
description="You can go "iflen(good_exits) ==1:
description=description+good_exits[0]
else:
fordirectioningood_exits[0:-1]:
description=description+direction+", "description=description+"or "+good_exits[-1]
returndescription+"."definitialize():
globalbag, statebag= []
initialize_map()
state="playing"defprint_winner():
# Way back before digital images there was ASCII art.line1="\\\\"+" "*4+"/ /"+" "*17+"||"+" "*3+"/ | / /"+" "*13+"//"line2=" \\\\ / / ___"+" "*13+"|| / | / "+"/ () ___"+" "*5+"//"line3= (" \\\\/ / //"+" "*3+")) //"+" "*3+"//"+" "*3+"|| / /||/ "+"/ // //"+" "*3+")) //")
line4= (" "*3+"/ / //"+" "*3+"// //"+" "*3+"//"+" "*4+"||/ / | / "+"// //"+" "*3+"//")
line5= (" "*2+"/ / (("+"_"*3+"// (("+"_"*3+"(("+" "*5+"| / | / /"+"/ //"+" "*3+"// //")
line7=" "*21+"/| "+"_"*16line8=" "*15+"O|"+"="*3+"|* >"+"_"*16+">"line9=" "*21+"\|"ifstate=="win":
print(
"", "", line1, line2, line3, line4, line5,
"", line7, line8, line9,
"", "", "You have won the game.",
sep="\n"
)
else:
print("You lost the game. Maybe next time.")
defwelcome():
print(
"Welcome to my Text Adventure Game. Kill the monsters, survive,",
"and find the Final Prize to win!",
"\n"
)
"""This is the function that plays the game. There is a loop that continues until the game is won or lost."""defplay_game():
""" Start up my text adventure game. Uses the console for everything. """initialize()
welcome()
help()
look()
# read a command from the console and execute it in a loop.play_game()
You may have noticed a list comprehension used in exits(). I changed 4.04 to be about list comprehensions. #370
One of my students gets very excited about formatted output. I added the ASCII art for her to enjoy.
When I show them the code for fight() I first do it with an extra elif for the troll special case. After it is done I will note some duplicated code and refactor it to the more complex conditional that covers both cases.
While coding, I will explain the idea of writing out code with the assumption that I have functions that already exist like there_is_a_monster_here(). I then code those after the current function is done.
As stated above each day we look at how to program the main functions that do things. The code I generally try to emulate follows:
"""Interactive Fiction GameThe goal of this game is to beat the monsters and claim the prize at the end of the dungeon.""""""The map and descriptions of various rooms and items. 5 character abbreviations so youcan see what the map is easily. None is used to indicate a solid wall. I have put Nonearound the entire map so I don't have to code exceptions for off the map indexing."""dungeon_map= [
[None, None, None, None, None, None, None, None, None, None],
[None, "start", "sword", "empty", "tapes", "plant", "sword", "orc", "empty", None],
[None, None, None, "tarot", None, None, "maze", None, None, None],
[None, "kitch", "sword", "orc", None, "maze", "maze", "maze", "maze", None],
[None, "leavs", None, None, None, "maze", None, "maze", "maze", None],
[None, "tapes", None, "plant", None, "spidr", "maze", None, "maze", None],
[None, "libry", "tunlN", "store", None, None, None, "maze", "maze", None],
[None, None, "tunnl", None, None, "halbd", "mazOW", "maze", None, None],
[None, "sword", "tunlS", "puddl", None, None, "hole", None, None, None],
[None, None, None, "bigNW", "bigNE", "plant", "kitch", "troll", "tapes", None],
[None, "stnes", "thron", "bigSW", "bigSE", "sword", None, None, "empty", None],
[None, None, None, "troll", None, None, None, "prize", "troll", None],
[None, None, None, None, None, None, None, None, None, None],
]
room_descriptions= {
# describe the different rooms# things you can pick up"sword": "This is an unremarkable room. There is a rusty old sword here!",
"halbd": "So many rusted and broken weapons. There is one that stands out. ""A halberd decorated with gold and silver that glows with some ""kind of magic.",
"stnes": "There are mysterious glowing stones here.",
"prize": "You have found a prize!",
# an empty room after you pick up the thing that was here"empty": "You are in an empty room.",
# some different rooms that just have discriptions and can be used and reused"start": "You are stuck at the bottom of a dry well. There is a moldy"" door to the East that you forced open.",
"thron": "You are in a throne room complete with a large gaudy chair. ""You imagine it was resplendent in gold and red before it all ""faded to brown and grey.",
"tapes": "You have found a room with large faded tapestries on the walls. ""Moths have chewed holes in some of them.",
"puddl": "A foul smelling puddle makes you feel a bit ill.",
"kitch": "This room has a very large cauldron over a burnt out fire pit. ""From the bones piled neatly in the corner you surmise adventurers"" are cooked and eaten here.",
"tarot": "A goblin with gaudy makeup is sitting at a table with tarot cards"" laid out in front of her. She looks up as you enter. She flips a "'card and gives you your fortune: "Death".',
"store": "This was once a room full of crates and barrels to store ""important things. Everything has been broken open and emptied. ""What a mess.",
"libry": "This library is in poor condition. The books crumble to dust when ""you touch them. Ironically, as you pick up a novel by Margaret ""Mitchell it turns to dust and blows away in a cool draft of air.",
# a tight tunnel that takes up 3 spaces"tunlN": "A small tunnel goes South. You might be able to squeeze through.",
"tunnl": "You are in a tunnel just big enough to squeeze through.",
"tunlS": "A small tunnel goes North. You might be able to squeeze through.",
# The maze uses the same discription over and over to confuse the player.# There is a way to get out with the halberd and get to the prize."maze" : "You are in a maze of twisty little passages, all alike.",
"mazOW": "You are in a maze of twisty little passages. There is a hole in"" the wall to the South with a ladder to reach it. If you go ""through it you may not get back.",
"hole" : "There is a hole near the ceiling to the North, if you stack a few ""dead bodies up you might be able to reach it.",
# a big cave that takes up 4 locations on the map. It discribes an orc troll war."bigNW": "This is an enormous cave. It looks like a war between orcs and ""trolls has been going on here for a while. You are in the North"" West corner.",
"bigNE": "This is an enormous cave. The war between orcs and trolls has ""been brutal. You are in the North East corner.",
"bigSW": "This is an enormous cave. Dead orcs and trolls are every where. ""You are in the South West corner.",
"bigSE": "This is an enormous cave. It looks like a war between orcs and ""trolls started here. You are in the South East corner.",
# monsters that want to kill you."orc" : "There is an angry orc here! He is going to kill you without ""any further discussion.",
"troll": "An extraordinarily large, unhappy troll is sitting here. He ""isn't going to let you pass without extracting a cost.",
"plant": "There is a huge carnivorous plant growing out of a large crack ""in the floor. It is snapping at you. You could try sneaking around ""it, but it will probably eat you.",
"spidr": "A very large spider sits motionless in an even larger web.",
# dead versions of all the monsters that didn't kill you."corpse": "You find a dead orc just laying there.",
"troll corpse": "A dead troll is sprawled out across the room. ""You will need to climb over him.",
"leavs": "This room is littered with very large dried up leaves.",
"gooey web": "There is a large spider web with some kind of goo all over it.",
}
item_descriptions= {
# descriptions of things in your bag"sword": "a rusty sword",
"stnes": "some mysterious glowing stones",
"halbd": "a glowing ceremonial halberd",
"prize": "The Final Prize",
}
death_by_monster= {
# describe how you died."orc" : "The orc kills you in a most horrible way.",
"troll": "The surprisingly big troll cheerfully kills you.",
"plant": "You are grabbed by the large plant and slowly digested over the next ""couple of days.",
"spidr": "The spider grabs you with amazing speed and agility. You will be ""eaten in a few days. Enjoy hanging out with the spider.",
}
kill_the_monster= {
# describe how the monster died."orc" : "You manage to kill the orc.",
"troll": "The surprisingly big troll also dies surprisingly easy.",
"plant": "You hack the plant into pieces. The large leaves are ""already turning brown.",
"spidr": "You stab the overgrown spider and it oozes in a disgusting way.",
}
monster_to_corpse= {
# change the room description after the monster is dead."orc" : "corpse",
"troll": "troll corpse",
"plant": "leavs",
"spidr": "gooey web",
}
help_text= (
"You may go west (w), east (e), north (n) or south (s) if there is an exit. "+"You can get (g) and fight (f). You may also check your bag (b). "+"To repeat the room description use look (l). To repeat this type help."+"\n"
)
"""Room locations and code to manipulate them.A room location is a list of two integers. The first or 0 elementis the north-south index. The second or 1 element is the east-westindex."""moves= {
"east" : [ 0, 1],
"west" : [ 0, -1],
"north": [-1, 0],
"south": [ 1, 0]
}
defstart_location():
return [1, 1]
defroom_to_the(direction):
return [room[0] +moves[direction][0], room[1] +moves[direction][1]]
defroom_type(a_room):
returndungeon_map[a_room[0]][a_room[1]]
defset_this_room_type(type):
globaldungeon_mapdungeon_map[room[0]][room[1]] =typedefthis_room():
returnroom_type(room)
defroom_exists(a_room):
returnroom_type(a_room) !=Nonedefis_there_a_room_to_the(direction):
returnroom_exists(room_to_the(direction))
defset_room_to_the(direction):
globalprevious_room, roomprevious_room=roomroom=room_to_the(direction)
defgoing_back(direction):
returnprevious_room==room_to_the(direction)
defempty_this_room():
set_this_room_type("empty")
defdescription_of_this_room():
returnroom_descriptions[this_room()]
defmonster_died_in_this_room():
set_this_room_type(monster_to_corpse[this_room()])
definitialize_map():
globalroom, previous_roomroom=start_location()
previous_room=start_location()
"""Functions to run the various commands you can enter."""defhelp():
print(help_text)
defwest():
move("west")
defeast():
move("east")
defnorth():
move("north")
defsouth():
move("south")
deflook():
print(description_of_this_room())
print(exits())
defget():
globalstateifthis_room() notinitem_descriptions:
print("There is nothing to get.")
else:
print("You get "+item_descriptions[this_room()] +".")
ifthis_room() =="prize":
state="win"bag.append(this_room())
empty_this_room()
deffight():
globalstateifnotthere_is_a_monster_here():
print("Relax, there is nothing to fight here.")
elif (
(there_is_a_monster_here() andnotready_for_monster()) or
(there_is_a_troll_here() andnotready_for_troll())
): # even Python is sad about itprint("You are not prepared.", death_by_monster[this_room()])
state="lose"else:
print(kill_the_monster[this_room()])
ifnot"halbd"inbag:
print("Your rusty old sword breaks. You won't be using it again.")
bag.remove("sword")
monster_died_in_this_room()
defbag_contents():
iflen(bag) ==0:
print("Your bag is empty.")
else:
foriteminbag:
print(item_descriptions[item])
defunknown():
print('Command not recognized. Type "help" to see commands.')
"""Functions that help other functions in some way."""defmove(direction):
globalstateifnotis_there_a_room_to_the(direction):
print("You can't go that way.")
elifthere_is_a_monster_here() andnotgoing_back(direction):
print("The monster won't let you pass!", death_by_monster[this_room()])
state="lose"else:
set_room_to_the(direction)
look()
defexits():
good_exits= [
directionfordirectionin ["east", "west", "north", "south"]
ifis_there_a_room_to_the(direction)
]
description="You can go "iflen(good_exits) ==1:
description=description+good_exits[0]
else:
fordirectioningood_exits[0:-1]:
description=description+direction+", "description=description+"or "+good_exits[-1]
returndescription+"."defthere_is_a_monster_here():
returnthis_room() indeath_by_monsterdefthere_is_a_troll_here():
returnthis_room() =="troll"defready_for_monster():
return"sword"inbagor"halbd"inbagdefready_for_troll():
return ("sword"inbagand"stnes"inbag) or"halbd"inbagdefinitialize():
globalbag, statebag= []
initialize_map()
state="playing"defprint_winner():
# Way back before digital images there was ASCII art.line1="\\\\"+" "*4+"/ /"+" "*17+"||"+" "*3+"/ | / /"+" "*13+"//"line2=" \\\\ / / ___"+" "*13+"|| / | / "+"/ () ___"+" "*5+"//"line3= (" \\\\/ / //"+" "*3+")) //"+" "*3+"//"+" "*3+"|| / /||/ "+"/ // //"+" "*3+")) //")
line4= (" "*3+"/ / //"+" "*3+"// //"+" "*3+"//"+" "*4+"||/ / | / "+"// //"+" "*3+"//")
line5= (" "*2+"/ / (("+"_"*3+"// (("+"_"*3+"(("+" "*5+"| / | / /"+"/ //"+" "*3+"// //")
line7=" "*21+"/| "+"_"*16line8=" "*15+"O|"+"="*3+"|* >"+"_"*16+">"line9=" "*21+"\|"ifstate=="win":
print(
"", "", line1, line2, line3, line4, line5,
"", line7, line8, line9,
"", "", "You have won the game.",
sep="\n"
)
else:
print("You lost the game. Maybe next time.")
defwelcome():
print(
"Welcome to my Text Adventure Game. Kill the monsters, survive,",
"and find the Final Prize to win!",
"\n"
)
"""A dictionary that translates a command into a function that needs to be called.To add new commands just add the command's name as a key and a function name as the value."""commands= {
"help": help,
"west": west, "w": west,
"east": east, "e": east,
"south": south, "s": south,
"north": north, "n": north,
"get": get, "g": get,
"fight": fight, "f": fight,
"bag": bag_contents, "b": bag_contents,
"look": look, "l": look,
}
defplay_game():
""" Start up my text adventure game. Uses the console for everything. """initialize()
welcome()
help()
look()
whilestate=="playing":
# Process commands with a dictionary. If the command is in the dictionary# call the value as a function. If not call the default function unknown().commands.get(input("What will you do? "), unknown)()
print_winner()
play_game()
It should be noted that I changed 6.02 to also include using a default with get().
Another thing I like to harp on is testing. I show them how the structure of the program allows for testing. For example I will show them this code:
defplay_game():
""" Start up my text adventure game. Uses the console for everything. """initialize()
welcome()
help()
look()
# read a command from the console and execute it in a loop.play_game()
east()
get()
east()
south()
south()
fight()
west()
get()
west()
south()
south()
south()
east()
south()
south()
east()
south()
south()
west()
west()
get()
east()
east()
south()
look()
It uses the fact that commands are implemented as individual functions to traverse the map. In this case we need to get to a troll to test fighting one.
The text was updated successfully, but these errors were encountered:
Discussed in #382
Originally posted by jdonwells April 23, 2022
As proposed here #349 I am trying out moving the projects around. In this instance the Interactive Fiction (aka text adventure) to Unit 6.
The biggest issue was how much starter code to give. I decided they should need to add about 80 lines of code. 80 lines of code for a project is about what I have been doing at each unit.
My slide show looks like this https://docs.google.com/presentation/d/1zWDXTQdb0qCsqW1NzuNrsYIgXGhBxJGayYmzyvvvdos/edit?usp=sharing
The following days after the introduction a command is discussed. I usually start with the starter code and program it in front of the class. And explain how it works in detail. The code created this way is not shared in any copy paste form. They must watch, listen, ask questions, then replicate the code. The order I used was north(), south(), east(), west() then get() then fight().
Last I go through the loop in play_game(). I show them two ways to do it. The first is the way they already know with a cascading if else. Then I show them how to do it with a dictionary full of functions. Since this unit is about dictionaries it makes sense, but they can still turn in the way they already know.
The starter code looks like this:
You may have noticed a list comprehension used in exits(). I changed 4.04 to be about list comprehensions. #370
One of my students gets very excited about formatted output. I added the ASCII art for her to enjoy.
When I show them the code for fight() I first do it with an extra elif for the troll special case. After it is done I will note some duplicated code and refactor it to the more complex conditional that covers both cases.
While coding, I will explain the idea of writing out code with the assumption that I have functions that already exist like there_is_a_monster_here(). I then code those after the current function is done.
As stated above each day we look at how to program the main functions that do things. The code I generally try to emulate follows:
It should be noted that I changed 6.02 to also include using a default with get().
Another thing I like to harp on is testing. I show them how the structure of the program allows for testing. For example I will show them this code:
It uses the fact that commands are implemented as individual functions to traverse the map. In this case we need to get to a troll to test fighting one.
The text was updated successfully, but these errors were encountered: