CS 124
Fall 2023

Problem Set 15 and 16 FAQ

If you don’t see your question here, post it on Piazza or come to office hours! See the links in the navigation bar for both of those options.

Problem Set 15

  1. Do we need to follow the guidelines for the RandomPlayer class?

    Yes, please create the RandomPlayer class by inheriting from the Player class. This is an excellent exercise in seeing the advantages of object-oriented programming. Using inheritance, we do not need to duplicate code from the Player class and we can tweak its default behavior by making a RandomPlayer always give a random move. You will also use this technique of inheriting classes and overriding methods in Problem 2.

    If inheritance or overriding methods seems confusing, look over the lecture notes to see some examples.

Problem Set 16

  1. Where should I begin?

    Start by reading over the lecture notes on AI for Connect Four. Be sure you understand how the lookahead strategy works before you start coding. Once you go through some of the examples we gave and the worksheet, you can start with the pseudocode given in the lecture notes. If some part of it seems confusing, be sure to also look over the hints given in the problem set which go into more detail.

  2. Does each line in the pseudocode represent one line of Python?

    Not necessarily. Each statement in the pseudocode could be implemented with one or more statements. Some of the pseudocode could even be implemented using conditional statements.

  3. Do I need to create a separate opponent class?

    No, the opponent you construct in scores_for will be an instance of the AIPlayer class.

  4. How do I create an opponent?

    You need to create an instance of the AIPlayer class whose checker is the opposite of the current player. In addition, they should use the same tiebreaking strategy as the current player, and have a lookahead that is one less than the lookahead used by the current player.

  5. How do I determine the player’s scores from the opponent’s?

    You can determine this by answering the following questions. Suppose we are determining the score for a column col.

    • The opponent’s best/max score after the player moves into col is 100, so the opponent wins. What should our player’s score be in this case?

    • The opponent’s best/max score after the player moves into col is 0, so the opponent loses. What should our player’s score be in this case?

    • The opponent’s best/max score after the player moves into col is 50, so neither the opponent nor the player wins. What should our player’s score be in this case?