SlideShare a Scribd company logo
1 of 1
Download to read offline
I have to write a Connect Four game program. When a player takes their turn, they will select a
column in which to place a token. The token is placed at the top of the column and is allowed to
fall to the bottom, stacking on top of any previously placed tokens. Two players take turns placing
token colors of red or yellow. The first person to create four of their color token in a row,
horizontally or vertically, (NOT diagonally in this problem) wins and the game is over.
The program will display the board (7 columns and 6 rows), then ask for alternating players to
place a token in column 0 through 6. The process repeats until one player wins. You do not need
to check for a tie game, or if there is space in a chosen column.
The photos (shown below) contain the code for the game framework. It is required that I utilize
functions and write my code within the functions. The function signatures are provided for you in
the framework. Examine each one to see what will be needed by the end. I am given 2 functions to
start with: main() and display(board).
Part 1: Fill out the code for the placeToken function. It is given three parameters: (1) the board,
(2) the column in which to place a token, and (3) the token itself. The board is the two dimensional
list of characters, with spaces ' ' being empty locations. The column is a numerical index in which
to place the token, and the token is the character 'R' or 'Y'.
Start at the top row (index 0) and move down the rows until the row below is not ' ', then place the
token. Then return the row the token ended up in. You can test this out by running the program,
but the game won't end yet because the other functions are incomplete. Use control+C (command
+ C) to stop the game early.
Another way to approach this is to start at the bottom row and walk upwards until the space is ' '.
Part 2: Fill out the code for the winningMove function. The game is won if four tokens of the
same color line up either vertically or horizontally. Good functional design would have these
checks in their own functions. Fill in the code for winningMove such that it uses the 2 other check
functions (below). This function can be one line of code. The row and column parameters are the
location of the last move taken.
Part 3: Fill in the code for checkVertical, which checks for four in a line vertically (on the same
column) as the given row and column parameters. You only need to search outward from the row
and column parameters and not the whole board. Since new moves are controlled by gravity in
connect four, you only need to search downward. You can test if this is working by running the
program.
Part 4: Fill in the code for checkHorizontal, which checks for four in a line horizontally (on the
same row) as the given row and column parameters. You only need to search outward from the
row and column parameters and not the whole board. You can test if this is working by running the
program.
The last photo shows an example run.

More Related Content

Similar to I have to write a Connect Four game program When a player t.pdf

Create a Java non-GUI stand-alone application that displays a histog
Create a Java non-GUI stand-alone application that displays a histogCreate a Java non-GUI stand-alone application that displays a histog
Create a Java non-GUI stand-alone application that displays a histogkedsliemichal
 
Artificial intelligence - python
Artificial intelligence - pythonArtificial intelligence - python
Artificial intelligence - pythonSunjid Hasan
 
This assignment is using Logism to create circuits. I have been tryi.pdf
This assignment is using Logism to create circuits. I have been tryi.pdfThis assignment is using Logism to create circuits. I have been tryi.pdf
This assignment is using Logism to create circuits. I have been tryi.pdfambikacomputer4301
 
50g working with matricies
50g  working with matricies50g  working with matricies
50g working with matriciesEfrain Parizaca
 
Tutorial 04 (revised) (1)
Tutorial 04 (revised) (1)Tutorial 04 (revised) (1)
Tutorial 04 (revised) (1)IIUM
 
Hey i have attached the required file for my assignment.and addi
Hey i have attached the required file for my assignment.and addiHey i have attached the required file for my assignment.and addi
Hey i have attached the required file for my assignment.and addisorayan5ywschuit
 
Cse 402 offline b2
Cse 402 offline b2Cse 402 offline b2
Cse 402 offline b2sujoyhnkc
 
Please make the complete program, Distinguish between header files a.pdf
Please make the complete program, Distinguish between header files a.pdfPlease make the complete program, Distinguish between header files a.pdf
Please make the complete program, Distinguish between header files a.pdfSALES97
 
Excel Tutorials - Random Value Selection from a List
Excel Tutorials - Random Value Selection from a ListExcel Tutorials - Random Value Selection from a List
Excel Tutorials - Random Value Selection from a ListMerve Nur Taş
 
