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.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
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.
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education