Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Using Python The Tic-Tac-Toe is represented by a 2D list where X=1 and O=2, create a function named winInRow. The function will take 3 parameters:

Using Python

The Tic-Tac-Toe is represented by a 2D list where X=1 and O=2, create a function named winInRow.

The function will take 3 parameters: 1. a two-dimensional list that holds a representation of the board game-state 2. a number for a specific row to look in 3. the piece type of one of the players

This function should return True if there are 3 pieces side by side in the indicated row of the indicated piece type. Remember that we have the possibility of rows of length 3 and of length 4. You will have to create an implementation that finds 3 in a row in both of these situations. You cant just find the total number of pieces of the same type in the row. In a row of length 4 there may be 3 pieces with an EMPTY or opponent piece in between them which prevent them from being 3 in a row. There are many ways to accomplish this function, the key challenges are that in some games rows will be 3 cells long, in others 4 cells long, and that there may be blanks or opponent pieces separating the piece type being checked. The second function has many similarities to you first one. Instead of keeping your row the same and looking in different column indices you will keep the column the same and change your row indices.

Thanks in advance!

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Internals A Deep Dive Into How Distributed Data Systems Work

Authors: Alex Petrov

1st Edition

1492040347, 978-1492040347

More Books

Students also viewed these Databases questions