From 0278b943662931bf03ef30469fc921d8c1d1e74c Mon Sep 17 00:00:00 2001 From: Meg Stang Date: Tue, 2 Aug 2022 09:50:48 -0600 Subject: [PATCH 01/10] Update I1 and I2 to have interaction patterns --- module1/projects/connect_four/iteration_1.md | 132 +++++++++++--- module1/projects/connect_four/iteration_2.md | 175 +++++++++++++++++-- module1/projects/connect_four/iteration_3.md | 16 +- 3 files changed, 285 insertions(+), 38 deletions(-) diff --git a/module1/projects/connect_four/iteration_1.md b/module1/projects/connect_four/iteration_1.md index 03e890a6c..7356ff381 100644 --- a/module1/projects/connect_four/iteration_1.md +++ b/module1/projects/connect_four/iteration_1.md @@ -1,6 +1,6 @@ --- layout: page -title: Iteration 1 - Game Board +title: Iteration 1 - Chip and Cell --- _[Back to Connect Four Home](./index)_ @@ -10,30 +10,118 @@ _[Back to Requirements](./requirements)_ In this iteration, you are required to use TDD to create your classes. Use the interaction pattern to determine what a method should do and write one or more tests to verify that expected behavior. Then you can implement the method. You should always write code with the purpose of making a test pass. -## Printing the Board +## Cell -When a user runs the command to start the game, they will see a welcome message, followed by an empty board. The board itself will represent empty spaces with periods and column names with a letter A-G. +A Cell object represents the space where a chip could be placed on the Connect 4 board. We will be able to read it's column letter and row number, as well as it's display value. It will also have behavior to fill in the cell with a new value. -``` -ABCDEFG -....... -....... -....... -....... -....... -....... +The Cell class should follow this interaction pattern: + +```ruby +pry(main)> require './lib/cell' +# => true +pry(main)> a1 = Cell.new("A1") +# => # +pry(main)> b3 = Cell.new("B3") +# => # +pry(main)> a1.placement +# => "A1" +pry(main)> a1.column +# => "A" +pry(main)> a1.row +# => 1 +pry(main)> a1.value +# => "." +pry(main)> a1.filled? +# => false +pry(main)> a1.fill("X") +# => "X" +pry(main)> a1.value +# => "X" +pry(main)> a1.filled? +# => true +pry(main)> b3.fill("O") +# => "O" +pry(main)> b3.value +# => "O" +pry(main)> b3.filled? +# => true ``` -Player pieces will be represented by X's, while computer pieces will be represented by O's. A board later in the game might look something like the following: +## Board -``` -ABCDEFG -....... -....... -O...... -X.O...O -XXOX..X -XOOXOOX -``` +The Board class is responsible for keeping track of each cell on the board and validating 4 in a row. -For Iteration 1, students should have a program that will print out a welcome message and an empty board. +Follow the interaction pattern below to build out the board's display: + +### Board Display + +```ruby +[1] pry(main)> require './lib/chip' +=> true +[2] pry(main)> require './lib/cell' +=> true +[3] pry(main)> require './lib/board' +=> true +[4] pry(main)> a_cells = [Cell.new("A1"),Cell.new("A2"),Cell.new("A3"),Cell.new("A4"),Cell.new("A5"),Cell.new("A6")] +[5] pry(main)> b_cells = [Cell.new("B1"),Cell.new("B2"),Cell.new("B3"),Cell.new("B4"),Cell.new("B5"),Cell.new("B6")] +[6] pry(main)> c_cells = [Cell.new("C1"),Cell.new("C2"),Cell.new("C3"),Cell.new("C4"),Cell.new("C5"),Cell.new("C6")] +[7] pry(main)> d_cells = [Cell.new("D1"),Cell.new("D2"),Cell.new("D3"),Cell.new("D4"),Cell.new("D5"),Cell.new("D6")] +[8] pry(main)> e_cells = [Cell.new("E1"),Cell.new("E2"),Cell.new("E3"),Cell.new("E4"),Cell.new("E5"),Cell.new("E6")] +[9] pry(main)> f_cells = [Cell.new("F1"),Cell.new("F2"),Cell.new("F3"),Cell.new("F4"),Cell.new("F5"),Cell.new("F6")] +[10] pry(main)> g_cells = [Cell.new("G1"),Cell.new("G2"),Cell.new("G3"),Cell.new("G4"),Cell.new("G5"),Cell.new("G6")] +[11] pry(main)> columns = {A: a_cells, B: b_cells, C: c_cells, D: d_cells, E: e_cells, F: f_cells, G: g_cells} +[12] pry(main)> board = Board.new(columns) +=> # +[13] pry(main)> board.columns +=> {:A=> + [#, + #, + #, + #, + #, + #], + :B=> + [#, + #, + #, + #, + #, + #], + :C=> + [#, + #, + #, + #, + #, + #], + :D=> + [#, + #, + #, + #, + #, + #], + :E=> + [#, + #, + #, + #, + #, + #], + :F=> + [#, + #, + #, + #, + #, + #], + :G=> + [#, + #, + #, + #, + #, + #]} +[16] pry(main)> board.render_board +=> "A B C D E F G\n. . . . . . .\n. . . . . . .\n. . . . . . .\n. . . . . . .\n. . . . . . .\n. . . . . . ." +``` diff --git a/module1/projects/connect_four/iteration_2.md b/module1/projects/connect_four/iteration_2.md index 710ddd652..6d0061e93 100644 --- a/module1/projects/connect_four/iteration_2.md +++ b/module1/projects/connect_four/iteration_2.md @@ -1,6 +1,6 @@ --- layout: page -title: Iteration 2 - Placing Pieces +title: Iteration 2 - The Board --- _[Back to Connect Four Home](./index)_ @@ -10,24 +10,171 @@ _[Back to Requirements](./requirements)_ In this iteration, you are required to use TDD to create your classes. Use the interaction pattern to determine what a method should do and write one or more tests to verify that expected behavior. Then you can implement the method. You should always write code with the purpose of making a test pass. -## Placing Pieces +## Board -Update your program to request user input and allow them to place an individual piece. +The Board class is responsible for keeping track of each cell on the board and validating 4 in a row. -Your program should ask the user to enter a letter A-G. -Update the board to display the player's piece in the lowest available position of the selected column with an 'X'. +Follow the interaction pattern below to build out the functionality for placing a chip on the board: -The computer takes its turn by selecting one of the 7 columns at random. Update the board to display the computer's piece in the lowest available position of the selected column with an 'O'. -The player and computer should be able to repeat this sequence and continue taking turns. +### Place Chip On Board -### Invalid Column Selection +```ruby +pry(main)> require './lib/cell' +# => true +pry(main)> require './lib/board' +# => true +pry(main)> a_cells = [Cell.new("A1"),Cell.new("A2"),Cell.new("A3"),Cell.new("A4"),Cell.new("A5"),Cell.new("A6")] +pry(main)> b_cells = [Cell.new("B1"),Cell.new("B2"),Cell.new("B3"),Cell.new("B4"),Cell.new("B5"),Cell.new("B6")] +pry(main)> c_cells = [Cell.new("C1"),Cell.new("C2"),Cell.new("C3"),Cell.new("C4"),Cell.new("C5"),Cell.new("C6")] +pry(main)> d_cells = [Cell.new("D1"),Cell.new("D2"),Cell.new("D3"),Cell.new("D4"),Cell.new("D5"),Cell.new("D6")] +pry(main)> e_cells = [Cell.new("E1"),Cell.new("E2"),Cell.new("E3"),Cell.new("E4"),Cell.new("E5"),Cell.new("E6")] +pry(main)> f_cells = [Cell.new("F1"),Cell.new("F2"),Cell.new("F3"),Cell.new("F4"),Cell.new("F5"),Cell.new("F6")] +pry(main)> g_cells = [Cell.new("G1"),Cell.new("G2"),Cell.new("G3"),Cell.new("G4"),Cell.new("G5"),Cell.new("G6")] +pry(main)> columns = {A: a_cells, B: b_cells, C: c_cells, D: d_cells, E: e_cells, F: f_cells, G: g_cells} +pry(main)> board = Board.new(columns) +pry(main)> board.place_chip("A", "X") +pry(main)> board.render_board +# => "A B C D E F G\n. . . . . . .\n. . . . . . .\n. . . . . . .\n. . . . . . .\n. . . . . . .\nX . . . . . ." +pry(main)> board.place_chip("A", "O") +pry(main)> board.render_board +# => "A B C D E F G\n. . . . . . .\n. . . . . . .\n. . . . . . .\n. . . . . . .\nO . . . . . .\nX . . . . . ." +pry(main)> board.place_chip("D", "X") +pry(main)> board.render_board +# => "A B C D E F G\n. . . . . . .\n. . . . . . .\n. . . . . . .\n. . . . . . .\nO . . . . . .\nX . . X . . ." +pry(main)> board.place_chip("C", "O") +pry(main)> board.render_board +# => "A B C D E F G\n. . . . . . .\n. . . . . . .\n. . . . . . .\n. . . . . . .\nO . . . . . .\nX . O X . . ." -Neither the player nor computer should be able to play in an invalid column. An invalid column is defined as one of the following: -1. Outside the range A-G -1. Full, i.e. there is no available position in the column +``` -If an invalid column is selected by the player, the program should display an error message and ask the player to select a valid column. The program should repeat this process until a valid column is selected. -* The one exception is when there are no valid columns available; i.e. the game board is full. In this case, the game is a draw, an endgame condition. -If an invalid column is selected by the computer, the program should repeat until a valid column is selected. No error message should display to the user when the computer selects an invalid column. +### Validate 4 Across + +```ruby +pry(main)> c3 = board.columns[:C][2] +# => # +pry(main)> e2 = board.columns[:E][1] +# => # +pry(main)> board.row_for(c3) +# => [#, + #, + #, + #, + #, + #, + #] +pry(main)> board.column_for(c3) +# => [#, + #, + #, + #, + #, + #] +pry(main)> board.diagonal_for(c3) +# => [#, + #, + #, + #, + #, + #] +pry(main)> board.row_for(e2) +# => [#, + #, + #, + #, + #, + #, + #] +pry(main)> board.column_for(e2) +# => [#, + #, + #, + #, + #, + #] +pry(main)> board.diagonal_for(e2) +# => [#, + #, + #, + #] +pry(main)> a1 = board.columns[:A][0] +# => # +pry(main)> a2 = board.columns[:A][1] +# => # +pry(main)> a3 = board.columns[:A][2] +# => # +pry(main)> a4 = board.columns[:A][3] +# => # +pry(main)> a1.fill("X") +# => "X" +pry(main)> a2.fill("X") +# => "X" +pry(main)> a3.fill("X") +# => "X" +pry(main)> column_a = board.column_for(a3) +# => [#, + #, + #, + #, + #, + #] +pry(main)> board.check_for_four(column_a) +# => false +pry(main)> a4.fill("X") +# => "X" +pry(main)> board.check_for_four(column_a) +# => true +pry(main)> b1 = board.columns[:B][0] +# => # +pry(main)> c1 = board.columns[:C][0] +# => # +pry(main)> d1 = board.columns[:D][0] +# => # +pry(main)> e1 = board.columns[:E][0] +# => # +pry(main)> b1.fill("O") +# => "O" +pry(main)> c1.fill("O") +# => "O" +pry(main)> d1.fill("O") +# => "O" +pry(main)> row_1 = board.row_for(e1) +# => [#, + #, + #, + #, + #, + #, + #] +pry(main)> board.check_for_four(row_1) +# => false +pry(main)> e1.fill("O") +# => "O" +pry(main)> board.check_for_four(row_1) +# => true +pry(main)> b2 = board.columns[:B][1] +# => # +pry(main)> c3 = board.columns[:C][2] +# => # +pry(main)> d4 = board.columns[:D][3] +# => # +pry(main)> b2.fill("X") +# => "X" +pry(main)> c3.fill("X") +# => "X" +pry(main)> diagonal = board.diagonal_for(d4) +# => [#, + #, + #, + #, + #, + #] +pry(main)> board.check_for_four(diagonal) +# => false +pry(main)> d4.fill("X") +# => "X" +pry(main)> board.check_for_four(diagonal) +# => true +``` + diff --git a/module1/projects/connect_four/iteration_3.md b/module1/projects/connect_four/iteration_3.md index 66b113d42..4e3750be6 100644 --- a/module1/projects/connect_four/iteration_3.md +++ b/module1/projects/connect_four/iteration_3.md @@ -6,7 +6,7 @@ title: Iteration 3 - Playing the Game _[Back to Connect Four Home](./index)_ _[Back to Requirements](./requirements)_ -Now it's time to put together the components you've built in the last two iterations to make a working game. You are allowed to build any additional classes or methods you think may be useful to accomplish this. However, this project will be assessed on the spec outlined in the last two iterations, so don't remove any of the functionality from previously built classes. +Now it's time to put together the components you've built in the last two iterations to make a working game. You are allowed to build any additional classes or methods you think may be useful to accomplish this. You might also run into instances where it would make sense to refactor some methods that you already built in the first two iterations. You are not expected to test anything related to user input and output in this iteration, but try to use TDD as much as possible to help you design your solution. @@ -29,7 +29,18 @@ Once the User has chosen to play, display a new game board and ask the player to ### Placing Pieces -The player starts the game by placing their first piece in a valid column. The computer then places their first piece in a randomly selected valid column. The player and computer should repeat this sequence and continue taking turns until an endgame condition is met. +Your program will request user input and allow them to place an individual piece. + +Your program should ask the user to enter a letter A-G. +Update the board to display the player's piece in the lowest available position of the selected column with an 'X'. + +The computer takes its turn by selecting one of the 7 columns at random. Update the board to display the computer's piece in the lowest available position of the selected column with an 'O'. + +The player and computer should be able to repeat this sequence and continue taking turns. + +If an invalid column is selected by the player, the program should display an error message and ask the player to select a valid column. The program should repeat this process until a valid column is selected. + +If an invalid column is selected by the computer, the program should repeat until a valid column is selected. No error message should display to the user when the computer selects an invalid column. ### End of Game @@ -75,3 +86,4 @@ This checklist summarizes all of the functionality you are expected to build. Th * The player cannot select a valid column. * The program reports the appropriate endgame status * Game returns user back to the Main Menu + From 759e582f699af1b7fc1ae21226e97442a7380692 Mon Sep 17 00:00:00 2001 From: Meg Stang Date: Tue, 2 Aug 2022 09:57:41 -0600 Subject: [PATCH 02/10] Update Iteration description --- module1/projects/connect_four/iteration_1.md | 2 +- module1/projects/connect_four/iteration_2.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/module1/projects/connect_four/iteration_1.md b/module1/projects/connect_four/iteration_1.md index 7356ff381..3685dfb1f 100644 --- a/module1/projects/connect_four/iteration_1.md +++ b/module1/projects/connect_four/iteration_1.md @@ -1,6 +1,6 @@ --- layout: page -title: Iteration 1 - Chip and Cell +title: Iteration 1 - Cell and Board Render --- _[Back to Connect Four Home](./index)_ diff --git a/module1/projects/connect_four/iteration_2.md b/module1/projects/connect_four/iteration_2.md index 6d0061e93..7e4c115d7 100644 --- a/module1/projects/connect_four/iteration_2.md +++ b/module1/projects/connect_four/iteration_2.md @@ -1,6 +1,6 @@ --- layout: page -title: Iteration 2 - The Board +title: Iteration 2 - Placing Chips and Validating Four Across --- _[Back to Connect Four Home](./index)_ From 50bb7f88692f80d5f90dd7de51bb2492714f2c80 Mon Sep 17 00:00:00 2001 From: Meg Stang Date: Tue, 2 Aug 2022 10:25:17 -0600 Subject: [PATCH 03/10] Fix pry session formatting --- module1/projects/connect_four/iteration_1.md | 40 ++++++++++---------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/module1/projects/connect_four/iteration_1.md b/module1/projects/connect_four/iteration_1.md index 3685dfb1f..d1554cbd8 100644 --- a/module1/projects/connect_four/iteration_1.md +++ b/module1/projects/connect_four/iteration_1.md @@ -56,24 +56,24 @@ Follow the interaction pattern below to build out the board's display: ### Board Display ```ruby -[1] pry(main)> require './lib/chip' -=> true -[2] pry(main)> require './lib/cell' -=> true -[3] pry(main)> require './lib/board' -=> true -[4] pry(main)> a_cells = [Cell.new("A1"),Cell.new("A2"),Cell.new("A3"),Cell.new("A4"),Cell.new("A5"),Cell.new("A6")] -[5] pry(main)> b_cells = [Cell.new("B1"),Cell.new("B2"),Cell.new("B3"),Cell.new("B4"),Cell.new("B5"),Cell.new("B6")] -[6] pry(main)> c_cells = [Cell.new("C1"),Cell.new("C2"),Cell.new("C3"),Cell.new("C4"),Cell.new("C5"),Cell.new("C6")] -[7] pry(main)> d_cells = [Cell.new("D1"),Cell.new("D2"),Cell.new("D3"),Cell.new("D4"),Cell.new("D5"),Cell.new("D6")] -[8] pry(main)> e_cells = [Cell.new("E1"),Cell.new("E2"),Cell.new("E3"),Cell.new("E4"),Cell.new("E5"),Cell.new("E6")] -[9] pry(main)> f_cells = [Cell.new("F1"),Cell.new("F2"),Cell.new("F3"),Cell.new("F4"),Cell.new("F5"),Cell.new("F6")] -[10] pry(main)> g_cells = [Cell.new("G1"),Cell.new("G2"),Cell.new("G3"),Cell.new("G4"),Cell.new("G5"),Cell.new("G6")] -[11] pry(main)> columns = {A: a_cells, B: b_cells, C: c_cells, D: d_cells, E: e_cells, F: f_cells, G: g_cells} -[12] pry(main)> board = Board.new(columns) -=> # -[13] pry(main)> board.columns -=> {:A=> +pry(main)> require './lib/chip' +# => true +pry(main)> require './lib/cell' +# => true +pry(main)> require './lib/board' +# => true +pry(main)> a_cells = [Cell.new("A1"),Cell.new("A2"),Cell.new("A3"),Cell.new("A4"),Cell.new("A5"),Cell.new("A6")] +pry(main)> b_cells = [Cell.new("B1"),Cell.new("B2"),Cell.new("B3"),Cell.new("B4"),Cell.new("B5"),Cell.new("B6")] +pry(main)> c_cells = [Cell.new("C1"),Cell.new("C2"),Cell.new("C3"),Cell.new("C4"),Cell.new("C5"),Cell.new("C6")] +pry(main)> d_cells = [Cell.new("D1"),Cell.new("D2"),Cell.new("D3"),Cell.new("D4"),Cell.new("D5"),Cell.new("D6")] +pry(main)> e_cells = [Cell.new("E1"),Cell.new("E2"),Cell.new("E3"),Cell.new("E4"),Cell.new("E5"),Cell.new("E6")] +pry(main)> f_cells = [Cell.new("F1"),Cell.new("F2"),Cell.new("F3"),Cell.new("F4"),Cell.new("F5"),Cell.new("F6")] +pry(main)> g_cells = [Cell.new("G1"),Cell.new("G2"),Cell.new("G3"),Cell.new("G4"),Cell.new("G5"),Cell.new("G6")] +pry(main)> columns = {A: a_cells, B: b_cells, C: c_cells, D: d_cells, E: e_cells, F: f_cells, G: g_cells} +pry(main)> board = Board.new(columns) +# => # +pry(main)> board.columns +# => {:A=> [#, #, #, @@ -122,6 +122,6 @@ Follow the interaction pattern below to build out the board's display: #, #, #]} -[16] pry(main)> board.render_board -=> "A B C D E F G\n. . . . . . .\n. . . . . . .\n. . . . . . .\n. . . . . . .\n. . . . . . .\n. . . . . . ." +pry(main)> board.render_board +# => "A B C D E F G\n. . . . . . .\n. . . . . . .\n. . . . . . .\n. . . . . . .\n. . . . . . .\n. . . . . . ." ``` From 4ceee19cc62acaf587965e6c895568c21c07b6fc Mon Sep 17 00:00:00 2001 From: Meg Stang Date: Tue, 2 Aug 2022 10:26:30 -0600 Subject: [PATCH 04/10] Add board set up for interaction pattern --- module1/projects/connect_four/iteration_2.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/module1/projects/connect_four/iteration_2.md b/module1/projects/connect_four/iteration_2.md index 7e4c115d7..633e22e3d 100644 --- a/module1/projects/connect_four/iteration_2.md +++ b/module1/projects/connect_four/iteration_2.md @@ -52,6 +52,19 @@ pry(main)> board.render_board ### Validate 4 Across ```ruby +pry(main)> require './lib/cell' +# => true +pry(main)> require './lib/board' +# => true +pry(main)> a_cells = [Cell.new("A1"),Cell.new("A2"),Cell.new("A3"),Cell.new("A4"),Cell.new("A5"),Cell.new("A6")] +pry(main)> b_cells = [Cell.new("B1"),Cell.new("B2"),Cell.new("B3"),Cell.new("B4"),Cell.new("B5"),Cell.new("B6")] +pry(main)> c_cells = [Cell.new("C1"),Cell.new("C2"),Cell.new("C3"),Cell.new("C4"),Cell.new("C5"),Cell.new("C6")] +pry(main)> d_cells = [Cell.new("D1"),Cell.new("D2"),Cell.new("D3"),Cell.new("D4"),Cell.new("D5"),Cell.new("D6")] +pry(main)> e_cells = [Cell.new("E1"),Cell.new("E2"),Cell.new("E3"),Cell.new("E4"),Cell.new("E5"),Cell.new("E6")] +pry(main)> f_cells = [Cell.new("F1"),Cell.new("F2"),Cell.new("F3"),Cell.new("F4"),Cell.new("F5"),Cell.new("F6")] +pry(main)> g_cells = [Cell.new("G1"),Cell.new("G2"),Cell.new("G3"),Cell.new("G4"),Cell.new("G5"),Cell.new("G6")] +pry(main)> columns = {A: a_cells, B: b_cells, C: c_cells, D: d_cells, E: e_cells, F: f_cells, G: g_cells} +pry(main)> board = Board.new(columns) pry(main)> c3 = board.columns[:C][2] # => # pry(main)> e2 = board.columns[:E][1] From 51690859b2870bc32e87c8dd03a2cb1ed3146a6e Mon Sep 17 00:00:00 2001 From: Meg Stang Date: Tue, 2 Aug 2022 10:27:12 -0600 Subject: [PATCH 05/10] Remove require for chip class --- module1/projects/connect_four/iteration_1.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/module1/projects/connect_four/iteration_1.md b/module1/projects/connect_four/iteration_1.md index d1554cbd8..fce5eeca5 100644 --- a/module1/projects/connect_four/iteration_1.md +++ b/module1/projects/connect_four/iteration_1.md @@ -56,8 +56,6 @@ Follow the interaction pattern below to build out the board's display: ### Board Display ```ruby -pry(main)> require './lib/chip' -# => true pry(main)> require './lib/cell' # => true pry(main)> require './lib/board' From d93730a08a331bbb347646888b9eb788efb7fdb9 Mon Sep 17 00:00:00 2001 From: Meg Stang Date: Tue, 2 Aug 2022 10:37:48 -0600 Subject: [PATCH 06/10] Slim up and update the IP to only show return values for f functions that they're working on --- module1/projects/connect_four/iteration_2.md | 75 +++++--------------- 1 file changed, 17 insertions(+), 58 deletions(-) diff --git a/module1/projects/connect_four/iteration_2.md b/module1/projects/connect_four/iteration_2.md index 633e22e3d..30e4f119f 100644 --- a/module1/projects/connect_four/iteration_2.md +++ b/module1/projects/connect_four/iteration_2.md @@ -77,20 +77,6 @@ pry(main)> board.row_for(c3) #, #, #] -pry(main)> board.column_for(c3) -# => [#, - #, - #, - #, - #, - #] -pry(main)> board.diagonal_for(c3) -# => [#, - #, - #, - #, - #, - #] pry(main)> board.row_for(e2) # => [#, #, @@ -99,6 +85,13 @@ pry(main)> board.row_for(e2) #, #, #] +pry(main)> board.column_for(c3) +# => [#, + #, + #, + #, + #, + #] pry(main)> board.column_for(e2) # => [#, #, @@ -106,87 +99,53 @@ pry(main)> board.column_for(e2) #, #, #] +pry(main)> board.diagonal_for(c3) +# => [#, + #, + #, + #, + #, + #] pry(main)> board.diagonal_for(e2) # => [#, #, #, #] pry(main)> a1 = board.columns[:A][0] -# => # pry(main)> a2 = board.columns[:A][1] -# => # pry(main)> a3 = board.columns[:A][2] -# => # pry(main)> a4 = board.columns[:A][3] -# => # +pry(main)> column_a = board.column_for(a1) # we could have also used any cell from column A here. pry(main)> a1.fill("X") -# => "X" pry(main)> a2.fill("X") -# => "X" pry(main)> a3.fill("X") -# => "X" -pry(main)> column_a = board.column_for(a3) -# => [#, - #, - #, - #, - #, - #] pry(main)> board.check_for_four(column_a) # => false pry(main)> a4.fill("X") -# => "X" pry(main)> board.check_for_four(column_a) # => true pry(main)> b1 = board.columns[:B][0] -# => # pry(main)> c1 = board.columns[:C][0] -# => # pry(main)> d1 = board.columns[:D][0] -# => # pry(main)> e1 = board.columns[:E][0] -# => # pry(main)> b1.fill("O") -# => "O" pry(main)> c1.fill("O") -# => "O" pry(main)> d1.fill("O") -# => "O" -pry(main)> row_1 = board.row_for(e1) -# => [#, - #, - #, - #, - #, - #, - #] +pry(main)> row_1 = board.row_for(e1) # we could have also used any cell from row 1 here. pry(main)> board.check_for_four(row_1) # => false pry(main)> e1.fill("O") -# => "O" pry(main)> board.check_for_four(row_1) # => true pry(main)> b2 = board.columns[:B][1] -# => # pry(main)> c3 = board.columns[:C][2] -# => # pry(main)> d4 = board.columns[:D][3] -# => # pry(main)> b2.fill("X") -# => "X" pry(main)> c3.fill("X") -# => "X" -pry(main)> diagonal = board.diagonal_for(d4) -# => [#, - #, - #, - #, - #, - #] +pry(main)> diagonal = board.diagonal_for(d4) # we coul dhave also used any cell that woul dhave been on this diagonal. pry(main)> board.check_for_four(diagonal) # => false pry(main)> d4.fill("X") -# => "X" pry(main)> board.check_for_four(diagonal) # => true ``` From a1fa4de0f57c08361290a8994712c60417deae62 Mon Sep 17 00:00:00 2001 From: Meg Stang Date: Tue, 2 Aug 2022 10:40:25 -0600 Subject: [PATCH 07/10] Add more description for what IP is testing --- module1/projects/connect_four/iteration_2.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/module1/projects/connect_four/iteration_2.md b/module1/projects/connect_four/iteration_2.md index 30e4f119f..5cd67788a 100644 --- a/module1/projects/connect_four/iteration_2.md +++ b/module1/projects/connect_four/iteration_2.md @@ -111,6 +111,9 @@ pry(main)> board.diagonal_for(e2) #, #, #] + + +# Check for connect 4 in a column: pry(main)> a1 = board.columns[:A][0] pry(main)> a2 = board.columns[:A][1] pry(main)> a3 = board.columns[:A][2] @@ -124,6 +127,8 @@ pry(main)> board.check_for_four(column_a) pry(main)> a4.fill("X") pry(main)> board.check_for_four(column_a) # => true + +# Check for connect 4 in a row: pry(main)> b1 = board.columns[:B][0] pry(main)> c1 = board.columns[:C][0] pry(main)> d1 = board.columns[:D][0] @@ -137,6 +142,8 @@ pry(main)> board.check_for_four(row_1) pry(main)> e1.fill("O") pry(main)> board.check_for_four(row_1) # => true + +# Check for connect 4 in a diagonal: pry(main)> b2 = board.columns[:B][1] pry(main)> c3 = board.columns[:C][2] pry(main)> d4 = board.columns[:D][3] From bce3453938d15a5d0b7d65ee95707a880d843389 Mon Sep 17 00:00:00 2001 From: Meg Stang Date: Tue, 2 Aug 2022 11:03:25 -0600 Subject: [PATCH 08/10] Remove unnecessary part of ip --- module1/projects/connect_four/iteration_2.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/module1/projects/connect_four/iteration_2.md b/module1/projects/connect_four/iteration_2.md index 5cd67788a..c48b64884 100644 --- a/module1/projects/connect_four/iteration_2.md +++ b/module1/projects/connect_four/iteration_2.md @@ -66,9 +66,7 @@ pry(main)> g_cells = [Cell.new("G1"),Cell.new("G2"),Cell.new("G3"),Cell.new("G4" pry(main)> columns = {A: a_cells, B: b_cells, C: c_cells, D: d_cells, E: e_cells, F: f_cells, G: g_cells} pry(main)> board = Board.new(columns) pry(main)> c3 = board.columns[:C][2] -# => # pry(main)> e2 = board.columns[:E][1] -# => # pry(main)> board.row_for(c3) # => [#, #, From 036ee05a7367ac9a6f325549f9341995e29bea87 Mon Sep 17 00:00:00 2001 From: Meg Stang Date: Tue, 2 Aug 2022 11:06:25 -0600 Subject: [PATCH 09/10] Fix typo --- module1/projects/connect_four/iteration_2.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/module1/projects/connect_four/iteration_2.md b/module1/projects/connect_four/iteration_2.md index c48b64884..cdc4ad624 100644 --- a/module1/projects/connect_four/iteration_2.md +++ b/module1/projects/connect_four/iteration_2.md @@ -147,11 +147,11 @@ pry(main)> c3 = board.columns[:C][2] pry(main)> d4 = board.columns[:D][3] pry(main)> b2.fill("X") pry(main)> c3.fill("X") -pry(main)> diagonal = board.diagonal_for(d4) # we coul dhave also used any cell that woul dhave been on this diagonal. +pry(main)> diagonal = board.diagonal_for(d4) # we could have also used any cell that would have been on this diagonal. pry(main)> board.check_for_four(diagonal) # => false pry(main)> d4.fill("X") -pry(main)> board.check_for_four(diagonal) +pry(main)> board.check_for_four(diagonal) #note: a1 was already filled in with "X" earlier in this interaction pattern # => true ``` From 1494470dc08e31dc5f4a64f1c1db1ee47bf2a441 Mon Sep 17 00:00:00 2001 From: Abdul Redd <104014874+abdulredd@users.noreply.github.com> Date: Sun, 14 Aug 2022 14:38:55 -0400 Subject: [PATCH 10/10] Update module1/projects/connect_four/iteration_1.md Co-authored-by: Erin Pintozzi --- module1/projects/connect_four/iteration_1.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/module1/projects/connect_four/iteration_1.md b/module1/projects/connect_four/iteration_1.md index fce5eeca5..b28186a8e 100644 --- a/module1/projects/connect_four/iteration_1.md +++ b/module1/projects/connect_four/iteration_1.md @@ -12,7 +12,7 @@ In this iteration, you are required to use TDD to create your classes. Use the i ## Cell -A Cell object represents the space where a chip could be placed on the Connect 4 board. We will be able to read it's column letter and row number, as well as it's display value. It will also have behavior to fill in the cell with a new value. +A Cell object represents the space where a chip could be placed on the Connect 4 board. We will be able to read its column letter and row number, as well as its display value. It will also have behavior to fill in the cell with a new value. The Cell class should follow this interaction pattern: