Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added images/capstone-admin-page.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions posts/post/post-capstone/post-capstone.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
</header>

<script>
const GH_API_URL = 'https://api.github.com/repos/riceriley59/CS-162/issues/1/comments';
const GH_API_URL = 'https://api.github.com/repos/riceriley59/HackByte/issues/10/comments';

let request = new XMLHttpRequest();
request.open('GET', GH_API_URL, true);
Expand Down Expand Up @@ -88,7 +88,7 @@
request.send();
</script>
<article>
<h1>Oregon State Senior Capstone Project - Fuel Kiosk</h1>
<h1>Oregon State Senior Capstone - Fuel Kiosk</h1>
<p><br>
Hunt the Wumpus is a cave CLI game that I made for a university assignment. The concept is very simple you are in square grid, the cave, in which you get to choose the size. You have to shoot
the Wumpus with an arrow, find the gold, and then escape exactly where you came in from. There is also other dangerous events in the cave such as bottomless pits and bat caves filled with bats. If
Expand Down Expand Up @@ -255,7 +255,7 @@ <h1>Oregon State Senior Capstone Project - Fuel Kiosk</h1>
<ul id="gh-comments-list"></ul>
<p id="no-comments-found">No comments found for this article.</p>
<p id="leave-a-comment">This will take you to Github where you can then write, and post, your comment (it will show up on the page within an hour).
You will need a Github account to comment.<br><br><button onclick="window.location.href='https://github.com/riceriley59/CS-162/issues/1';">Leave a comment</button></p>
You will need a Github account to comment.<br><br><button onclick="window.location.href='https://github.com/riceriley59/HackByte/issues/10';">Leave a comment</button></p>
</div>

<div class="trademark"><p>Riley Rice - 2022</p></div>
Expand Down
74 changes: 37 additions & 37 deletions posts/post/post-huntthewumpus/post-huntthewumpus.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@300&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@300&display=swap" rel="stylesheet">
<link rel="stylesheet" href="post-huntthewumpus.css">
<link rel="stylesheet" href="../../../transitions.css">
<link rel="stylesheet" href="../../prism.css">
Expand Down Expand Up @@ -34,37 +34,37 @@
</header>

<script>
const GH_API_URL = 'https://api.github.com/repos/riceriley59/CS-162/issues/1/comments';
const GH_API_URL = 'https://api.github.com/repos/riceriley59/HackByte/issues/9/comments';

let request = new XMLHttpRequest();
request.open('GET', GH_API_URL, true);
request.onload = function() {
if (this.status >= 200 && this.status < 400) {
let response = JSON.parse(this.response);

for(var i = 0; i < response.length; i++){
document.getElementById('gh-comments-list').appendChild(createCommentEl(response[i]));
}

if(0 === response.length) {
document.getElementById('no-comments-found').style.display = 'block';
}
} else {
console.error(this);
}
};

function createCommentEl(response) {
let user = document.createElement( 'a' );
user.setAttribute( 'href', response.user.url.replace('api.github.com/users', 'github.com'));
user.classList.add('user');

let userAvatar = document.createElement('img');
userAvatar.classList.add('avatar');
userAvatar.setAttribute('src', response.user.avatar_url);

user.appendChild(userAvatar);

let commentLink = document.createElement('a');
commentLink.setAttribute('href', response.html_url);
commentLink.classList.add('comment-url');
Expand All @@ -73,40 +73,40 @@
let commentContents = document.createElement('div');
commentContents.classList.add('comment-content');
commentContents.innerHTML = response.body;

let comment = document.createElement('li');
comment.setAttribute('data-created', response.created_at);
comment.setAttribute('data-author-avatar', response.user.avatar_url);
comment.setAttribute('data-user-url', response.user.url);

comment.appendChild(user);
comment.appendChild(commentContents);
comment.appendChild(commentLink);

return comment;
}
request.send();
</script>
<article>
<h1>Hunt the Wumpus - Cave CLI Game</h1>
<p><br>
Hunt the Wumpus is a cave CLI game that I made for a university assignment. The concept is very simple you are in square grid, the cave, in which you get to choose the size. You have to shoot
the Wumpus with an arrow, find the gold, and then escape exactly where you came in from. There is also other dangerous events in the cave such as bottomless pits and bat caves filled with bats. If
you walk into the Wumpus's room or a room with a bottomless pit in it you die. If you walk into a bat cave they pick you up and move you to random room in the grid regardless if whether it's occupied
by something. You have three arrows only and if you shoot all of them without hitting the wumpus you lose, and every arrow moves three rooms. Every time that you shoot an arrow there is a 75% chance
that the wumpus will move to another room that doesn't have an event. This also means it can move to the room your currently in still. Normally when playing the game you don't know where the objects are
but when you get near them you'll see an output message for each event one move away from you, and this can help you decide and even figure out where the events are. Although, for testing purposes I implemented
Hunt the Wumpus is a cave CLI game that I made for a university assignment. The concept is very simple you are in square grid, the cave, in which you get to choose the size. You have to shoot
the Wumpus with an arrow, find the gold, and then escape exactly where you came in from. There is also other dangerous events in the cave such as bottomless pits and bat caves filled with bats. If
you walk into the Wumpus's room or a room with a bottomless pit in it you die. If you walk into a bat cave they pick you up and move you to random room in the grid regardless if whether it's occupied
by something. You have three arrows only and if you shoot all of them without hitting the wumpus you lose, and every arrow moves three rooms. Every time that you shoot an arrow there is a 75% chance
that the wumpus will move to another room that doesn't have an event. This also means it can move to the room your currently in still. Normally when playing the game you don't know where the objects are
but when you get near them you'll see an output message for each event one move away from you, and this can help you decide and even figure out where the events are. Although, for testing purposes I implemented
a debug mode in which you can see where the player and all the events are in the grid. The grid will looking something like this:<br><br>

