Question Write the function check_vin(board) to check if the Tie-Tac-Toe board game board has a winner. If there is a winner, return the picce of the winner (i.c., either '0' or 'X' ). Otherwise, the game has no winner and simply return an empty string " You are guaranteed there will be at most one winner.

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter6: Modularity Using Functions
Section6.4: A Case Study: Rectangular To Polar Coordinate Conversion
Problem 9E: (Numerical) Write a program that tests the effectiveness of the rand() library function. Start by...
icon
Related questions
Question

Python

A player wins if they can form a straight line consisting of 3 of their piece. If once the board is
full and nobody wins, the game ends in a draw.
Question
Write the function check_vin(board) to check if the Tic-Tac-Toe board game board has a
winner. If there is a winner, return the piece of the winner (i.e., either '0' or 'X' ). Otherwise,
the game has no winner and simply return an empty string ". You are guaranteed there will be
at most one winner.
Assumptions
• The will be at most one winner
• board will be a valid board configuration
Restrictions
• The input board should not be modified.
Sample Gameplay
User inputs are underlined. The latest valid moves are coloured red.
1|2|3
Player X move: 1
X|2|3
Player X move: 6
Player X move: 2
X|X|3
-+-+-
X|2|3
4|5|6
-+-+-
-+-+
-+-+-
-+-+-
4|016
0101X
7|8|9
-++-
-+-+-
-+-+-
7|8|9
7|8|9
018|9
Player 0 move: 5
1|213
Player 0 move: 1
Invalid move!
Player 0 move: 7
X|2|3
Player 0 move:
X|X|0
Player 0 move: 4
-+-+-
-+-+
-+-+-
4|016
X|2|3
-+-+-
-+++-
-+-+-
ーキーキー
7|8|9
01016
018|9
018|9
ーキーキー
Player O won!
7|8|9
Transcribed Image Text:A player wins if they can form a straight line consisting of 3 of their piece. If once the board is full and nobody wins, the game ends in a draw. Question Write the function check_vin(board) to check if the Tic-Tac-Toe board game board has a winner. If there is a winner, return the piece of the winner (i.e., either '0' or 'X' ). Otherwise, the game has no winner and simply return an empty string ". You are guaranteed there will be at most one winner. Assumptions • The will be at most one winner • board will be a valid board configuration Restrictions • The input board should not be modified. Sample Gameplay User inputs are underlined. The latest valid moves are coloured red. 1|2|3 Player X move: 1 X|2|3 Player X move: 6 Player X move: 2 X|X|3 -+-+- X|2|3 4|5|6 -+-+- -+-+ -+-+- -+-+- 4|016 0101X 7|8|9 -++- -+-+- -+-+- 7|8|9 7|8|9 018|9 Player 0 move: 5 1|213 Player 0 move: 1 Invalid move! Player 0 move: 7 X|2|3 Player 0 move: X|X|0 Player 0 move: 4 -+-+- -+-+ -+-+- 4|016 X|2|3 -+-+- -+++- -+-+- ーキーキー 7|8|9 01016 018|9 018|9 ーキーキー Player O won! 7|8|9
Expert Solution
steps

Step by step

Solved in 2 steps with 2 images

Blurred answer
Knowledge Booster
Introduction to computer system
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr