Skip to end of metadata
Go to start of metadata

Abstract

This project tasked us with implementing a graph in Java. A graph is essentially a collection of nodes with pathways between the nodes. This would allow us to create a graphical user interface where there are different rooms, node/vertex, and doors, edges/paths. I implemented my graph by having each vertex be comprised of an array that stored its four neighboring vertices in an Array. We are to control a hunter using key controls who can go from vertex to vertex if an edge exists between. The hunter has a single arrow which if it shoots in the direction of the wumpus will kill it. However, if it misses or lands on the Wumpus it will die and lose. My hunter had short term memory loss and could not remember the layout of the cave, but could smell the wumpus if it was within two rooms.

Solution

The wumpus and hunter were fairly simple, as they were extensions off of the Vertex. The challenging part was coding the hunter to move and shoot arrows. This led to having to form keychar binds that would move the character or shoot the character based on its armed status. The armed status was set similarly, by binding the space bar to switch the armed boolean from true to false or vice versa.

My graph was an ArrayList of Vertices and the shortest path from the hunter to the wumpus was calculated by Dijkstra's algorithm. If the shortest value from the hunter to the wumpus would reach 2 edges, then the hunter's room would change to the color red. This would indicate that the hunter smelled the wumpus.

Printouts

Killed Wumpus

KilledWumpus.mov

Arrow Missed

ArrowMissed.mov

Killed by Wumpus

KilledbyWumpus.mov

Conclusion

While this project was built upon the implementation of a graph, I feel as if I learned just as much about creating an interface. The most challenging part of the project was coming up with a means to bind the movement of the hunter to characters on the keyboard. This was outside the direct realm of data structures and algorithms, but a really interesting and visual thing to learn.

Acknowledgment

Deka Popov

Labels