F. Discussion

Blackjack

If/else statements are used for multiple functions of the game. For example, these are used to determine what happens to a player based on their score, which means that they cause him/her to lose if their score goes over 21, and dictates whether he or she wins or loses against a computer by comparing the scores of the two players. Switch statements determine the player and dealer’s total. While loops are used for when the user wants to hit, and they prevent the same card from being drawn twice.

There were a few bugs in the code that were found when testing. First and foremost, I had trouble using the subplot() and imshow() functions. The images would be formatted incorrectly on the GUI. In order to remedy this issue, I created two panels in the GUI. One larger panel for the player and one smaller panel for the dealer was created. The images axes were each placed on the panels, which resulted in properly formatted images.

Another issue that occurred was when two aces were given to the player initially. Once the player dismissed the first “Ace Value?” box, the second one did not reappear. I added a counter in the playerSum switch statement. If two aces were given to the user, an if/else statement would run, making the “Ace Value?” box reappear.

A variety of stylistic changes for the GUI occurred during the duration of the project as well. Through testing of the project allowed me to learn even more about MatLab. It was another challenge I needed to overcome. This game was very time consuming, but I gained a better understanding of MatLab and its components.

Over Under

In over under, the task seemed pretty simple to make a game that would just ask if the user thought the roll would be over or under seven, but once the coding began, there was more to it that previously thought. When the loop was done and the bet was stored along with the new amount of money the user had to play, the game would be stuck in a loop. I didn’t realize that there was no way to get out of the game once it had started. Then there was an input statement asking if the user would like to play again after each round as long as they had money. Another issue that the game is faced with is that the game can only be played in whole numbers. The game cannot take bets that incorporate cents. Due to limited time, rather than fix the issue, the instructions indicated that the game may only be played using bets rounded to the nearest dollar. By the end, the game was fully functioning and I was able to better grasp how to use and work with matlab.

Hangman
If else statements formed the basis of the game. They were used to compare the input letter to the actual letter and to determine what to do depending on how many out were left. Throughout the process of creating the game I became accustomed to using the guide feature to create a GUI. I was able to learn about handles and how I could apply them to the hangman game. Handles were used heavily as they were the way the player interacts with the program. Throughout testing a number of issues appeared. The panels of GUI often stuck together causing some things to display when the should not or remain hidden when they should have appeared. They had to be manually rearranged in order to function properly. Another issue was that the user could keep clicking buttons after the win or lose text would display. I had to learn how to disable and re-enable the buttons to prevent this from happening. Another issue that took a while to manifest was that the method of generating random numbers seemed to favor some words and ignore others. We had to revamp the random number generator to ensure that the random words were random. Overall this was a fun project that allowed us to gain a better understanding of matlab and resulted in a fully functional game