Othello:
When initially planning out how to program Othello into MATLAB, our group was overwhelmed. The challenge of dealing with graphics for the first time was daunting. Another factor that added to the challenge of programming Othello was the fact that Othello has many conditions that must be met in order for a player to place a piece on the board. These conditions include:
- the player must place their piece in an empty space
- the piece cannot be placed on top of another piece
- the piece must be placed next to a piece of the opposite color
- when placed, the piece must flank (flip over) at least one of the opponents pieces
In order to deal with the complexities of Othello’s rules, our group decided to draft a flowchart so that we could better plan out how to approach programming the game. Before we decided to make a flowchart our program included many if/else commands and it was confusing and very difficult to debug. After completing the flowchart, however, our group realized that we could create a more organised version of the program utilizing while commands. In the end, our program became much easier to read and the number of program errors was reduced as well. Using nested while commands, our group was able to program checks for the many conditions necessary for piece placement in Othello. After the challenge of getting the player to place their piece in a valid location was met, it became much easier to program the remaining elements of the game.
While testing Othello we noticed that a couple of re-occurring errors were occurring. One such error had to do with the code for flipping pieces in-between the placed piece and another piece. It was discovered that the error was due to the fact that the lines of code responsible for flipping pieces were initially copied and pasted before they were altered to fit the requirements for each direction around the placed piece. The problem was that our group had forgotten to alter some of the original lines of code so the pieces weren’t flipping correctly.
Another error that our group came across while testing the program was the fact that our vector that was used to store the pieces and their colors on the board (Board_State) lacked a defined border. As a result, when the program checked to make sure that the piece was placed next to a piece of the opposite color, it’s sweep of the surrounding spaces in the vector would sometimes take it out of the vector and stop the program. To combat this error, a border was added to the Board_State vector and the program was altered to incorporate it.
After extensive testing and refining, Othello was ready to play. During the final testing day, it ended up passing and worked exactly as intended.
Hangman
The first step in designing hangman was deciding if our hangman would be a one player or two. As a team we drew out a flowchart and executed a short code for a two person version of the game. In this version the first player would input a word, and the second player would then guess the word by inputting letters one at a time. This version of the game worked, however we decided to try something more challenging. At this point we began planning code for a single player version of Hangman in MatLab.
A flowchart and partial code plan was then formulated for a one player version. One large part of this version was finding a way to randomly generate words for the player to guess. Methods were discussed, such as assigning letters to numbers and randomly generating numbers to form words. This method would not work, due to the randomly generated numbers would not be words, therefor extremely hard to guess. After much testing and tinkering a final solution was found. Each word in the code had to be individually written and programmed letter by letter. This led us to be able to create a general theme of animals within the words.
After having an outside user test the game, they made the suggestion to add how many letters they need to guess at the beginning, rather than when they first guess a correct letter. In the code we had not yet put in blanks for the number of letters in the words. Based on the user test, we were able to improve the game.