CVE 156 lecture 3.pdf
CVE 156 lecture 3.pdfCVE 156 lecture 3.pdf
CVE 156 lecture 3.pdfSomayyaAnsary
 
Assignment Poblems
Assignment Poblems Assignment Poblems
Assignment Poblems vkabre
 
This assignment will have two circuits A main circuit that .pdf
This assignment will have two circuits A main circuit that .pdfThis assignment will have two circuits A main circuit that .pdf
This assignment will have two circuits A main circuit that .pdfadislifestyle
 
This is an individual project, to be completed on your own. It i.docx
This is an individual project, to be completed on your own. It i.docxThis is an individual project, to be completed on your own. It i.docx
This is an individual project, to be completed on your own. It i.docxabhi353063
 

Similar to I have to write a Connect Four game program When a player t.pdf (15)

Create a Java non-GUI stand-alone application that displays a histog
Create a Java non-GUI stand-alone application that displays a histogCreate a Java non-GUI stand-alone application that displays a histog
Create a Java non-GUI stand-alone application that displays a histog
 
Artificial intelligence - python
Artificial intelligence - pythonArtificial intelligence - python
Artificial intelligence - python
 
This assignment is using Logism to create circuits. I have been tryi.pdf
This assignment is using Logism to create circuits. I have been tryi.pdfThis assignment is using Logism to create circuits. I have been tryi.pdf
This assignment is using Logism to create circuits. I have been tryi.pdf
 
50g working with matricies
50g  working with matricies50g  working with matricies
50g working with matricies
 
Tutorial 04 (revised) (1)
Tutorial 04 (revised) (1)Tutorial 04 (revised) (1)
Tutorial 04 (revised) (1)
 
Hey i have attached the required file for my assignment.and addi
Hey i have attached the required file for my assignment.and addiHey i have attached the required file for my assignment.and addi
Hey i have attached the required file for my assignment.and addi
 
Cse 402 offline b2
Cse 402 offline b2Cse 402 offline b2
Cse 402 offline b2
 
DRAWING LINES.pptx
DRAWING LINES.pptxDRAWING LINES.pptx
DRAWING LINES.pptx
 
Please make the complete program, Distinguish between header files a.pdf
Please make the complete program, Distinguish between header files a.pdfPlease make the complete program, Distinguish between header files a.pdf
Please make the complete program, Distinguish between header files a.pdf
 
Excel Tutorials - Random Value Selection from a List
Excel Tutorials - Random Value Selection from a ListExcel Tutorials - Random Value Selection from a List
Excel Tutorials - Random Value Selection from a List
 
CVE 156 lecture 3.pdf
CVE 156 lecture 3.pdfCVE 156 lecture 3.pdf
CVE 156 lecture 3.pdf
 
Assignment Poblems
Assignment Poblems Assignment Poblems
Assignment Poblems
 
Shoot-for-A-Star
Shoot-for-A-StarShoot-for-A-Star
Shoot-for-A-Star
 
This assignment will have two circuits A main circuit that .pdf
This assignment will have two circuits A main circuit that .pdfThis assignment will have two circuits A main circuit that .pdf
This assignment will have two circuits A main circuit that .pdf
 
This is an individual project, to be completed on your own. It i.docx
This is an individual project, to be completed on your own. It i.docxThis is an individual project, to be completed on your own. It i.docx
This is an individual project, to be completed on your own. It i.docx
 

More from aayushmaany2k14

7 In pea plants round R is dominant to wrinkled r A h.pdf
7 In pea plants round R is dominant to wrinkled r A h.pdf7 In pea plants round R is dominant to wrinkled r A h.pdf
7 In pea plants round R is dominant to wrinkled r A h.pdfaayushmaany2k14
 
7 In cats some are black some are orange and some are ca.pdf
7 In cats some are black some are orange and some are ca.pdf7 In cats some are black some are orange and some are ca.pdf
7 In cats some are black some are orange and some are ca.pdfaayushmaany2k14
 
7 You have just discovered a new fungal species from Yellow.pdf
7 You have just discovered a new fungal species from Yellow.pdf7 You have just discovered a new fungal species from Yellow.pdf
7 You have just discovered a new fungal species from Yellow.pdfaayushmaany2k14
 
7 Write the MIPS code to implement the for loop below Use .pdf
7 Write the MIPS code to implement the for loop below Use .pdf7 Write the MIPS code to implement the for loop below Use .pdf
7 Write the MIPS code to implement the for loop below Use .pdfaayushmaany2k14
 
7 Given the diagram above describe the order of events in .pdf
7 Given the diagram above describe the order of events in .pdf7 Given the diagram above describe the order of events in .pdf
7 Given the diagram above describe the order of events in .pdfaayushmaany2k14
 
7 Ontario Resources a natural energy supplier borrowed 8.pdf
7 Ontario Resources a natural energy supplier borrowed 8.pdf7 Ontario Resources a natural energy supplier borrowed 8.pdf
7 Ontario Resources a natural energy supplier borrowed 8.pdfaayushmaany2k14
 
7 Let XiiZ+1i2path dM263681c0701839752119c34.pdf
7 Let XiiZ+1i2path dM263681c0701839752119c34.pdf7 Let XiiZ+1i2path dM263681c0701839752119c34.pdf
7 Let XiiZ+1i2path dM263681c0701839752119c34.pdfaayushmaany2k14
 
7 Essay What is the difference between efficiency and equ.pdf
7 Essay What is the difference between efficiency and equ.pdf7 Essay What is the difference between efficiency and equ.pdf
7 Essay What is the difference between efficiency and equ.pdfaayushmaany2k14
 
7 What is most true about the following B2B promotional too.pdf
7 What is most true about the following B2B promotional too.pdf7 What is most true about the following B2B promotional too.pdf
7 What is most true about the following B2B promotional too.pdfaayushmaany2k14
 
7 What do foxes and birds have in common a They are both .pdf
7 What do foxes and birds have in common a They are both .pdf7 What do foxes and birds have in common a They are both .pdf
7 What do foxes and birds have in common a They are both .pdfaayushmaany2k14
 
7 Using terms from the key on the right correctly identify.pdf
7 Using terms from the key on the right correctly identify.pdf7 Using terms from the key on the right correctly identify.pdf
7 Using terms from the key on the right correctly identify.pdfaayushmaany2k14
 
7 Using node 1 as the root perform a BFS for node 6 Detai.pdf
7 Using node 1 as the root perform a BFS for node 6 Detai.pdf7 Using node 1 as the root perform a BFS for node 6 Detai.pdf
7 Using node 1 as the root perform a BFS for node 6 Detai.pdfaayushmaany2k14
 
8 The residents of Elk Meadows and Valley View are experien.pdf
8 The residents of Elk Meadows and Valley View are experien.pdf8 The residents of Elk Meadows and Valley View are experien.pdf
8 The residents of Elk Meadows and Valley View are experien.pdfaayushmaany2k14
 
8 What would be the most possible interaction between the s.pdf
8 What would be the most possible interaction between the s.pdf8 What would be the most possible interaction between the s.pdf
8 What would be the most possible interaction between the s.pdfaayushmaany2k14
 
8 A unique structure in vertebrate embryos is the somite S.pdf
8 A unique structure in vertebrate embryos is the somite S.pdf8 A unique structure in vertebrate embryos is the somite S.pdf
8 A unique structure in vertebrate embryos is the somite S.pdfaayushmaany2k14
 
7 Kate has a utility function Uxy4xpath dM95702c.pdf
7 Kate has a utility function Uxy4xpath dM95702c.pdf7 Kate has a utility function Uxy4xpath dM95702c.pdf
7 Kate has a utility function Uxy4xpath dM95702c.pdfaayushmaany2k14
 
8 Protein synthesis begins when in the nucleus of each cell.pdf
8 Protein synthesis begins when in the nucleus of each cell.pdf8 Protein synthesis begins when in the nucleus of each cell.pdf
8 Protein synthesis begins when in the nucleus of each cell.pdfaayushmaany2k14
 
729 David is going to purchase two stocks to form the initi.pdf
729 David is going to purchase two stocks to form the initi.pdf729 David is going to purchase two stocks to form the initi.pdf
729 David is going to purchase two stocks to form the initi.pdfaayushmaany2k14
 
8 IPOsinitial public offerings of stockcreate billions of.pdf
8 IPOsinitial public offerings of stockcreate billions of.pdf8 IPOsinitial public offerings of stockcreate billions of.pdf
8 IPOsinitial public offerings of stockcreate billions of.pdfaayushmaany2k14
 
8 Agreement and disagreement among economists Suppose that .pdf
8 Agreement and disagreement among economists Suppose that .pdf8 Agreement and disagreement among economists Suppose that .pdf
8 Agreement and disagreement among economists Suppose that .pdfaayushmaany2k14
 

More from aayushmaany2k14 (20)

7 In pea plants round R is dominant to wrinkled r A h.pdf
7 In pea plants round R is dominant to wrinkled r A h.pdf7 In pea plants round R is dominant to wrinkled r A h.pdf
7 In pea plants round R is dominant to wrinkled r A h.pdf
 
7 In cats some are black some are orange and some are ca.pdf
7 In cats some are black some are orange and some are ca.pdf7 In cats some are black some are orange and some are ca.pdf
7 In cats some are black some are orange and some are ca.pdf
 
7 You have just discovered a new fungal species from Yellow.pdf
7 You have just discovered a new fungal species from Yellow.pdf7 You have just discovered a new fungal species from Yellow.pdf
7 You have just discovered a new fungal species from Yellow.pdf
 
7 Write the MIPS code to implement the for loop below Use .pdf
7 Write the MIPS code to implement the for loop below Use .pdf7 Write the MIPS code to implement the for loop below Use .pdf
7 Write the MIPS code to implement the for loop below Use .pdf
 
7 Given the diagram above describe the order of events in .pdf
7 Given the diagram above describe the order of events in .pdf7 Given the diagram above describe the order of events in .pdf
7 Given the diagram above describe the order of events in .pdf
 
7 Ontario Resources a natural energy supplier borrowed 8.pdf
7 Ontario Resources a natural energy supplier borrowed 8.pdf7 Ontario Resources a natural energy supplier borrowed 8.pdf
7 Ontario Resources a natural energy supplier borrowed 8.pdf
 
7 Let XiiZ+1i2path dM263681c0701839752119c34.pdf
7 Let XiiZ+1i2path dM263681c0701839752119c34.pdf7 Let XiiZ+1i2path dM263681c0701839752119c34.pdf
7 Let XiiZ+1i2path dM263681c0701839752119c34.pdf
 
7 Essay What is the difference between efficiency and equ.pdf
7 Essay What is the difference between efficiency and equ.pdf7 Essay What is the difference between efficiency and equ.pdf
7 Essay What is the difference between efficiency and equ.pdf
 
7 What is most true about the following B2B promotional too.pdf
7 What is most true about the following B2B promotional too.pdf7 What is most true about the following B2B promotional too.pdf
7 What is most true about the following B2B promotional too.pdf
 
7 What do foxes and birds have in common a They are both .pdf
7 What do foxes and birds have in common a They are both .pdf7 What do foxes and birds have in common a They are both .pdf
7 What do foxes and birds have in common a They are both .pdf
 
7 Using terms from the key on the right correctly identify.pdf
7 Using terms from the key on the right correctly identify.pdf7 Using terms from the key on the right correctly identify.pdf
7 Using terms from the key on the right correctly identify.pdf
 
7 Using node 1 as the root perform a BFS for node 6 Detai.pdf
7 Using node 1 as the root perform a BFS for node 6 Detai.pdf7 Using node 1 as the root perform a BFS for node 6 Detai.pdf
7 Using node 1 as the root perform a BFS for node 6 Detai.pdf
 
8 The residents of Elk Meadows and Valley View are experien.pdf
8 The residents of Elk Meadows and Valley View are experien.pdf8 The residents of Elk Meadows and Valley View are experien.pdf
8 The residents of Elk Meadows and Valley View are experien.pdf
 
8 What would be the most possible interaction between the s.pdf
8 What would be the most possible interaction between the s.pdf8 What would be the most possible interaction between the s.pdf
8 What would be the most possible interaction between the s.pdf
 