<img src="../../../images/huntthewumpus.png" height="40%" width="75%" object-fit="cover"></img><br><br>

It's a very simple game, but looking at it from a design perspective there can be quite a bit of different aspects to account for. You can start to realize that the project would be a lot simpler
if we used objects and polymorphism over functional programming, and conveniently this assignment required the use of that. This is because if you look at the requirements for each of the different events
It's a very simple game, but looking at it from a design perspective there can be quite a bit of different aspects to account for. You can start to realize that the project would be a lot simpler
if we used objects and polymorphism over functional programming, and conveniently this assignment required the use of that. This is because if you look at the requirements for each of the different events
in the grid they all need to be able to output an event specific message when you are near them and an event specific action when the player moves into the event's room. Since their requirements are extremely similiar
we can make an abstract class with two purely virtual functions which handle those two requirements and requires each event class, which will derive this abstract class, to implement their own specific version of
we can make an abstract class with two purely virtual functions which handle those two requirements and requires each event class, which will derive this abstract class, to implement their own specific version of
these functions. Doing it this way will reduce a lot of the code we have to write and reuse. The event class will look something like this: <br><br><br>
<br><br></p>

<pre>
<button id="toolbar" onclick="copyToClickBoard()">Copy</button>
<br>
Expand Down Expand Up @@ -137,17 +137,17 @@ <h1>Hunt the Wumpus - Cave CLI Game</h1>

<p><br>
Additionally, this will also make adding events to rooms a lot easier. When implementing the grid I created a 2D vector of room objects which has different variables and methods to make the implementation easier.
Within each of these room objects I added an empty event pointer, which allows us to use polymorphism. When putting each event in a room I would choose random coordinates and make sure that either the player
Within each of these room objects I added an empty event pointer, which allows us to use polymorphism. When putting each event in a room I would choose random coordinates and make sure that either the player
wasn't in that room and the event pointer in that room was set to null, which means theres no event in there, and if it wasn't then I would choose a new position and check again. When I found a valid position for
an event I would then create a new derived event object on the heap and point that event pointer to the memory address of that object.<br><br>

Now we have a bunch of different events in different rooms with there own implementation of the correct functions, but for my debug mode I need to be able to display a character so that I could tell what type of event
the object was without walking into it or being anywhere near it, and I implemented this using inheritance. Since each derived event inherited the event class I added a char const name attribute to the event class, as you can
see above, and made it so that it could only be set in the constructor, which means it would never change. I then made it so that whenever a derived event was constructed, since the event class is an abstract class it can't be
the object was without walking into it or being anywhere near it, and I implemented this using inheritance. Since each derived event inherited the event class I added a char const name attribute to the event class, as you can
see above, and made it so that it could only be set in the constructor, which means it would never change. I then made it so that whenever a derived event was constructed, since the event class is an abstract class it can't be
constructed by itself, it would call the event constructor with it's specific name for the event. For example Bats are 'B', Gold is 'G', and the Wumpus is 'W' and so on. Heres what the constructors looked like:

<br><br></p>

<pre>
<button id="toolbar" onclick="copyToClickBoard()">Copy</button>
<br>
Expand All @@ -173,8 +173,8 @@ <h1>Hunt the Wumpus - Cave CLI Game</h1>

/*********************************************************************
** Function: Wumpus::Wumpus()
** Description: This is the default constructor for the Wumpus class and it
constructs an Event object and sets the name to W so that the game can tell which
** Description: This is the default constructor for the Wumpus class and it
constructs an Event object and sets the name to W so that the game can tell which
Event this is when polymorphism is implemented
** Parameters: NONE
** Pre-Conditions: no Wumpus object
Expand All @@ -185,7 +185,7 @@ <h1>Hunt the Wumpus - Cave CLI Game</h1>
</pre>

<p><br>
This allowed me to print out the objects name irregardless of the event, for example I could just call event.name(), if the debug mode was set to true. Here's what the room and wumpus class look like, and keep in mind that all of
This allowed me to print out the objects name irregardless of the event, for example I could just call event.name(), if the debug mode was set to true. Here's what the room and wumpus class look like, and keep in mind that all of
the derived classes look about the same:
<br><br></p>

Expand Down Expand Up @@ -219,10 +219,10 @@ <h1>Hunt the Wumpus - Cave CLI Game</h1>
//setters
void set_event(Event*);
void set_has_player(bool);

//destructor which frees the event pointer if it's pointing to something
~Room();

};

//this class inherits the event and represents the wumpus
Expand All @@ -231,7 +231,7 @@ <h1>Hunt the Wumpus - Cave CLI Game</h1>
//constructor
Wumpus();

//these funciton override the event virtual functions and handle walking into the
//these funciton override the event virtual functions and handle walking into the
//wumpus's room
std::string percept() const override;
std::string encounter(Player&) const override;
Expand All @@ -244,8 +244,8 @@ <h1>Hunt the Wumpus - Cave CLI Game</h1>

<p><br>
Overall, this project was very benificial to my understanding of Object Oriented Programming, inhereitance, and polymorphism. It has also helped me understand the power of using these tools
as opposed to functional programming and the conciseness and reusability of this method. It allows programmers to write more concise and clean code, which is what every programmer should
strive for. I look forward to seeing more applications of this technique in the future, and i'm grateful to have another useful tool in my toolbelt. You can find the full code
as opposed to functional programming and the conciseness and reusability of this method. It allows programmers to write more concise and clean code, which is what every programmer should
strive for. I look forward to seeing more applications of this technique in the future, and i'm grateful to have another useful tool in my toolbelt. You can find the full code
<a target="_blank" href="https://github.com/riceriley59/CS-162/tree/main/assignments/wumpus">here</a>.
<br><br></p>

Expand All @@ -255,12 +255,12 @@ <h1>Hunt the Wumpus - Cave CLI Game</h1>
<ul id="gh-comments-list"></ul>
<p id="no-comments-found">No comments found for this article.</p>
<p id="leave-a-comment">This will take you to Github where you can then write, and post, your comment (it will show up on the page within an hour).
You will need a Github account to comment.<br><br><button onclick="window.location.href='https://github.com/riceriley59/CS-162/issues/1';">Leave a comment</button></p>
</div>
You will need a Github account to comment.<br><br><button onclick="window.location.href='https://github.com/riceriley59/HackByte/issues/9';">Leave a comment</button></p>
</div>

<div class="trademark"><p>Riley Rice - 2022</p></div>
<script src="post-huntthewumpus.js"></script>
<script src="../../../app.js"></script>
<script src="../../prism.js"></script>
</body>
</html>
</html>
13 changes: 12 additions & 1 deletion posts/posts.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" integrity="sha384-TX8t27EcRE3e/ihU7zmQxVncDAy5uIKz4rEkgIXeMed4M0jlfIDPvg6uqKI2xXr2" crossorigin="anonymous">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@300&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@300&display=swap" rel="stylesheet">
<link rel="stylesheet" href="posts.css">
<link rel="stylesheet" href="../transitions.css">
</head>
Expand Down Expand Up @@ -83,6 +83,17 @@ <h5 class="title"><a href='post/post-huntthewumpus/post-huntthewumpus.html'>Hunt
</figcaption>
</figure>
</div>

<div class="grid-item col-md-4 software webdesign">
<figure>
<img src="../images/capstone-admin-page.png" alt="">
<figcaption class="fig-caption">
<i class="fa fa-search"></i>
<h5 class="title"><a href='post/post-capstone/post-capstone.html'>Oregon State Capstone Project</a></h5>
<span class="sub-title">Helped Build a Fuel Kiosk for my Senior Capstone Project at Oregon State University</span>
</figcaption>
</figure>
</div>
</div>
</div>
</div>
Expand Down