Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PLEASE CODE IN PYTHON Part III: horizontal winner(board) This function scans the entire game board passed as an argument and returns one of three values:

PLEASE CODE IN PYTHON

Part III: horizontal winner(board)

This function scans the entire game board passed as an argument and returns one of three values:

1 if player 1 has placed four consecutive Xs in a single row somewhere in the board

2 if player 2 has placed four consecutive Os in a single row somewhere in the board

0 (zero) if neither player has placed four consecutive pieces in a single row somewhere in the board

Under no circumstances is the function permitted to make a change to board.

PROVIDED BELOW IS THE BOARD CLASS

# The Board class represents the game board. # From the player's perspective, the rows are numbered 1 through num_rows, # and the columns are numbered 1 through num_cols. Internally, however # the actual slots that hold the pieces are indexed using 0 through num_rows-1 # and 0 through num_cols-1. # DO NOT MODIFY THE Board CLASS IN ANY WAY! class Board: def __init__(self, num_rows, num_cols): self._num_rows = num_rows self._num_cols = num_cols self._slots = [] for i in range(0, num_rows): self._slots.append([]) for j in range(0, num_cols): self._slots[-1].append('.') # DO NOT MODIFY THE Board CLASS IN ANY WAY! # Displays the board. Note that slot [0][0] is in the bottom-left corner of the board. # [num_rows-1][num_cols-1] is the position of the slot in the upper-right corner def display_board(board): for i in range(board._num_rows-1, -1, -1): row = ''.join(board._slots[i]) print(row) 

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

Step: 3

blur-text-image

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 Application Development And Design

Authors: Michael V. Mannino

1st Edition

0072463678, 978-0072463675

More Books

Students also viewed these Databases questions

Question

When should you not apologize?

Answered: 1 week ago

Question

(1 point) Calculate 3 sin x cos x dx.

Answered: 1 week ago

Question

Explain the function and purpose of the Job Level Table.

Answered: 1 week ago