Return the best scoremove for the human findbest comp

Info icon This preview shows pages 55–57. Sign up to view the full content.

View Full Document Right Arrow Icon
   return the best {score,move}   for the human } FindBest Comp Move(int depth) {     if depth is zero        return (evaluate(board))     for each legal move the  computer  can make         temporarily make move[i]        score[i] =FindBest Human Move(depth-1);        undo move[i]    return the best {score,move}  for the computer } 1 OK – this sequence of moves yields a  score of +1 for the human. I’ll  remember that.  +3c +1h The computer continues through the  rest of the moves it could make and  gets scores for each of them… +0 +1h +1c Finally the computer identifies its best  possible move option (taking the human’s  Rook) and returns it. Result: Score  +3c  Pawn->Rook. This process continues out until we return all the  way back to the first FindBestCompMove function  call… By playing every move and every counter-move a  simulated opponent would make several levels deep, the  computer can figure out the best move… It then returns its best possible move to the chess  program…
Image of page 55

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Backup slides
Image of page 56
Writing a Chess Player FindBest Computer Move() {     For each legal move the  computer  can make         Temporarily make the move        See how the ideal human player would respond        Undo the move    Return the move that  hurts the human most } FindBestIdeal Human Move() {     For each legal move the  ideal human  could make         Temporarily make the move.        See how the computer would respond        Undo the move    Return the move that  hurts the computer most } Computer Player Human Player FindBest Computer Move() {     For each legal move the  computer  can make         Temporarily make the move        See how the ideal human player would respond        Undo the move    Return the move that  hurts the human most } FindBestIdeal Human Move() {     For each legal move the  ideal human  could make         Temporarily make the move.        See how the computer would respond        Undo the move    Return the move that  hurts the computer most } This would go on and on, in  many cases playing 6 or more  levels deep! +9c +1h +2c +1h +4h +2c +2c +5h Based on the current board  configuration, the  best move the human  can make  will give an advantage of  +2  over the computer . And the move is… Based on the current board  configuration, the  best move the  computer can make  will give an  advantage of  +3 over the human . And  the move is… Based on the current board configuration,  the  best move the ideal human  could make  would give an  advantage of +1 over the  computer . And the move is…
Image of page 57
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern