-
Notifications
You must be signed in to change notification settings - Fork 0
/
432342001.html
102 lines (89 loc) · 21 KB
/
432342001.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
<!DOCTYPE html>
<html>
<head>
<title>Di Luo : Di Luo's CS231 Project 9</title>
<link rel="stylesheet" href="styles/site.css" type="text/css" />
<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body class="theme-default aui-theme-default">
<div id="page">
<div id="main" class="aui-page-panel">
<div id="main-header">
<div id="breadcrumb-section">
<ol id="breadcrumbs">
<li class="first">
<span><a href="index.html">Di Luo</a></span>
</li>
<li>
<span><a href="413631037.html">Di Luo’s Home</a></span>
</li>
<li>
<span><a href="474513827.html">Di Luo's CS231</a></span>
</li>
</ol>
</div>
<h1 id="title-heading" class="pagetitle">
<span id="title-text">
Di Luo : Di Luo's CS231 Project 9
</span>
</h1>
</div>
<div id="content" class="view">
<div class="page-metadata">
Created by <span class='author'> Di Luo</span>, last modified on May 12, 2019
</div>
<div id="main-content" class="wiki-content group">
<p><u><strong>Description</strong></u></p><p>In this project, I <span style="color: rgb(34,51,68);">used a graph to represent a game map for the game Hunt the Wumpus, a classic RPG with very simple rules. In this game, <span style="color: rgb(34,34,34);">the player moves through a series of connected caves </span><span style="color: rgb(34,34,34);">as they hunt a monster named the Wumpus. The </span>turn-based<span style="color: rgb(34,34,34);"> game has the player trying to avoid meeting the Wumpus and the goal is to fire the only arrow they have through the caves to kill the Wumpus. As the hunter approaches the Wumpus, there will be clues in the room. <span style="color: rgb(34,51,68);">The hunter can fire from one room into an adjacent room where he suspects the Wumpus is hiding. If he fires the arrow correctly, the Wumpus will be slain. If he guesses incorrectly, the Wumpus, alarmed by the sound of the arrow bouncing off the cave wall, will come to eat him.</span></span></span></p><p><span style="color: rgb(34,51,68);"><span style="color: rgb(34,34,34);"><span style="color: rgb(34,51,68);"><br/></span></span></span></p><p><span style="color: rgb(34,51,68);"><span style="color: rgb(34,34,34);"><span style="color: rgb(34,51,68);">To create the game, I used LinkedList class, Agent class, Landscape class from the previous projects, and refined Agent and Landscape classes to make them work for the game. Vertex class, which was implemented in the lab that creates a room in the game, was refined to satisfy the rules of the game. Then I created Hunter class and Wumpus class<span style="color: rgb(34,51,68);"> that </span><span style="color: rgb(34,51,68);">extend</span><span style="color: rgb(34,51,68);"> </span><span style="color: rgb(34,51,68);">Agent</span><span style="color: rgb(34,51,68);"> class</span> to represent the characters of the game. Finally, <span style="color: rgb(34,51,68);">HuntTheWumpus class was implemented according to<span style="color: rgb(34,51,68);"> </span>InteractiveLandscapeDisplay.java, which is the main game controller class. Eventually, the game was successfully implemented.</span></span></span></span></p><p> </p><p><strong><u><span style="color: rgb(34,51,68);">Solution</span></u></strong></p><p>First, I reused the classes from the previews projects, such as Agent, LinkedList, Landscape, and LandscapeDisplay. For Agent class, double fields for x and y positions were changed to int, and other unrelated functions were deleted. For LinkedList class, there was no change. For Landscape class, it was updated that it has a list of foreground agents and a list of back gruond agents, which are both LinkedLists. The job of Landscape is to store the agents and to draw them. Also unrelated functions were deleted.</p><p> </p><p>Then I updated Vertex class, which implements a room in the game. After the update, the draw method can indicate several identities of the room: possible exits, whether the Wumpus is two rooms away or closer, and etc. </p><p> </p><p>Next, I created two new classes that extend Agent class: Hunter and Wumpus, which represents the hunter and the wumpus in the game respectively. <span style="color: rgb(34,51,68);">The Hunter is always visible on the map, while <span style="color: rgb(34,51,68);">in the default game the Wumpus is not visible initially. The Wumpus is visible only if it is killed by the Hunter or it eats the Hunter. I used some pictures to represent the two characters in different situation, which is shown below:</span></span></p><p><span style="color: rgb(34,51,68);"><span style="color: rgb(34,51,68);">When Hunter is alive:</span></span></p><p><span style="color: rgb(34,51,68);"><span style="color: rgb(34,51,68);"><span class="confluence-embedded-file-wrapper"><img class="confluence-embedded-image" draggable="false" src="attachments/432342001/432309018.jpg" data-image-src="attachments/432342001/432309018.jpg" data-unresolved-comment-count="0" data-linked-resource-id="432309018" data-linked-resource-version="1" data-linked-resource-type="attachment" data-linked-resource-default-alias="HunterNotLoaded.jpg" data-base-url="https://wiki.colby.edu" data-linked-resource-content-type="image/jpeg" data-linked-resource-container-id="432342001" data-linked-resource-container-version="5"></span></span></span></p><p><span style="color: rgb(34,51,68);"><span style="color: rgb(34,51,68);">When Hunter is aiming:</span></span></p><p><span style="color: rgb(34,51,68);"><span style="color: rgb(34,51,68);"><span class="confluence-embedded-file-wrapper"><img class="confluence-embedded-image" draggable="false" src="attachments/432342001/432309019.jpg" data-image-src="attachments/432342001/432309019.jpg" data-unresolved-comment-count="0" data-linked-resource-id="432309019" data-linked-resource-version="1" data-linked-resource-type="attachment" data-linked-resource-default-alias="HunterLoaded.jpg" data-base-url="https://wiki.colby.edu" data-linked-resource-content-type="image/jpeg" data-linked-resource-container-id="432342001" data-linked-resource-container-version="5"></span></span></span></p><p><span style="color: rgb(34,51,68);"><span style="color: rgb(34,51,68);">When Wumpus is alive because the hunter fails:</span></span></p><p><span style="color: rgb(34,51,68);"><span style="color: rgb(34,51,68);"><span class="confluence-embedded-file-wrapper"><img class="confluence-embedded-image" draggable="false" src="attachments/432342001/432309020.jpg" data-image-src="attachments/432342001/432309020.jpg" data-unresolved-comment-count="0" data-linked-resource-id="432309020" data-linked-resource-version="1" data-linked-resource-type="attachment" data-linked-resource-default-alias="MonsterAlive.jpg" data-base-url="https://wiki.colby.edu" data-linked-resource-content-type="image/jpeg" data-linked-resource-container-id="432342001" data-linked-resource-container-version="5"></span></span></span></p><p><span style="color: rgb(34,51,68);"><span style="color: rgb(34,51,68);">When Wumpus is dead, killed by the hunter:</span></span></p><p><span style="color: rgb(34,51,68);"><span class="confluence-embedded-file-wrapper"><img class="confluence-embedded-image" draggable="false" src="attachments/432342001/432309021.jpg" data-image-src="attachments/432342001/432309021.jpg" data-unresolved-comment-count="0" data-linked-resource-id="432309021" data-linked-resource-version="1" data-linked-resource-type="attachment" data-linked-resource-default-alias="deadMonster.jpg" data-base-url="https://wiki.colby.edu" data-linked-resource-content-type="image/jpeg" data-linked-resource-container-id="432342001" data-linked-resource-container-version="5"></span></span></p><p><span style="color: rgb(34,51,68);"><br/></span></p><p><span style="color: rgb(34,51,68);">Finally, I created <span style="color: rgb(34,51,68);">HuntTheWumpus class according to</span><span style="color: rgb(34,51,68);"> </span><span style="color: rgb(34,51,68);">InteractiveLandscapeDisplay.java, which is the main game controller class. <span style="color: rgb(34,51,68);">The constructor builds the graph, inserts the vertices, Hunter, and Wumpus into the Landscape, and adds any other user interface elements. It was enabled to add a KeyListener and an ActionListener to the display to listen for keystrokes and clicks. "a" was used as moving or shooting to the west, "w" <span style="color: rgb(34,51,68);">was used </span>as moving or shooting to the north, "s" <span style="color: rgb(34,51,68);">was used </span>as moving or shooting to the south, "d" <span style="color: rgb(34,51,68);">was used </span>as moving or shooting to the east, and space <span style="color: rgb(34,51,68);">was used </span>as changing the hunter's status. The first hit on the space will change the hunter from unloaded status to the loaded status, in which the hunter is unable to move. The second hit of space key will unload the hunter and enable the hunter to move. Then I tried the game with HuntTheWumpus class and a simulation is shown below, which successfully worked:</span></span></span></p><p><span class="confluence-embedded-file-wrapper confluence-embedded-manual-size"><img class="confluence-embedded-image" draggable="false" width="300" src="attachments/432342001/432309085.gif" data-image-src="attachments/432342001/432309085.gif" data-unresolved-comment-count="0" data-linked-resource-id="432309085" data-linked-resource-version="1" data-linked-resource-type="attachment" data-linked-resource-default-alias="ezgif.com-gif-maker-2.gif" data-base-url="https://wiki.colby.edu" data-linked-resource-content-type="image/gif" data-linked-resource-container-id="432342001" data-linked-resource-container-version="5"></span></p><p><span style="color: rgb(34,51,68);"><span style="color: rgb(34,51,68);"><span style="color: rgb(34,51,68);"><br/></span></span></span></p><p><strong><u><span style="color: rgb(34,51,68);">Extension</span></u></strong></p><p><span style="color: rgb(34,51,68);">Extension 1:</span></p><p><span style="color: rgb(34,51,68);"><span>I changed the constructor of Landscape so that the edges between vertexes appear more randomly and the map becomes more complex. A snippet of code is shown below:</span></span></p><p><span style="color: rgb(34,51,68);"><span><span class="confluence-embedded-file-wrapper confluence-embedded-manual-size"><img class="confluence-embedded-image" draggable="false" width="300" src="attachments/432342001/432309088.png" data-image-src="attachments/432342001/432309088.png" data-unresolved-comment-count="0" data-linked-resource-id="432309088" data-linked-resource-version="1" data-linked-resource-type="attachment" data-linked-resource-default-alias="Screen Shot 2019-05-11 at 8.05.05 PM.png" data-base-url="https://wiki.colby.edu" data-linked-resource-content-type="image/png" data-linked-resource-container-id="432342001" data-linked-resource-container-version="5"></span>.</span></span></p><p><span style="color: rgb(34,51,68);"><span>The game then looks like:</span></span></p><p><span style="color: rgb(34,51,68);"><span><span class="confluence-embedded-file-wrapper confluence-embedded-manual-size"><img class="confluence-embedded-image" draggable="false" width="300" src="attachments/432342001/432309030.gif" data-image-src="attachments/432342001/432309030.gif" data-unresolved-comment-count="0" data-linked-resource-id="432309030" data-linked-resource-version="3" data-linked-resource-type="attachment" data-linked-resource-default-alias="ezgif.com-gif-maker.gif" data-base-url="https://wiki.colby.edu" data-linked-resource-content-type="image/gif" data-linked-resource-container-id="432342001" data-linked-resource-container-version="5"></span>.</span></span></p><p><span style="color: rgb(34,51,68);"><br/></span></p><p><span style="color: rgb(34,51,68);">Extension 2:</span></p><p><span style="color: rgb(34,51,68);">I added a "restart" button so that users can use it to restart and play the new game. The gameplay with the restart button and the snippets are shown below.</span></p><p><span style="color: rgb(34,51,68);"><span class="confluence-embedded-file-wrapper confluence-embedded-manual-size"><img class="confluence-embedded-image" draggable="false" width="300" src="attachments/432342001/432309090.png" data-image-src="attachments/432342001/432309090.png" data-unresolved-comment-count="0" data-linked-resource-id="432309090" data-linked-resource-version="1" data-linked-resource-type="attachment" data-linked-resource-default-alias="Screen Shot 2019-05-11 at 8.06.02 PM.png" data-base-url="https://wiki.colby.edu" data-linked-resource-content-type="image/png" data-linked-resource-container-id="432342001" data-linked-resource-container-version="5"></span></span></p><p><span style="color: rgb(34,51,68);"><span class="confluence-embedded-file-wrapper confluence-embedded-manual-size"><img class="confluence-embedded-image" draggable="false" width="300" src="attachments/432342001/432309091.png" data-image-src="attachments/432342001/432309091.png" data-unresolved-comment-count="0" data-linked-resource-id="432309091" data-linked-resource-version="1" data-linked-resource-type="attachment" data-linked-resource-default-alias="Screen Shot 2019-05-11 at 8.05.53 PM.png" data-base-url="https://wiki.colby.edu" data-linked-resource-content-type="image/png" data-linked-resource-container-id="432342001" data-linked-resource-container-version="5"></span></span></p><p><span style="color: rgb(34,51,68);"><span class="confluence-embedded-file-wrapper confluence-embedded-manual-size"><img class="confluence-embedded-image" draggable="false" width="300" src="attachments/432342001/432309030.gif" data-image-src="attachments/432342001/432309030.gif" data-unresolved-comment-count="0" data-linked-resource-id="432309030" data-linked-resource-version="3" data-linked-resource-type="attachment" data-linked-resource-default-alias="ezgif.com-gif-maker.gif" data-base-url="https://wiki.colby.edu" data-linked-resource-content-type="image/gif" data-linked-resource-container-id="432342001" data-linked-resource-container-version="5"></span></span></p><p><span style="color: rgb(34,51,68);"><br/></span></p><p><span style="color: rgb(34,51,68);">Extension 3:</span></p><p><span style="color: rgb(34,51,68);">I used different pictures to make the visualization more interesting. Besides, when the hunter shoots to the wrong direction, the Wumpus will do some zig-zag movements.</span></p><p><span style="color: rgb(34,51,68);"><br/></span></p><p><strong><u><span style="color: rgb(34,51,68);">Reflection</span></u></strong></p><p><span style="color: rgb(34,51,68);">In this project I learned how to implement a graph consisted of vertexes and edges, and use the graph to create an actual game. The project gives me a chance to see deeper on how a game runs on the computer. Besides, while creating the game, different data structures were implemented to make the game work. In general, I think this project is a nice conclusion on what I have learned in the course CS231 and how to use them in real-life situation. </span></p><p><span style="color: rgb(34,51,68);"><br/></span></p><p><strong><u><span style="color: rgb(34,51,68);">Source</span></u></strong></p><p><span style="color: rgb(34,51,68);">Thanks to Sihang Chen!</span></p><p><span style="color: rgb(34,51,68);"><a href="https://en.wikipedia.org/wiki/Hunt_the_Wumpus" class="external-link" rel="nofollow">https://en.wikipedia.org/wiki/Hunt_the_Wumpus</a></span></p><p><a href="https://en.wikipedia.org/wiki/Ranger_(character_class)" class="external-link" rel="nofollow">https://en.wikipedia.org/wiki/Ranger_(character_class)</a><br/><a href="https://pixabay.com/illustrations/hunter-man-fantasy-pose-isolated-1443648/" class="external-link" rel="nofollow">https://pixabay.com/illustrations/hunter-man-fantasy-pose-isolated-1443648/</a><br/><a href="https://bobandsuewilliams.com/image/monster/799547.html" class="external-link" rel="nofollow">https://bobandsuewilliams.com/image/monster/799547.html</a><br/><a href="https://www.vectorstock.com/royalty-free-vector/a-dead-greenslime-monster-vector-1534928" class="external-link" rel="nofollow">https://www.vectorstock.com/royalty-free-vector/a-dead-greenslime-monster-vector-1534928</a></p>
</div>
<div class="pageSection group">
<div class="pageSectionHeader">
<h2 id="attachments" class="pageSectionTitle">Attachments:</h2>
</div>
<div class="greybox" align="left">
<img src="images/icons/bullet_blue.gif" height="8" width="8" alt=""/>
<a href="attachments/432342001/432309018.jpg">HunterNotLoaded.jpg</a> (image/jpeg)
<br/>
<img src="images/icons/bullet_blue.gif" height="8" width="8" alt=""/>
<a href="attachments/432342001/432309019.jpg">HunterLoaded.jpg</a> (image/jpeg)
<br/>
<img src="images/icons/bullet_blue.gif" height="8" width="8" alt=""/>
<a href="attachments/432342001/432309020.jpg">MonsterAlive.jpg</a> (image/jpeg)
<br/>
<img src="images/icons/bullet_blue.gif" height="8" width="8" alt=""/>
<a href="attachments/432342001/432309021.jpg">deadMonster.jpg</a> (image/jpeg)
<br/>
<img src="images/icons/bullet_blue.gif" height="8" width="8" alt=""/>
<a href="attachments/432342001/432309028.gif">firsttry.gif</a> (image/gif)
<br/>
<img src="images/icons/bullet_blue.gif" height="8" width="8" alt=""/>
<a href="attachments/432342001/432309089.gif">ezgif.com-gif-maker.gif</a> (image/gif)
<br/>
<img src="images/icons/bullet_blue.gif" height="8" width="8" alt=""/>
<a href="attachments/432342001/432309085.gif">ezgif.com-gif-maker-2.gif</a> (image/gif)
<br/>
<img src="images/icons/bullet_blue.gif" height="8" width="8" alt=""/>
<a href="attachments/432342001/432309088.png">Screen Shot 2019-05-11 at 8.05.05 PM.png</a> (image/png)
<br/>
<img src="images/icons/bullet_blue.gif" height="8" width="8" alt=""/>
<a href="attachments/432342001/432309095.gif">ezgif.com-gif-maker.gif</a> (image/gif)
<br/>
<img src="images/icons/bullet_blue.gif" height="8" width="8" alt=""/>
<a href="attachments/432342001/432309090.png">Screen Shot 2019-05-11 at 8.06.02 PM.png</a> (image/png)
<br/>
<img src="images/icons/bullet_blue.gif" height="8" width="8" alt=""/>
<a href="attachments/432342001/432309091.png">Screen Shot 2019-05-11 at 8.05.53 PM.png</a> (image/png)
<br/>
<img src="images/icons/bullet_blue.gif" height="8" width="8" alt=""/>
<a href="attachments/432342001/432309030.gif">ezgif.com-gif-maker.gif</a> (image/gif)
<br/>
</div>
</div>
</div> </div>
<div id="footer" role="contentinfo">
<section class="footer-body">
<p>Document generated by Confluence on Aug 29, 2022 09:29</p>
<div id="footer-logo"><a href="http://www.atlassian.com/">Atlassian</a></div>
</section>
</div>
</div> </body>
</html>