QuestionThis is the questions, i have tried to implement this, but i am stuck. Can someone provide me with the solution?Adventure: itemsNow that you are sure the game is playable using the Tiny and Small maps, let’s implement the remaining feature needed to be able to play the Crowther map as well. As seen above, the data file contains descriptions for items that are placed in the game (each in a specific room) and then picked up, taken along, and dropped again by the player. The Crowther game is designed in a way that some routes can only be taken when the player is carrying certain items.Items that are lying around in a room should look like this:You are inside a building, a well house for a large spring.KEYS: a set of keysPicking up items should work like this:You are inside a building, a well house for a large spring.KEYS: a set of keys> TAKE KEYSKEYS taken.> TAKE KEYSNo such item.> TAKE SOMETHINGNo such item.>Putting down items should work like this:You are inside a building, a well house for a large spring.KEYS: a set of keys> TAKE KEYSKEYS taken.> DROP KEYSKEYS dropped.> DROP KEYSNo such item.> TAKE KEYSKEYS taken.ImplementationImplement a new Item class that represents items within the game. Place it in its own file item.py.Add an attribute to store Item objects in each Room. And, because a items can be picked up and held by the player, you should also create an attribute in the Adventure class to contain Item objects (what kind of variable would be appropriate for that?).Then make sure items are loaded from the data file and place into the correct initial rooms after loading.And finally, implement user interface code for items, in particular the TAKE and DROP commands. Do note that you should always call methods on the Adventure class to do these actions! Do not directly manipulate elements (variables) from that class or from other classes.And to test, don’t forget to load the Crowther map:$ python3 adventure.py Crowthermy loader.py:from room import Room# from room import connectionsdef load_room_graph(filename): count = 0 rooms = {} with open(filename) as tiny_file: for line in tiny_file: strip = line.strip(“n”) read = strip.split(“t”) if read == [“”]: count+=1 continue if count == 0: room_obj = Room(read[0], read[1], read[2]) rooms[int(read[0])] = room_obj if count == 1: strip = line.strip(“n”) read = strip.split(“t”) source_room = rooms[int(read[0])] for i in range(0, len(read) – 2, 2): direction = read[0] destination_room = rooms[int(read[i + 2])] source_room.add_connection(read[i + 1], destination_room) if count == 2: strip = line.strip(“n”) read = strip.split(“t”) source_room_items = rooms[int(read[2])] for i in range(0, len(read) – 2, 2): item = read[0] description = read[1] source_room_items.add_connection(read[2], source_room_items) # print(rooms[2]._connections) # assert rooms[1].has_connection(“WEST”) # assert rooms[2].get_connection(“EAST”)._short_description == “Outside building” return roomsmy item.py:class Items: def __init__(self, item, short_description): self._item = item self._short_description = short_description self._items = {} def items_take(self, item, short_description): if item in self._items: return items return short_description return False def items_drop(self, item): if item in self._items: return Falsemy adventure.py:import loaderfrom room import Roomfrom item import Itemsclass Adventure(): # Create rooms and items for the game that was specified at the command line def __init__(self, filename): self._current_room = loader.load_room_graph(filename)[1] # Pass along the description of the current room, be it short or long def room_description(self): return self._current_room.description() # Move to a different room by changing “current” room, if possible def move(self, direction): if self._current_room == self._current_room.has_connection(direction): return self._current_room.has_connection(direction) else: next_room = self._current_room.get_connection(direction) return next_room def items_take(self, item, description): if item in self._items: return items return short_description return Falseif __name__ == “__main__”: from sys import argv # Check command line arguments if len(argv) not in [1,2]: print(“Usage: python3 adventure.py [name]”) exit(1) # Load the requested game or else Tiny print(“Loading…”) if len(argv) == 2: game_name = argv[1] elif len(argv) == 1: game_name = “Tiny” filename = f”data/{game_name}Adv.dat” # Create game adventure = Adventure(filename) # Welcome user print(“Welcome to Adventure.n”) # Print very first room description print(adventure.room_description()) # print(adventure._current_room._connections) # Prompt the user for commands until they type QUIT while True: # Prompt, converting all input to upper case command = input(“> “).upper() # Perform the move or other command if adventure.move(command): adventure._current_room = adventure._current_room.get_connection(command) print(adventure.room_description()) else: print(“Invalid command”) # Perform the take item command if adventure.items_take(command, description): print(adventure.room_short_description) else: print(“Invalid command”) # Allows player to exit the game loop if command == “QUIT”: breakmy room.py:class Room: def __init__(self, number, short_description, long_description): self._number = number self._short_description = short_description self._long_description = long_description self._visited = False self._connections = {} # accepts a direction and a room object, and saves it in the connection storage def add_connection(self, direction, room): # saves it in the connection storage self._connections[direction] = room # can determine if there is a connection available from the room to another room, given the direction def has_connection(self, direction): if direction in self._connections: return True return False # retrieves the actual Room object that is found given a specific direction def get_connection(self, direction): if direction in self._connections: return self._connections[direction] if ‘FORCED’ in self._connections: next_room = self.get_connection(‘FORCED’) def set_visited(self): self._visited = True def description(self): # if visited show short description if self._visited == True and direction == ‘FORCED’: return self._long_description if self._visited == True: return self._short_description return self._long_descriptionmy cowtheAdv.dat:1 Outside building You are standing at the end of a road before a small brick building. A small stream flows out of the building and down a gully to the south. A road runs up a small hill to the west.2 End of road You are at the end of a road at the top of a small hill. You can see a small building in the valley to the east.3 Inside building You are inside a building, a well house for a large spring. The exit door is to the south. There is another room to the north, but the door is barred by a shimmering curtain.4 Valley beside a stream You are in a valley in the forest beside a stream tumbling along a rocky bed. The stream is flowing to the south.5 Slit in rock At your feet all the water of the stream splashes into a two-inch slit in the rock. To the south, the streambed is bare rock.6 Outside grate You are in a 20-foot depression floored with bare dirt. Set into the dirt is a strong steel grate mounted in concrete. A dry streambed leads into the depression from the north.7 Above locked grate The grate is locked and you don’t have any keys.8 Beneath grate You are in a small chamber beneath a 3×3 steel grate to the surface. A low crawl over cobbles leads inward to the west.9 Cobble crawl You are crawling over cobbles in a low east/west passage. There is a dim light to the east.10 Darkness It is now pitch dark. If you proceed you will likely fall into a pit.11 Pit You fell into a pit and broke every bone in your body!12 Debris room You are in a debris room filled with stuff washed in from the surface. A low wide passage with cobbles becomes plugged with mud and debris here, but an extremely narrow canyon leads upward and west. Carved on the wall is the message: “Magic Word XYZZY”.13 Sloping canyon You are in an awkward sloping east/west canyon.14 Chamber of orange stone You are in a splendid chamber thirty feet high. The walls are frozen rivers of orange stone. A narrow canyon and a good passage exit from east and west sides of the chamber.15 Chamber of orange stone You are in a splendid chamber thirty feet high. The walls are frozen rivers of orange stone. A narrow canyon and a good passage exit from east and west sides of the chamber. High in the cavern, you see a little bird flying around the rocks. It takes one look at the black rod and quickly flies out of sight.16 Top of pit At your feet is a small pit breathing traces of white mist. An east passage ends here except for a small crack leading on. Rough stone steps lead into the pit.17 Narrow crack The crack is far too small for you to follow.18 Hall of mists You are at one end of a vast hall stretching forward out of sight to the west. The hall is filled with wisps of white mist swaying to and fro almost as if alive. There are passages to the north and south, and a stone stairway leads upward.19 Nugget of gold room This is a low room with a crude note on the wall. The note says, “You won’t get it up the steps.”20 Unseen force An unseen force blocks your way and a ghostly voice echoes: “You won’t get it up the steps.”21 East bank of fissure You are on the east bank of a fissure slicing clear across the hall. The mist is quite thick here.22 Blocked by fissure The fissure looks too wide to cross.23 Wave Rod (bug: doesn’t check object) You don’t have the appropriate thing to wave.24 Crystal bridge crossing fissure As you wave the rod, a cascade of crystalline sparks issues from its tip which gain shape and substance over the chasm. In moments, a shimmering crystal bridge spans the fissure. After you cross, the bridge fades into nothingness.25 West bank of fissure You are on the west side of the fissure in the Hall of Mists.26 Blocked by fissure The fissure looks too wide to cross.27 Wave Rod (bug: doesn’t check object) You don’t have the appropriate thing to wave.28 Crystal bridge crossing fissure As you wave the rod, a cascade of crystalline sparks issues from its tip which gain shape and substance over the chasm. In moments, a shimmering crystal bridge spans the fissure. After you cross, the bridge fades into nothingness.29 Fatal jump You make a mighty leap but fall several feet short of the far side. You make a few mad scrambles at the air as you fall to your death on the rocks below.30 West end of the Hall of Mists You are at the west end of Hall of Mists. A low wide crawl exits north. To the south is a little passage six feet off the floor that seems to twist sharply.31 You are in a maze of twisty little passages, all alike. You are in a maze of twisty little passages, all alike.32 You are in a maze of twisty little passages, all alike. You are in a maze of twisty little passages, all alike.33 You are in a maze of twisty little passages, all alike. You are in a maze of twisty little passages, all alike.34 You are in a maze of twisty little passages, all alike. You are in a maze of twisty little passages, all alike.35 You are in a maze of twisty little passages, all alike. You are in a maze of twisty little passages, all alike.36 You are in a maze of twisty little passages, all alike. You are in a maze of twisty little passages, all alike.37 You are in a maze of twisty little passages, all alike. You are in a maze of twisty little passages, all alike.38 Pirate’s lair You’re in the pirate’s lair deep in the maze. The only exit is south.39 Brink of pit in the maze You are on the brink of a thirty-foot pit with a massive orange column down one wall. You could climb down here but you could not get back up. The maze continues at this level.40 Hall of the Mountain King You are in the Hall of the Mountain King, with passages off in several directions. A fierce green snake bars your way.41 Blocked by snake You can’t get by the snake.42 Bird attacks snake As you enter the chamber, you see a fierce green snake. Before you can think, the little bird flies from your shoulder, attacks the green snake, and in an astounding flurry drives the snake away. The bird then flies back.43 Hall of the Mountain King You are in the Hall of the Mountain King, with passages off in several directions.44 West side chamber You are in the West Side Chamber of the Hall of the Mountain King. A passage continues west and up here.45 East side chamber You are in the East Side Chamber of the Hall of the Mountain King.46 Long curving passage You are in a long passageway that curves from the east to the south.47 Low N/S passage You are in a low N/S passage with a hole in the floor.48 You’re at “Y2” You are in a large room, with a passage to the south, a passage to the west, and a wall of broken rock to the east. There is a large “Y2” on a rock in the room’s center. As you enter, a hollow voice says “PLUGH”.49 Window on pit You’re at a low window overlooking a huge pit, which extends up out of sight. A floor is indistinctly visible over 50 feet below. Traces of white mist cover the floor of the pit, becoming thicker to the left. Marks in the dust around the window would seem to indicate that someone has been here recently. Directly across the pit from you and 25 feet away there is a similar window in the wall of the pit. You see a shadowy figure in the other window.50 Figure waves back The figure waves back. In fact, it seems to be following your actions.51 Too heavy As you utter the magic word, your surroundings begin to fade in and out. After a protracted struggle, you hear a hollow voice say, “It’s just too heavy.”52 Broken rock You wander around in the broken rock but don’t find anything interesting.53 E/W passage You are in an E/W passage. There is a hole in the ceiling above that appears to open into a passage.54 Green chamber You’re in a small chamber lit by an eerie green light that seems to emanate from an extremely narrow crack to the north. A dark corridor leads west.55 Emerald room You’re in a small chamber whose walls are studded with glowing green gemstones. A narrow crack leads south.56 Too narrow for crack Something you’re carrying won’t fit through the crack.57 Darkness It is now pitch dark. If you proceed you will likely fall into a pit.58 East end of Twopit Room You are at the east end of the Twopit Room. The floor here is littered with thin rock slabs, which make it easy to descend the pits. There is a path here bypassing the pits to connect passages from east and west. There are holes all over, but the only big one is in the roof directly over the west pit where you can’t get to it.59 West end of Twopit Room You are at the west end of the Twopit Room. There is a large hole above the pit at this end of the room.60 East pit You are at the bottom of the eastern pit in the Twopit Room.61 West pit You are at the bottom of the western pit in the Twopit Room underneath a large hole in the ceiling.62 Plant is already picked (bug: might be elsewhere) You can’t water the plant after you’ve picked it. You might try replanting it.63 Beanstalk As you water the plant, it bursts into violent growth, quickly filling the entire pit and pushing you upward toward the hole in ceiling. You scramble for your life and manage to catch hold of the rock and pull yourself to safety. The plant then shrinks away as quickly as it grew.64 Giant room You are in the Giant Room. The ceiling here is too high up for your lamp to show it. A cavernous passage leads north. There is a hole in the floor through which you can see the Twopit room far below.65 Too big a drop Without the plant, it’s far too large a drop.66 Whirlpool You are in a magnificent cavern with a rushing stream, which cascades over a sparkling waterfall into a roaring whirlpool that disappears through a hole in the floor. A passage exits to the south.67 ThroughWhirlpool You are dragged down, down, into the depths of the whirlpool. Just as you can no longer hold your breath, you are shot out over a waterfall into the shallow end of a large reservoir. Gasping and sputtering, you crawl weakly towards the shore.68 Underground lake You are at the edge of a large underground reservoir. An opaque cloud of white mist fills the room and rises rapidly upward. The lake is fed by a stream, which tumbles out of a hole in the wall about ten feet overhead and splashes noisily into the water somewhere within the mist. The only exit is to the south.69 Mirror room You are in a circular chamber about 25 feet across. The floor is covered by white mist seeping in from the north. The walls extend upward for well over 100 feet. Suspended from some unseen point far above you, an enormous two-sided mirror is hanging parallel to and midway between the canyon walls. A small window can be seen in the wall some fifty feet up. The canyon has exits to the north and east.70 Curtain1 A closed curtain. Only passable with the NUGGET.71 Curtain2 A closed curtain. Only passable with the DIAMOND.72 Curtain3 A closed curtain. Only passable with the EMERALD.73 Curtain4 A closed curtain. Only passable with the EGGS.74 Curtain5 A closed curtain. Only passable with the CHEST.75 Curtain6 A closed curtain. Only passable with the COINS.76 Missing Treasures You can pass through this curtain only if you’re carrying all the treasures. You don’t yet have all six.77 Victory You have collected all the treasures and are admitted to the Adventurer’s Hall of Fame. Congratulations!1 WEST 2 UP 2 NORTH 3 IN 3 SOUTH 4 DOWN 42 EAST 1 DOWN 13 SOUTH 1 OUT 1 NORTH 70 XYZZY 12/LAMP XYZZY 10 PLUGH 48/LAMP PLUGH 104 NORTH 1 UP 1 SOUTH 5 DOWN 55 NORTH 4 UP 4 SOUTH 6 DOWN 66 NORTH 5 UP 5 DOWN 8/KEYS DOWN 77 FORCED 68 UP 6 OUT 6 IN 9 WEST 99 EAST 8 WEST 12/LAMP WEST 1010 EAST 9 OUT 9 XYZZY 3 PLUGH 3 NORTH 11 SOUTH 11 WEST 11 UP 11 DOWN 1112 EAST 9 WEST 13 UP 13 XYZZY 313 EAST 12 DOWN 12 WEST 14/BIRD WEST 15/ROD WEST 14 UP 14/BIRD UP 15/ROD UP 1414 EAST 13 WEST 1615 EAST 13 WEST 1616 EAST 14/BIRD EAST 15/ROD EAST 14 WEST 17 DOWN 1817 FORCED 1618 UP 20/NUGGET UP 16 WEST 21 SOUTH 19 NORTH 42/BIRD NORTH 4019 NORTH 18 OUT 1820 FORCED 1821 EAST 18 WAVE 24/ROD WAVE 23 WEST 22 JUMP 2922 FORCED 2123 FORCED 2124 FORCED 2525 WEST 30 WAVE 28/ROD WAVE 27 EAST 26 JUMP 2926 FORCED 2527 FORCED 2528 FORCED 2130 EAST 25 NORTH 46 SOUTH 3131 WEST 30 NORTH 32 SOUTH 3332 NORTH 34 EAST 31 WEST 3533 NORTH 35 EAST 36 WEST 3134 SOUTH 36 WEST 32 EAST 3935 SOUTH 32 WEST 3336 EAST 33 WEST 34 NORTH 3737 NORTH 38 SOUTH 36 WEST 3938 SOUTH 37 OUT 3739 EAST 37 WEST 34 DOWN 14/BIRD DOWN 15/ROD DOWN 1440 SOUTH 18 NORTH 41 EAST 41 WEST 4141 FORCED 4042 FORCED 4343 SOUTH 18 NORTH 47 WEST 44 EAST 4544 EAST 43 WEST 46 UP 4645 WEST 43 OUT 4346 EAST 44 SOUTH 3047 NORTH 48 SOUTH 43 DOWN 5348 SOUTH 47 PLUGH 51/NUGGET PLUGH 3 EAST 52 WEST 4949 EAST 48 OUT 48 WAVE 5050 FORCED 4951 FORCED 4852 FORCED 4853 UP 47 WEST 58 EAST 5454 WEST 53/LAMP WEST 57 NORTH 56/LAMP NORTH 56/BIRD NORTH 56/NUGGET NORTH 56/COINS NORTH 5555 SOUTH 54 OUT 5456 FORCED 5457 EAST 5458 EAST 53 WEST 59 DOWN 6059 EAST 58 WEST 69 DOWN 6160 UP 5861 UP 59 WATER 62/PLANT WATER 6362 FORCED 6163 FORCED 6464 NORTH 66 DOWN 6565 FORCED 6466 SOUTH 64 DOWN 67 SWIM 6767 FORCED 6868 SOUTH 69 OUT 6969 NORTH 68 EAST 5970 FORCED 71/NUGGET FORCED 7671 FORCED 72/DIAMOND FORCED 7672 FORCED 73/EMERALD FORCED 7673 FORCED 74/EGGS FORCED 7674 FORCED 75/CHEST FORCED 7675 FORCED 77/COINS FORCED 7676 FORCED 3KEYS a set of keys 3LAMP a brightly shining brass lamp 8ROD a black rod with a rusty star 12BIRD a little bird 14NUGGET a nugget of gold 19DIAMOND a sparkling diamond 25COINS a bag of coins 45EMERALD an emerald the size of a plover’s egg 55EGGS a nest of golden eggs 64WATER a bottle of water 3PLANT a small plant murmuring “Water, water” 61CHEST a pirate chest 38Note: the forced movement doesnt work yetComputer ScienceEngineering & TechnologyPython ProgrammingIMOP 50826YShare Question
solved : QuestionThis is the questions, i have tried to implement thi
How it works
- Paste your instructions in the instructions box. You can also attach an instructions file
- Select the writer category, deadline, education level and review the instructionsÂ
- Make a payment for the order to be assigned to a writer
- Â Download the paper after the writer uploads itÂ
Will the writer plagiarize my essay?
You will get a plagiarism-free paper and you can get an originality report upon request.
Is this service safe?
All the personal information is confidential and we have 100% safe payment methods. We also guarantee good grades
LET THE PROFESSIONALS WRITE YOUR PAPER!