miniproject: othello (classes, objects, and a smidge of random … · 17 hours ago · othello:...

21
1 MiniProject: Othello (Classes, Objects, and a smidge of random Numbers) (100 pts, Due Thurs, Sept 17 at midnight) Note: you may work with a partner or you may work alone. If you choose to work with a partner, make sure you both turn in the project, and make sure you include both names on the project. Equally, note your partner’s name in canvas. Please be aware that if your partner flakes on you, you are still responsible for completing the mini project and turning it in on time. Time: This project may take 8-10 hours, and should be worked on in a spread-out manner, as opposed to one sitting. This miniproject is closely tied to week 2 videos and ppts on my web site: https://www.eecis.udel.edu/~yarringt/CISC220 (yeah, I’m just gonna keep plugging it until everyone gets used to the idea that that is where I place my course content). Contents Othello: Description of Game ....................................................................................................................................................... 1 Purpose of this miniproject: ......................................................................................................................................................... 2 Programming Description: Othello ................................................................................................................................................... 2 Player Class: .................................................................................................................................................................................. 2 (6 pts) Creating and implementing the header file and the definition file for the Player Class ................................................ 2 Othello Class: ................................................................................................................................................................................ 2 (4 pts) Creating a header file and a definition file for Othello Class ......................................................................................... 2 (6 pts) 3 constructors: ............................................................................................................................................................... 3 (3 pts)makemat ......................................................................................................................................................................... 3 (8 pts)printmat() ....................................................................................................................................................................... 3 (12 pts)placepiece() .................................................................................................................................................................. 4 (20 pts)countandflippieces() ..................................................................................................................................................... 4 (8 pts)ckwin() ............................................................................................................................................................................ 5 (20 pts)compplacepiece(player p): ........................................................................................................................................... 5 (15 pts): Getting the game to work successfully and turning in a screenshot of your running code ........................................ 5 Extra Credit Options: .................................................................................................................................................................... 7 To Turn in:..................................................................................................................................................................................... 7 Sample Output: ............................................................................................................................................................................. 7 Othello: Description of Game For this lab you will be using classes and objects to program the game Othello. For those of you unfamiliar with the game, there is an 8x8 board, and 2 players. Equally, there are pieces that you place on the board. All pieces are identical, and they have one side black, and the other side a color (mine were orange). The 4 middle squares are diagonal black and orange pieces to start with, e.g., 0 1 2 3 4 5 6 7 0 _ _ _ _ _ _ _ _ 1 _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 3 _ _ _ B O _ _ _ 4 _ _ _ O B _ _ _ 5 _ _ _ _ _ _ _ _ 6 _ _ _ _ _ _ _ _ 7 _ _ _ _ _ _ _ _

Upload: others

Post on 10-Sep-2020

5 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: MiniProject: Othello (Classes, Objects, and a smidge of random … · 17 hours ago · Othello: Description of Game For this lab you will be using classes and objects to program the

1

MiniProject: Othello (Classes, Objects, and a smidge of random Numbers) (100 pts, Due Thurs, Sept 17 at midnight)

Note: you may work with a partner or you may work alone. If you choose to work with a partner, make sure you both turn in the project, and make sure you include both names on the project. Equally, note your partner’s name in canvas. Please be aware that if your partner flakes on you, you are still responsible for completing the mini project and turning it in on time.

Time: This project may take 8-10 hours, and should be worked on in a spread-out manner, as opposed to one sitting.

This miniproject is closely tied to week 2 videos and ppts on my web site: https://www.eecis.udel.edu/~yarringt/CISC220 (yeah, I’m just gonna keep plugging it until everyone gets used to the idea that that is where I place my course content).

Contents Othello: Description of Game ....................................................................................................................................................... 1 Purpose of this miniproject: ......................................................................................................................................................... 2

Programming Description: Othello ................................................................................................................................................... 2

Player Class: .................................................................................................................................................................................. 2 (6 pts) Creating and implementing the header file and the definition file for the Player Class ................................................ 2

Othello Class: ................................................................................................................................................................................ 2 (4 pts) Creating a header file and a definition file for Othello Class ......................................................................................... 2

(6 pts) 3 constructors: ............................................................................................................................................................... 3

(3 pts)makemat ......................................................................................................................................................................... 3

(8 pts)printmat() ....................................................................................................................................................................... 3

(12 pts)placepiece() .................................................................................................................................................................. 4

(20 pts)countandflippieces() ..................................................................................................................................................... 4

(8 pts)ckwin() ............................................................................................................................................................................ 5

(20 pts)compplacepiece(player p): ........................................................................................................................................... 5

(15 pts): Getting the game to work successfully and turning in a screenshot of your running code ........................................ 5

Extra Credit Options: .................................................................................................................................................................... 7 To Turn in: ..................................................................................................................................................................................... 7 Sample Output: ............................................................................................................................................................................. 7

Othello: Description of Game

For this lab you will be using classes and objects to program the game Othello. For those of you unfamiliar with the game, there is an 8x8 board, and 2 players. Equally, there are pieces that you place on the board. All pieces are identical, and they have one side black, and the other side a color (mine were orange).

The 4 middle squares are diagonal black and orange pieces to start with, e.g.,

0 1 2 3 4 5 6 7 0 _ _ _ _ _ _ _ _ 1 _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 3 _ _ _ B O _ _ _ 4 _ _ _ O B _ _ _ 5 _ _ _ _ _ _ _ _ 6 _ _ _ _ _ _ _ _ 7 _ _ _ _ _ _ _ _

Page 2: MiniProject: Othello (Classes, Objects, and a smidge of random … · 17 hours ago · Othello: Description of Game For this lab you will be using classes and objects to program the

2

One player is black pieces, and one is orange pieces. The two players take turns placing pieces with their color up on the board. Each time they place a piece on the board it must be placed such that at least one of the other players pieces is flipped. To flip a piece, their piece must be directly in a line between an old piece of yours on the board, and the piece you just placed on the board. If a player is unable to place their piece on the board, they forfeit their turn. The winner is the player with the most pieces on the board.

Below is a link to a video demonstration of the game (they used black and white instead of black and orange, but you get the idea)

https://www.youtube.com/watch?v=Ol3Id7xYsY4

Purpose of this miniproject:

The purpose of this project is to establish a firm foundation in creating and using basic classes and objects. For many of our future data structures we will be using classes and objects. There is a smidge of random number generation thrown in as well (because you can never go wrong with a bit of randomness).

Note: If a pop-up box arises that says “Errors exist, do you wish to continue?” Your code DOES NOT COMPILE. Don’t click continue. Fix your code. You will not receive credit for code that does not compile.

Thus I am requiring these 2 classes, and I am requiring that the player fields in the Othello class be of type Player.

Equally, I am requiring that you basically follow my method outline for the Othello class, although I will allow you to

add methods (helper methods, perhaps) and even modify the method parameters. Be aware that any modifications

may involve your having to update the playGame method.

Programming Description: Othello You will be creating 2 classes (one very brief class for the player objects in the game, and one more extensive class for the

Othello Game. Thus you will be creating 4 files: Player.hpp, Player.cpp, Othello.hpp, and Othello.cpp (if this all sounds crazy to

you, please watch my videos/ppts under week 2 on my web site at https://www.eecis.udel.edu/~yarringt/CISC220 (plugging it

again!)).

I am giving you the contents for the 5th file which should contain the main function, and the playGame method for the Othello

class.

Player Class:

(6 pts) Creating and implementing the header file and the definition file for the Player Class The player class consists of 2 fields and 2 constructors.

The fields are:

• a string for the name,

• A char for the player’s piece (‘B’ or ‘O’);

The two constructors are:

• One with no input parameters, that sets the name field to be something like, “computer” and chooses a

piece color for that player (again, either ‘B’ or ‘O’)

• One with 2 input parameters (a string and a char). This constructor sets the name filed to be the string input

parameter and the piece field to be the char parameter

Othello Class:

(4 pts) Creating a header file and a definition file for Othello Class The Othello Class is much more extensive than the Player class, and as such, there is some flexibility (i.e., you may add

methods that will act as helper methods, you may modify the parameters for methods, you may even add (or possibly

subtract) a field. (Note that for this class I’m giving you the playGame method, so be aware that if you modify the

methods/fields too drastically, you will also have to edit the playGame method). For my Othello Class:

The fields are:

• A board matrix (8x8) of chars – this is the otherllo board

Page 3: MiniProject: Othello (Classes, Objects, and a smidge of random … · 17 hours ago · Othello: Description of Game For this lab you will be using classes and objects to program the

3

• A board size (int) which for this game will always be 8;

• 2 players, both of type Player

• A numplayer field (an int). This indicates how many players are “live” and how many are computers. For instance, if

the numplayers is 0, the computer is playing against the computer, whereas if the numplayers is 1, a person is playing

the computer, and if it is 2, a person is playing another person.

The Methods I wrote are:

Othello(); Othello(string st1, char c); Othello(string st1, char c, string st2, char c2);

(6 pts) 3 constructors: 0ne setting both players to be computers and choosing which piece goes to each, setting the and numplayers to be 0, one setting one player’s fields to be thee input parameters and the second player to be a computer, and the numplayers to be 1, and the third sets both player’s fields and numplayers to be 2. /*

(3 pts)makemat This method initializes each element in the list as a blank character ('_'). (You need to initialize the matrix so there's not gibberish in each square when we start - C++ lets you access gibberish, so it isn't easy to check if a square is empty) After the matrix has been made, add 'B' and 'O' to the centermost squares to initialize the board, so you end up with something like this: [' ',' ',' ',' ',' ',' ',' ',' '], [' ',' ',' ',' ',' ',' ',' ',' '], [' ',' ',' ',' ',' ',' ',' ',' '], [' ',' ',' ','B','O',' ',' ',' '], [' ',' ',' ','O','B',' ',' ',' '], [' ',' ',' ',' ',' ',' ',' ',' '], [' ',' ',' ',' ',' ',' ',' ',' '], [' ',' ',' ',' ',' ',' ',' ',' ']] */ /*

(6 pts)printmat() this method prints out the matrix, by adding a tab between each square. It also prints out around the edges the index values. This makes selecting a square MUCH EASIER. It should print something that looks like this the first time you print the matrix:

0 1 2 3 4 5 6 7 0 _ _ _ _ _ _ _ _ 1 _ _ _ _ _ _ _ _ 2 _ _ _ _ _ _ _ _ 3 _ _ _ B O _ _ _ 4 _ _ _ O B _ _ _ 5 _ _ _ _ _ _ _ _ 6 _ _ _ _ _ _ _ _ 7 _ _ _ _ _ _ _ _ */

/*

Page 4: MiniProject: Othello (Classes, Objects, and a smidge of random … · 17 hours ago · Othello: Description of Game For this lab you will be using classes and objects to program the

4

(12 pts)placepiece() this method takes 2 input parameters as strings: the current player ('player1' or 'player2') and the player's color ('B', or 'O'). It returns nothing, but modifies the boardmatrix (adds the player's piece and calls the countandflippieces method above to flip the appropriate pieces) Start by having the player input the x and y coordinates of the square where they want to place their piece. To give you an example of what this would look like to get the coordinates from the player: int x; int y; cout<<"enter the x coordinate on the board: "; cin >> x; cout<<"enter the y coordinate on the board: "; cin >> y; Check to make sure that hte x coordinate and the y coordinate are both valid (not less than 0 or off the edge of the board) and that the boardmatrix at the x-y coordinate doesn't already have a piece there. If the x or y coordinates are off-limits, or the boardmatrix already has a piece on it there, ask the usr to enter another set of x/y coordinates and continue to do this until the user chooses valid x/y coordinates. Once a valid x/y coordinate has been chosen, the boardmatrix at the x/y coordinates becomes the player's color. Now add the call(s) to the countandflippieces method to flip the appropriate pieces in each of the 8 directions, keeping track of the total number of flipped pieces. If the total number of flipped pieces is 0, then print out ("Player forfeits turn") and set the square on the boardmatrix back to ' '.*/

/*

(20 pts)countandflippieces() This method takes as a minimum, the (integer) x and y coordinates of where the player placed a piece on the board, and the current player. It might also take a boolean value that determines whether to actually flip the pieces or not and a direction to check in (leftupdiag, leftdowndiag, left,up, etc.) It returns (an integer) the count of the number of pieces flipped Note: My method is 24 lines long and doesn't use helper methods. However, if you want, and think this method would be easier with helper methods, feel free to add more methods. Note2: I used the boolean value to determine whether to flip the pieces or not. In other words, if the computer is playing, you may want to look at a square on the board and determine how many pieces would be flipped if the computer placed a piece there. If, however, a person is placing a piece, or the computer has determined it wants to place a piece in a particular location, then the pieces should be flipped. Testing: To test this method, call it with an x and y coordinate, player, etc. and set the boolean value to true. Then use the printmatrix method to print the board and see if the appropriate pieces were flipped. Also check the count integer returned to see

Page 5: MiniProject: Othello (Classes, Objects, and a smidge of random … · 17 hours ago · Othello: Description of Game For this lab you will be using classes and objects to program the

5

if the count is correct. */

/*

(6 pts)ckwin() This method takes no input parameters. It returns nothing, but prints out who won with the number of pieces on the board with that color, so it might print: Player 1 won with: 33 versus 31 Testing: print the boardmatrix using your printboard method above. Then call this method. Check to see whether the results match the board by counting the number of squares on the board that match the color of the input parameter. */

/******************************************************************************* If you've made it this far, you can start testing your code without the next method In the playGame method, comment out the call to compplacepiece. Then in main, Use the game instantiator that calls the constructor that sets both players to be humans. Make sure you remove any test cases you used to test your methods (or, anything you commented Out) *******************************************************************************/ /*

(20 pts)compplacepiece(player p): This method takes as input a player This method looks at all possible places that the player's piece could be placed on the boardmatrix, then uses countandflippieces to calculate how many pieces would be flipped if a piece was placed there; Note: I used False as the input parameter to prevent the pieces from actually being flipped). This method needs to keep track ofmthe x/y coordinates that, if a piece was placed there, would flip the most pieces. Then, once the x/y coordinates of the location in which the most pieces would be flipped, the method countandflippieces is used to actually flip the pieces (so for mine the input parameter was set to True now). If you get the above working, that's worth 15 of the 20 points for this method. However, we want the computer to choose randomly among the x/y coordinates that flip the most pieces. So, if there are 4 x/y locations that all result in flipping 3 pieces, then we want to choose randomly among thise 4 x/y locations. Have fun! */

(15 pts): Getting the game to work successfully and turning in a screenshot of your running code /* Congratulations! Now that you have your classes and methods working, add in the playGame method. If everything works, you're done! (note: you might have to modify my calls to placepiece, compplacepiece, or ckwin if you've modified the input parameters from what I have) */ /******************************************************************************/ //Code I’m giving you:

Page 6: MiniProject: Othello (Classes, Objects, and a smidge of random … · 17 hours ago · Othello: Description of Game For this lab you will be using classes and objects to program the

6

//playGame Method: void Othello::playGame(){ makemat(); printmat(); bool play = true; int fullsqrs = 0; player p = p1; bool whichp = true; bool turn = true; if (rand()%2 == 0) { // p1 plays first p = p2; turn = false; whichp = false; } while ((play) && (fullsqrs < 64)){ cout << endl << p.name <<" ("<<p.piece<<") choose your square: "<<endl; if ((numplayers == 2) || ((numplayers == 1) && turn)){ placepiece(p); } else if ((numplayers == 0) || ((numplayers == 1) && (turn == false))){ compplacepiece(p); } turn = !turn; printmat(); if (whichp) { p = p2; whichp = false; } else { p=p1; whichp = true; } fullsqrs+=1; } ckwin(); } /* ************************************************************************* and code for the main function, which should be in its own file with a .cpp extension, located in the same project folder as your Othello Class and your Player Class files ****************************************************************************/ #include <iostream> #include <stdlib.h> #include "Othello.hpp" #include <time.h> using namespace std; int main() { srand(time(NULL)); Othello game("b1",'B',"s1",'O'); Othello game2("b1",'B');

Page 7: MiniProject: Othello (Classes, Objects, and a smidge of random … · 17 hours ago · Othello: Description of Game For this lab you will be using classes and objects to program the

7

Othello game3; game.playGame(); }

/*******************************************************************************************************************/

Extra Credit Options: If you actually have time, there are two extra credit options:

1) (up to 10 pts) – right now the computer’s “intelligence” is solely choosing randomly among the potential

squares that flip the most pieces. I was usually able to win simply by picking better pieces. Add some

intelligence to the computer so that it picks more wisely

2) (up to 20 pts) – create a better user interface. C++ is known for creating incredibly fast, efficient executable

code that takes very little space in memory. It is not known for its user interfaces. However, there are

libraries that will allow you to create a better user interface. For extra credit, create a cooler user interface.

/*******************************************************************************************************************/

To Turn in: 1 zipped file with 6 files:

• Player header and defintiions files

• Othello header and definitions files

• Your name and your partner’s name on ALL 4 files

• The main (zip it in there)

• A screenshot of your code working

/*******************************************************************************************************************/

Sample Output: (This is me playing the computer. I’m horrible at games. It’s embarrassing. But that’s not the point. This is what the game

output looks like when I play the computer:)

0 1 2 3 4 5 6 7 0 _ _ _ _ _ _ _ _ 1 _ _ _ _ _ _ _ _ 2 _ _ _ _ _ _ _ _ 3 _ _ _ B O _ _ _ 4 _ _ _ O B _ _ _ 5 _ _ _ _ _ _ _ _ 6 _ _ _ _ _ _ _ _ 7 _ _ _ _ _ _ _ _ computer (O) choose your square: 0 1 2 3 4 5 6 7 0 _ _ _ _ _ _ _ _ 1 _ _ _ _ _ _ _ _ 2 _ _ _ O _ _ _ _ 3 _ _ _ O O _ _ _ 4 _ _ _ O B _ _ _ 5 _ _ _ _ _ _ _ _ 6 _ _ _ _ _ _ _ _ 7 _ _ _ _ _ _ _ _ b1 (B) choose your square: Enter the x coordinate: 2 Enter the y coordinate: 2 0 1 2 3 4 5 6 7 0 _ _ _ _ _ _ _ _

Page 8: MiniProject: Othello (Classes, Objects, and a smidge of random … · 17 hours ago · Othello: Description of Game For this lab you will be using classes and objects to program the

8

1 _ _ _ _ _ _ _ _ 2 _ _ B O _ _ _ _ 3 _ _ _ B O _ _ _ 4 _ _ _ O B _ _ _ 5 _ _ _ _ _ _ _ _ 6 _ _ _ _ _ _ _ _ 7 _ _ _ _ _ _ _ _ computer (O) choose your square: 0 1 2 3 4 5 6 7 0 _ _ _ _ _ _ _ _ 1 _ _ _ _ _ _ _ _ 2 _ O O O _ _ _ _ 3 _ _ _ B O _ _ _ 4 _ _ _ O B _ _ _ 5 _ _ _ _ _ _ _ _ 6 _ _ _ _ _ _ _ _ 7 _ _ _ _ _ _ _ _ b1 (B) choose your square: Enter the x coordinate: 2 Enter the y coordinate: 4 0 1 2 3 4 5 6 7 0 _ _ _ _ _ _ _ _ 1 _ _ _ _ _ _ _ _ 2 _ O O O B _ _ _ 3 _ _ _ B B _ _ _ 4 _ _ _ O B _ _ _ 5 _ _ _ _ _ _ _ _ 6 _ _ _ _ _ _ _ _ 7 _ _ _ _ _ _ _ _ computer (O) choose your square: 0 1 2 3 4 5 6 7 0 _ _ _ _ _ _ _ _ 1 _ _ _ _ _ _ _ _ 2 _ O O O O O _ _ 3 _ _ _ B O _ _ _ 4 _ _ _ O B _ _ _ 5 _ _ _ _ _ _ _ _ 6 _ _ _ _ _ _ _ _ 7 _ _ _ _ _ _ _ _ b1 (B) choose your square: Enter the x coordinate: 3 Enter the y coordinate: 5 0 1 2 3 4 5 6 7 0 _ _ _ _ _ _ _ _ 1 _ _ _ _ _ _ _ _ 2 _ O O O O O _ _ 3 _ _ _ B B B _ _ 4 _ _ _ O B _ _ _ 5 _ _ _ _ _ _ _ _

Page 9: MiniProject: Othello (Classes, Objects, and a smidge of random … · 17 hours ago · Othello: Description of Game For this lab you will be using classes and objects to program the

9

6 _ _ _ _ _ _ _ _ 7 _ _ _ _ _ _ _ _ computer (O) choose your square: 0 1 2 3 4 5 6 7 0 _ _ _ _ _ _ _ _ 1 _ _ _ _ _ _ _ _ 2 _ O O O O O _ _ 3 _ _ _ B O O _ _ 4 _ _ _ O O O _ _ 5 _ _ _ _ _ _ _ _ 6 _ _ _ _ _ _ _ _ 7 _ _ _ _ _ _ _ _ b1 (B) choose your square: Enter the x coordinate: 3 Enter the y coordinate: 6 0 1 2 3 4 5 6 7 0 _ _ _ _ _ _ _ _ 1 _ _ _ _ _ _ _ _ 2 _ O O O O O _ _ 3 _ _ _ B B B B _ 4 _ _ _ O O O _ _ 5 _ _ _ _ _ _ _ _ 6 _ _ _ _ _ _ _ _ 7 _ _ _ _ _ _ _ _ computer (O) choose your square: 0 1 2 3 4 5 6 7 0 _ _ _ _ _ _ _ _ 1 _ _ _ _ _ _ _ _ 2 _ O O O O O O _ 3 _ _ _ B B O B _ 4 _ _ _ O O O _ _ 5 _ _ _ _ _ _ _ _ 6 _ _ _ _ _ _ _ _ 7 _ _ _ _ _ _ _ _ b1 (B) choose your square: Enter the x coordinate: 5 Enter the y coordinate: 4 0 1 2 3 4 5 6 7 0 _ _ _ _ _ _ _ _ 1 _ _ _ _ _ _ _ _ 2 _ O O O O O O _ 3 _ _ _ B B O B _ 4 _ _ _ O B B _ _ 5 _ _ _ _ B _ _ _ 6 _ _ _ _ _ _ _ _ 7 _ _ _ _ _ _ _ _ computer (O) choose your square: 0 1 2 3 4 5 6 7

Page 10: MiniProject: Othello (Classes, Objects, and a smidge of random … · 17 hours ago · Othello: Description of Game For this lab you will be using classes and objects to program the

10

0 _ _ _ _ _ _ _ _ 1 _ _ _ _ _ _ _ _ 2 _ O O O O O O _ 3 _ _ _ B B O O _ 4 _ _ _ O O O O _ 5 _ _ _ _ B _ _ _ 6 _ _ _ _ _ _ _ _ 7 _ _ _ _ _ _ _ _ b1 (B) choose your square: Enter the x coordinate: 3 Enter the y coordinate: 7 0 1 2 3 4 5 6 7 0 _ _ _ _ _ _ _ _ 1 _ _ _ _ _ _ _ _ 2 _ O O O O O O _ 3 _ _ _ B B B B B 4 _ _ _ O O O O _ 5 _ _ _ _ B _ _ _ 6 _ _ _ _ _ _ _ _ 7 _ _ _ _ _ _ _ _ computer (O) choose your square: 0 1 2 3 4 5 6 7 0 _ _ _ _ _ _ _ _ 1 _ _ _ _ _ _ _ _ 2 _ O O O O O O O 3 _ _ _ B B B O B 4 _ _ _ O O O O _ 5 _ _ _ _ B _ _ _ 6 _ _ _ _ _ _ _ _ 7 _ _ _ _ _ _ _ _ b1 (B) choose your square: Enter the x coordinate: 1 Enter the y coordinate: 7 0 1 2 3 4 5 6 7 0 _ _ _ _ _ _ _ _ 1 _ _ _ _ _ _ _ B 2 _ O O O O O B B 3 _ _ _ B B B O B 4 _ _ _ O O O O _ 5 _ _ _ _ B _ _ _ 6 _ _ _ _ _ _ _ _ 7 _ _ _ _ _ _ _ _ computer (O) choose your square: 0 1 2 3 4 5 6 7 0 _ _ _ _ _ _ _ _ 1 _ _ _ _ _ _ _ B 2 _ O O O O O B B 3 _ _ O O O O O B 4 _ _ _ O O O O _

Page 11: MiniProject: Othello (Classes, Objects, and a smidge of random … · 17 hours ago · Othello: Description of Game For this lab you will be using classes and objects to program the

11

5 _ _ _ _ B _ _ _ 6 _ _ _ _ _ _ _ _ 7 _ _ _ _ _ _ _ _ b1 (B) choose your square: Enter the x coordinate: 3 Enter the y coordinate: 1 0 1 2 3 4 5 6 7 0 _ _ _ _ _ _ _ _ 1 _ _ _ _ _ _ _ B 2 _ O O O O O B B 3 _ B B B B B B B 4 _ _ _ O O O O _ 5 _ _ _ _ B _ _ _ 6 _ _ _ _ _ _ _ _ 7 _ _ _ _ _ _ _ _ computer (O) choose your square: 0 1 2 3 4 5 6 7 0 _ _ _ _ _ _ _ _ 1 _ _ _ _ _ _ O B 2 _ O O O O O O B 3 _ B B B B B O B 4 _ _ _ O O O O _ 5 _ _ _ _ B _ _ _ 6 _ _ _ _ _ _ _ _ 7 _ _ _ _ _ _ _ _ b1 (B) choose your square: Enter the x coordinate: 0 Enter the y coordinate: 7 0 1 2 3 4 5 6 7 0 _ _ _ _ _ _ _ B 1 _ _ _ _ _ _ B B 2 _ O O O O B O B 3 _ B B B B B O B 4 _ _ _ O O O O _ 5 _ _ _ _ B _ _ _ 6 _ _ _ _ _ _ _ _ 7 _ _ _ _ _ _ _ _ computer (O) choose your square: 0 1 2 3 4 5 6 7 0 _ _ _ _ _ _ _ B 1 _ _ _ _ _ _ B B 2 _ O O O O B O B 3 O O O O O O O B 4 _ _ _ O O O O _ 5 _ _ _ _ B _ _ _ 6 _ _ _ _ _ _ _ _ 7 _ _ _ _ _ _ _ _ b1 (B) choose your square:

Page 12: MiniProject: Othello (Classes, Objects, and a smidge of random … · 17 hours ago · Othello: Description of Game For this lab you will be using classes and objects to program the

12

Enter the x coordinate: 2 Enter the y coordinate: 0 0 1 2 3 4 5 6 7 0 _ _ _ _ _ _ _ B 1 _ _ _ _ _ _ B B 2 B B B B B B O B 3 O O O O O O O B 4 _ _ _ O O O O _ 5 _ _ _ _ B _ _ _ 6 _ _ _ _ _ _ _ _ 7 _ _ _ _ _ _ _ _ computer (O) choose your square: 0 1 2 3 4 5 6 7 0 _ _ _ _ _ _ _ B 1 _ _ O _ _ _ B B 2 B O O O B B O B 3 O O O O O O O B 4 _ _ _ O O O O _ 5 _ _ _ _ B _ _ _ 6 _ _ _ _ _ _ _ _ 7 _ _ _ _ _ _ _ _ b1 (B) choose your square: Enter the x coordinate: 4 Enter the y coordinate: 0 0 1 2 3 4 5 6 7 0 _ _ _ _ _ _ _ B 1 _ _ O _ _ _ B B 2 B O O O B B O B 3 B O O O O O O B 4 B _ _ O O O O _ 5 _ _ _ _ B _ _ _ 6 _ _ _ _ _ _ _ _ 7 _ _ _ _ _ _ _ _ computer (O) choose your square: 0 1 2 3 4 5 6 7 0 _ _ _ _ _ _ _ B 1 _ _ O _ O _ B B 2 B O O O O O O B 3 B O O O O O O B 4 B _ _ O O O O _ 5 _ _ _ _ B _ _ _ 6 _ _ _ _ _ _ _ _ 7 _ _ _ _ _ _ _ _ b1 (B) choose your square: Enter the x coordinate: 0 Enter the y coordinate: 4 0 1 2 3 4 5 6 7 0 _ _ _ _ B _ _ B

Page 13: MiniProject: Othello (Classes, Objects, and a smidge of random … · 17 hours ago · Othello: Description of Game For this lab you will be using classes and objects to program the

13

1 _ _ O _ B _ B B 2 B O O O B O O B 3 B O O O B O O B 4 B _ _ O B O O _ 5 _ _ _ _ B _ _ _ 6 _ _ _ _ _ _ _ _ 7 _ _ _ _ _ _ _ _ computer (O) choose your square: 0 1 2 3 4 5 6 7 0 _ _ _ O B _ _ B 1 _ _ O _ O _ B B 2 B O O O B O O B 3 B O O O B O O B 4 B _ _ O B O O _ 5 _ _ _ _ B _ _ _ 6 _ _ _ _ _ _ _ _ 7 _ _ _ _ _ _ _ _ b1 (B) choose your square: Enter the x coordinate: 0 Enter the y coordinate: 2 0 1 2 3 4 5 6 7 0 _ _ B B B _ _ B 1 _ _ O _ O _ B B 2 B O O O B O O B 3 B O O O B O O B 4 B _ _ O B O O _ 5 _ _ _ _ B _ _ _ 6 _ _ _ _ _ _ _ _ 7 _ _ _ _ _ _ _ _ computer (O) choose your square: 0 1 2 3 4 5 6 7 0 _ _ B B B _ _ B 1 _ _ O _ O _ B B 2 B O O O O O O B 3 B O O O O O O B 4 B _ _ O O O O _ 5 _ _ _ _ O _ _ _ 6 _ _ _ _ O _ _ _ 7 _ _ _ _ _ _ _ _ b1 (B) choose your square: Enter the x coordinate: 7 Enter the y coordinate: 4 0 1 2 3 4 5 6 7 0 _ _ B B B _ _ B 1 _ _ O _ B _ B B 2 B O O O B O O B 3 B O O O B O O B 4 B _ _ O B O O _ 5 _ _ _ _ B _ _ _

Page 14: MiniProject: Othello (Classes, Objects, and a smidge of random … · 17 hours ago · Othello: Description of Game For this lab you will be using classes and objects to program the

14

6 _ _ _ _ B _ _ _ 7 _ _ _ _ B _ _ _ computer (O) choose your square: 0 1 2 3 4 5 6 7 0 _ _ B B B O _ B 1 _ _ O _ O _ B B 2 B O O O B O O B 3 B O O O B O O B 4 B _ _ O B O O _ 5 _ _ _ _ B _ _ _ 6 _ _ _ _ B _ _ _ 7 _ _ _ _ B _ _ _ b1 (B) choose your square: Enter the x coordinate: 0 Enter the y coordinate: 6 0 1 2 3 4 5 6 7 0 _ _ B B B B B B 1 _ _ O _ O _ B B 2 B O O O B O O B 3 B O O O B O O B 4 B _ _ O B O O _ 5 _ _ _ _ B _ _ _ 6 _ _ _ _ B _ _ _ 7 _ _ _ _ B _ _ _ computer (O) choose your square: 0 1 2 3 4 5 6 7 0 _ _ B B B B B B 1 _ _ O O O _ B B 2 B O O O O O O B 3 B O O O B O O B 4 B _ _ O B O O _ 5 _ _ _ _ B _ _ _ 6 _ _ _ _ B _ _ _ 7 _ _ _ _ B _ _ _ b1 (B) choose your square: Enter the x coordinate: 5 Enter the y coordinate: 3 0 1 2 3 4 5 6 7 0 _ _ B B B B B B 1 _ _ O B O _ B B 2 B O O B O O O B 3 B O O B B O O B 4 B _ _ B B O O _ 5 _ _ _ B B _ _ _ 6 _ _ _ _ B _ _ _ 7 _ _ _ _ B _ _ _ computer (O) choose your square: 0 1 2 3 4 5 6 7

Page 15: MiniProject: Othello (Classes, Objects, and a smidge of random … · 17 hours ago · Othello: Description of Game For this lab you will be using classes and objects to program the

15

0 _ _ B B B B B B 1 _ _ O B O _ B B 2 B O O B O O O B 3 B O O O B O O B 4 B _ O O O O O _ 5 _ _ _ B B _ _ _ 6 _ _ _ _ B _ _ _ 7 _ _ _ _ B _ _ _ b1 (B) choose your square: Enter the x coordinate: 0 Enter the y coordinate: 1 0 1 2 3 4 5 6 7 0 _ B B B B B B B 1 _ _ B B O _ B B 2 B O O B O O O B 3 B O O O B O O B 4 B _ O O O O O _ 5 _ _ _ B B _ _ _ 6 _ _ _ _ B _ _ _ 7 _ _ _ _ B _ _ _ computer (O) choose your square: 0 1 2 3 4 5 6 7 0 _ B B B B B B B 1 _ O O O O _ B B 2 B O O B O O O B 3 B O O O B O O B 4 B _ O O O O O _ 5 _ _ _ B B _ _ _ 6 _ _ _ _ B _ _ _ 7 _ _ _ _ B _ _ _ b1 (B) choose your square: Enter the x coordinate: 5 Enter the y coordinate: 5 0 1 2 3 4 5 6 7 0 _ B B B B B B B 1 _ O O O O _ B B 2 B O O B O O O B 3 B O O O B O O B 4 B _ O O O O B _ 5 _ _ _ B B B _ _ 6 _ _ _ _ B _ _ _ 7 _ _ _ _ B _ _ _ computer (O) choose your square: 0 1 2 3 4 5 6 7 0 _ B B B B B B B 1 _ O O O O _ B B 2 B O O B O O O B 3 B O O O B O O B 4 B _ O O O O B _

Page 16: MiniProject: Othello (Classes, Objects, and a smidge of random … · 17 hours ago · Othello: Description of Game For this lab you will be using classes and objects to program the

16

5 _ _ _ O O B _ _ 6 _ _ _ O B _ _ _ 7 _ _ _ _ B _ _ _ b1 (B) choose your square: Enter the x coordinate: 0 Enter the y coordinate: 0 0 1 2 3 4 5 6 7 0 B B B B B B B B 1 _ B O O O _ B B 2 B O B B O O O B 3 B O O B B O O B 4 B _ O O B O B _ 5 _ _ _ O O B _ _ 6 _ _ _ O B _ _ _ 7 _ _ _ _ B _ _ _ computer (O) choose your square: 0 1 2 3 4 5 6 7 0 B B B B B B B B 1 _ B O O O _ B B 2 B O B B O O O B 3 B O O B B O O B 4 B _ O O B O O _ 5 _ _ _ O O O O _ 6 _ _ _ O B _ _ _ 7 _ _ _ _ B _ _ _ b1 (B) choose your square: Enter the x coordinate: 7 Enter the y coordinate: 3 0 1 2 3 4 5 6 7 0 B B B B B B B B 1 _ B O O O _ B B 2 B O B B O O O B 3 B O O B B O O B 4 B _ O B B O O _ 5 _ _ _ B O O O _ 6 _ _ _ B B _ _ _ 7 _ _ _ B B _ _ _ computer (O) choose your square: 0 1 2 3 4 5 6 7 0 B B B B B B B B 1 _ B O O O _ B B 2 B O B B O O O B 3 B O O B O O O B 4 B _ O O B O O _ 5 _ _ O O O O O _ 6 _ _ _ B B _ _ _ 7 _ _ _ B B _ _ _ b1 (B) choose your square:

Page 17: MiniProject: Othello (Classes, Objects, and a smidge of random … · 17 hours ago · Othello: Description of Game For this lab you will be using classes and objects to program the

17

Enter the x coordinate: 4 Enter the y coordinate: 7 0 1 2 3 4 5 6 7 0 B B B B B B B B 1 _ B O O B _ B B 2 B O B B O B O B 3 B O O B O O B B 4 B _ O O B B B B 5 _ _ O O O O O _ 6 _ _ _ B B _ _ _ 7 _ _ _ B B _ _ _ computer (O) choose your square: 0 1 2 3 4 5 6 7 0 B B B B B B B B 1 _ B O O O O B B 2 B O B B O O O B 3 B O O B O O B B 4 B _ O O B B B B 5 _ _ O O O O O _ 6 _ _ _ B B _ _ _ 7 _ _ _ B B _ _ _ b1 (B) choose your square: Enter the x coordinate: 4 Enter the y coordinate: 1 0 1 2 3 4 5 6 7 0 B B B B B B B B 1 _ B O O O O B B 2 B B B B O O O B 3 B B B B O O B B 4 B B B B B B B B 5 _ _ B O O O O _ 6 _ _ _ B B _ _ _ 7 _ _ _ B B _ _ _ computer (O) choose your square: 0 1 2 3 4 5 6 7 0 B B B B B B B B 1 O O O O O O B B 2 B O B B O O O B 3 B B O B O O B B 4 B B B O B B B B 5 _ _ B O O O O _ 6 _ _ _ B B _ _ _ 7 _ _ _ B B _ _ _ b1 (B) choose your square: Enter the x coordinate: 5 Enter the y coordinate: 7 0 1 2 3 4 5 6 7 0 B B B B B B B B

Page 18: MiniProject: Othello (Classes, Objects, and a smidge of random … · 17 hours ago · Othello: Description of Game For this lab you will be using classes and objects to program the

18

1 O O O O O O B B 2 B O B B O O O B 3 B B O B O O B B 4 B B B O B B B B 5 _ _ B B B B B B 6 _ _ _ B B _ _ _ 7 _ _ _ B B _ _ _ computer (O) choose your square: 0 1 2 3 4 5 6 7 0 B B B B B B B B 1 O O O O O O B B 2 B O O B O O O B 3 B B O O O O O B 4 B B B O O B O B 5 _ _ B B B O O B 6 _ _ _ B B _ O _ 7 _ _ _ B B _ _ _ b1 (B) choose your square: Enter the x coordinate: 7 Enter the y coordinate: 7 0 1 2 3 4 5 6 7 0 B B B B B B B B 1 O B O O O O B B 2 B O B B O O O B 3 B B O B O O O B 4 B B B O B B O B 5 _ _ B B B B O B 6 _ _ _ B B _ B _ 7 _ _ _ B B _ _ B computer (O) choose your square: 0 1 2 3 4 5 6 7 0 B B B B B B B B 1 O B O O O O B B 2 B O B B O O O B 3 B O O O O O O B 4 B O O O B B O B 5 _ O O O O O O B 6 _ _ _ B B _ B _ 7 _ _ _ B B _ _ B b1 (B) choose your square: Enter the x coordinate: 6 Enter the y coordinate: 7 0 1 2 3 4 5 6 7 0 B B B B B B B B 1 O B O O O O B B 2 B O B B O O O B 3 B O O O O O O B 4 B O O O B B O B 5 _ O O O O O B B

Page 19: MiniProject: Othello (Classes, Objects, and a smidge of random … · 17 hours ago · Othello: Description of Game For this lab you will be using classes and objects to program the

19

6 _ _ _ B B _ B B 7 _ _ _ B B _ _ B computer (O) choose your square: 0 1 2 3 4 5 6 7 0 B B B B B B B B 1 O B O O O O B B 2 O O B B O O O B 3 O O O O O O O B 4 O O O O B B O B 5 O O O O O O B B 6 _ _ _ B B _ B B 7 _ _ _ B B _ _ B b1 (B) choose your square: Enter the x coordinate: 6 Enter the y coordinate: 1 0 1 2 3 4 5 6 7 0 B B B B B B B B 1 O B O O O O B B 2 O B B B O B O B 3 O B O O B O O B 4 O B O B B B O B 5 O B B O O O B B 6 _ B _ B B _ B B 7 _ _ _ B B _ _ B computer (O) choose your square: 0 1 2 3 4 5 6 7 0 B B B B B B B B 1 O B O O O O B B 2 O B B B O B O B 3 O B O O B O O B 4 O B O B B B O B 5 O O O O O O B B 6 _ B O B B _ B B 7 _ _ _ B B _ _ B b1 (B) choose your square: Enter the x coordinate: 7 Enter the y coordinate: 2 0 1 2 3 4 5 6 7 0 B B B B B B B B 1 O B O O O O B B 2 O B B B O B O B 3 O B B O B O O B 4 O B B B B B O B 5 O O B O O O B B 6 _ B B B B _ B B 7 _ _ B B B _ _ B computer (O) choose your square: 0 1 2 3 4 5 6 7

Page 20: MiniProject: Othello (Classes, Objects, and a smidge of random … · 17 hours ago · Othello: Description of Game For this lab you will be using classes and objects to program the

20

0 B B B B B B B B 1 O B O O O O B B 2 O B B B O B O B 3 O B B O B O O B 4 O B B B B B O B 5 O O B O O O B B 6 _ O O B B _ B B 7 _ O B B B _ _ B b1 (B) choose your square: Enter the x coordinate: 7 Enter the y coordinate: 0 0 1 2 3 4 5 6 7 0 B B B B B B B B 1 O B O O O O B B 2 O B B B O B O B 3 O B B O B O O B 4 O B B B B B O B 5 O O B O O O B B 6 _ B O B B _ B B 7 B B B B B _ _ B computer (O) choose your square: 0 1 2 3 4 5 6 7 0 B B B B B B B B 1 O B O O O O B B 2 O B B B O B O B 3 O B B O B O O B 4 O B B B B B O B 5 O O B O O O B B 6 _ B O O O O B B 7 B B B B B _ _ B b1 (B) choose your square: Enter the x coordinate: 6 Enter the y coordinate: 0 0 1 2 3 4 5 6 7 0 B B B B B B B B 1 B B O O O O B B 2 B B B B O B O B 3 B B B O B O O B 4 B B B B B B O B 5 B B B O O O B B 6 B B O O O O B B 7 B B B B B _ _ B computer (O) choose your square: 0 1 2 3 4 5 6 7 0 B B B B B B B B 1 B B O O O O B B 2 B B B B O B O B 3 B B B O B O O B 4 B B B B B B O B

Page 21: MiniProject: Othello (Classes, Objects, and a smidge of random … · 17 hours ago · Othello: Description of Game For this lab you will be using classes and objects to program the

21

5 B B B O O O O B 6 B B O O O O O B 7 B B B B B _ O B b1 (B) choose your square: Enter the x coordinate: 7 Enter the y coordinate: 5 0 1 2 3 4 5 6 7 0 B B B B B B B B 1 B B O O O O B B 2 B B B B O B O B 3 B B B O B O O B 4 B B B B B B O B 5 B B B B O B O B 6 B B O O B B B B 7 B B B B B B B B computer (O) choose your square: computer forfeits turn

b1(B) won with: 50 versus 14