1 / 3

scoresFor(self , board, ox, ply) Make empty score list For each col :

scoresFor(self , board, ox, ply) Make empty score list For each col : If allowed, add a move into the col for ox, then: Check for a win, if yes, append score of 100 to the list This is easy, call winsFor () Otherwise, if ply is 1, append score of 50 to the list Otherwise:

melosa
Download Presentation

scoresFor(self , board, ox, ply) Make empty score list For each col :

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. scoresFor(self, board, ox, ply) • Make empty score list • For each col: • If allowed, add a move into the col for ox, then: • Check for a win, if yes, append score of 100 to the list • This is easy, call winsFor() • Otherwise, if ply is 1, append score of 50 to the list • Otherwise: • Obtain opposing checker character • If ox is ‘x’ use ‘o’, if ox is ‘o’ use ‘x’ • Get a list of scores for the current board for opponent • Big Idea: call scoresFor recursively with ply - 1 • Find the maximum score in the list (best move for opponent) • Append 100 – max opponent score to the list • If a move was added, delete it • If the move not allowed, append score of -1 to the score list • Return the list

  2. nextMove(self, board) • Get a list of scores for all the moves I can make • Use scoresFor() with my own checker character • You will have a score in the list where the index of the list element is the column number for the move • Determine the highest score in the list • There may/will be more than one high score • Pick a column number corresponding to one of the high scores (leftmost, rightmost, random?) • Return the chosen column number to the caller

More Related