Question: Write a method max _ score _ column ( self , scores ) that takes a list scores containing a score for each column of
Write a method maxscorecolumnself scores that takes a list scores containing a score for each column of the board, and that returns the index of the column with the maximum score. If one or more columns are tied for the maximum score, the method should apply the called AIPlayers tiebreaking strategy to break the tie. Make sure that you return the index of the appropriate column, and not the columns score.
Notes:
One good way to implement this method is to first determine the maximum score in scores you can use the builtin max function for this and to then create a list containing the indices of all elements in scores that match this maximum score. For example, if scores consisted of the list the list of indices that you would build would be because all of these scores are tied for the maximum score. If scores consisted of the list you would build the list of indices Then once you have this list of indices, you can choose from the list based on the AIPlayers tiebreaking strategy.
If you take this approach, then you dont really need to worry about whether there is a tie. You can always use the tiebreaking strategy when choosing from the list of indices that you construct!
We have included an import statement for the random module so that you can use the appropriate function to make a random choice for players that use the 'RANDOM' tiebreaking strategy.
Examples:
scores p AIPlayerX 'LEFT', pmaxscorecolumnscores result: p AIPlayerX 'RIGHT', pmaxscorecolumnscores result:
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
