F. Discussion

F.Brief Discussion

Blackjack:

During the final testing, the TA ran through the code twice. The code ran correctly both times. The instructions were displayed on the screen, but there was still some explaining that had to be done in order for the TA to most accurately play the game. The TA lost the first round against the dealer and won the second round. The code was analyzed by the TA and the process of creation was explained.

Initially, the general rules of Blackjack were outlined in a pseudo code and a general code was written that contained all aspects of the game, but did not have any of the loops or variables present. The final code began with the shuffling of both the player and the dealer’s decks. After this, the cards of both the dealer and the player were displayed. The player went through their turn, followed by the dealer, who’s decisions were programmed based off of the different possible outputs of the player. Finally, a “results loop” was added at the end that was used to determine the final outcome of the game and display the results to the player.

The most challenging obstacle when creating this code was corresponding the loops of the player and the dealer. It was difficult to think of every single possible outcome and make a pathway that would go along with it. This was overcome by choosing two variables, A and W to indicate whether or not a certain result would be displayed or whether or not a loop would run. Using the variables in this way made the code more organized and easier to write.

Connect Four:

During the final testing of the game, the game ran as initially planned. The Four in a Row game did as it was prompted to. The game first displayed the first input, which simply said, “Does all players know how to play Four in a Row?” After the user was prompted to answer the question, 1 for yes, and two for no, based on their response, the user either started the game if they entered “yes” or they were displayed the set of rules and instructions if they entered “no.” After entering their desired answered, the game began immediately. The Four in a Row board immediately appeared after the decision was made and the game begun. The instructor was able to see the instructions and steps clearly as well as the board too. The instructors were able to insert their color chip piece that they had chosen into the board, a 6 by 7 grid of circles. The instructor managed to finish the game, and everything ran as planned.

Initially, the way that the team agreed to create Four in a Row, was by creating a grid of zeros by using the “zero(6,7)” function. It was later decided that it would be much easier to play four in a row with graphics, instead of a column and rows of zeros with only two set chips, 1s and 2s for markers. After the team agreed to make this change, the team spent two days deciding how we

could implement this change. After discussing with a couple TAs and other engineering students, it was discovered that it is possible to use just an ordinary graph to play Four in a Row. It was explained that you can enter markers into the graph using the “ginput” function. This function always users to input markers manual by a click instead of the markers already being entered. Using this function and the “grid on” function, the graph appeared and the user was able to input their chips. The only problem was creating a grid in a pattern of circles instead of a grid of squares. After researching, it was discovered that you could change the length and with of the tiny markers where the y axis and x axis crossed and formed dots. Using the grid function and linspace function, the team was able to create a pattern of circles with a width of .431 inches with even spacing of 0.01 vertically and horizontally. The next problem faced was making the board appear to look like an actual board instead of a graph with a X and Y axis. To give the board a more realistic look of an actual board, the X and Y axis was removed by using the set(gca,”YTick’ []) and set(gca, “XTick”, []) function. This function eliminates all variables along the X and Y axis since the brackets gets rid of the axis numbers from all numbers. The next constraint faced by the team was creating an actual marker for the pieces. It was decided that the game should not have a restriction on color, so in order to create a game with no color restriction, the team used a custom color function. This function immediately prompts the user to choose any color they would like with a restriction of only two colors. The obstacle that was discovered while using this function was that the user was not allowed to use the “ginput” with the custom color function if the grid didn’t have create values. This obstacle was resolved by creating a loop for the “ginput” function. The loop created only allowed the user to insert their piece if the place on the grid was positive. In order to make the grid positive, the team used the absolute function over the entire grid to make the statement true. Now, any place entered into the graph held a positive value allowing the user to input their answer into any coordinate point.