8 A unique structure in vertebrate embryos is the somite S.pdf
8 A unique structure in vertebrate embryos is the somite S.pdf8 A unique structure in vertebrate embryos is the somite S.pdf
8 A unique structure in vertebrate embryos is the somite S.pdf
 
7 Kate has a utility function Uxy4xpath dM95702c.pdf
7 Kate has a utility function Uxy4xpath dM95702c.pdf7 Kate has a utility function Uxy4xpath dM95702c.pdf
7 Kate has a utility function Uxy4xpath dM95702c.pdf
 
8 Protein synthesis begins when in the nucleus of each cell.pdf
8 Protein synthesis begins when in the nucleus of each cell.pdf8 Protein synthesis begins when in the nucleus of each cell.pdf
8 Protein synthesis begins when in the nucleus of each cell.pdf
 
729 David is going to purchase two stocks to form the initi.pdf
729 David is going to purchase two stocks to form the initi.pdf729 David is going to purchase two stocks to form the initi.pdf
729 David is going to purchase two stocks to form the initi.pdf
 
8 IPOsinitial public offerings of stockcreate billions of.pdf
8 IPOsinitial public offerings of stockcreate billions of.pdf8 IPOsinitial public offerings of stockcreate billions of.pdf
8 IPOsinitial public offerings of stockcreate billions of.pdf
 
8 Agreement and disagreement among economists Suppose that .pdf
8 Agreement and disagreement among economists Suppose that .pdf8 Agreement and disagreement among economists Suppose that .pdf
8 Agreement and disagreement among economists Suppose that .pdf
 

Recently uploaded

Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin ClassesCeline George
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfPoh-Sun Goh
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsMebane Rash
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxAreebaZafar22
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...christianmathematics
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17Celine George
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.christianmathematics
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Shubhangi Sonawane
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...Poonam Aher Patil
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxnegromaestrong
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxDenish Jangid
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptxMaritesTamaniVerdade
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 

Recently uploaded (20)

Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
Asian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptxAsian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptx
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 

I have to write a Connect Four game program When a player t.pdf

  • 1. I have to write a Connect Four game program. When a player takes their turn, they will select a column in which to place a token. The token is placed at the top of the column and is allowed to fall to the bottom, stacking on top of any previously placed tokens. Two players take turns placing token colors of red or yellow. The first person to create four of their color token in a row, horizontally or vertically, (NOT diagonally in this problem) wins and the game is over. The program will display the board (7 columns and 6 rows), then ask for alternating players to place a token in column 0 through 6. The process repeats until one player wins. You do not need to check for a tie game, or if there is space in a chosen column. The photos (shown below) contain the code for the game framework. It is required that I utilize functions and write my code within the functions. The function signatures are provided for you in the framework. Examine each one to see what will be needed by the end. I am given 2 functions to start with: main() and display(board). Part 1: Fill out the code for the placeToken function. It is given three parameters: (1) the board, (2) the column in which to place a token, and (3) the token itself. The board is the two dimensional list of characters, with spaces ' ' being empty locations. The column is a numerical index in which to place the token, and the token is the character 'R' or 'Y'. Start at the top row (index 0) and move down the rows until the row below is not ' ', then place the token. Then return the row the token ended up in. You can test this out by running the program, but the game won't end yet because the other functions are incomplete. Use control+C (command + C) to stop the game early. Another way to approach this is to start at the bottom row and walk upwards until the space is ' '. Part 2: Fill out the code for the winningMove function. The game is won if four tokens of the same color line up either vertically or horizontally. Good functional design would have these checks in their own functions. Fill in the code for winningMove such that it uses the 2 other check functions (below). This function can be one line of code. The row and column parameters are the location of the last move taken. Part 3: Fill in the code for checkVertical, which checks for four in a line vertically (on the same column) as the given row and column parameters. You only need to search outward from the row and column parameters and not the whole board. Since new moves are controlled by gravity in connect four, you only need to search downward. You can test if this is working by running the program. Part 4: Fill in the code for checkHorizontal, which checks for four in a line horizontally (on the same row) as the given row and column parameters. You only need to search outward from the row and column parameters and not the whole board. You can test if this is working by running the program. The last photo shows an example run.