Table of Contents

Before the lab

Entry quiz

Q&A

  1. How does an adversarial game differ from a single-agent search problem?
  2. Should the agent exploit an opponent who often makes mistakes?
  3. Why can alpha-beta pruning examine fewer states without changing the minimax decision? Why might center-first ordering be useful in Connect Four?
  4. Does a higher evaluation score mean that the position is truly better?

Notebook

Notebook: HCAI_Lab_Adversarial_Search.ipynb (Work in Google Colab or download the .ipynb file to local environment)

Work in groups of 2-4. Every group member must be able to explain the results.

Challenge

Work in groups of 2-4 to build an agent for the Connect 4 arena.

Your agent receives the current board and must select a legal column for its next piece. The CodinGame version uses a 7×9 board and includes an optional STEAL action for the second player, so read the rules carefully before adapting code from the notebook.

Begin with a simple working agent that selects legal moves. Then improve it using: a hand-crafted evaluation function; depth-limited minimax; alpha-beta pruning; move ordering that prioritizes promising or tactically necessary actions.

Consider which features help the agent recognize immediate wins, opponent threats, valuable positions, and longer-term opportunities. Remember that the response-time limit prevents exhaustive exploration of the complete game tree.

Start the challenge during the lab and continue it as part of the self-study regarding classes. Selected groups may share their strategies at the next lab, and effective solutions may receive bonus points.

Learn more!