The L game

In this assignment your group has to program (in Python, any version ok) an entire, working two-player game: the L game, invented by Edward de Bono. The game consists of a 4x4 grid, one 3x2 L-shaped piece for each player, and two 1x1 neutral pieces. The initial positions are specified. At each turn, a player must first move its L piece to a new position that is free (i.e., within the grid and not overlapping with the other L and the neutral pieces); and then may move one of the neutral pieces to any free position (or may choose not to move any neutral piece). The game finishes when a player cannot move its L piece to any position. The rules of the game are simple, but it does require some strategy.

In previous lab assignments for the Pac-man projects, you had to implement basic search algorithms such as A*, minimax, etc., but the remaining infrastructure of the game was provided (state representation, legal actions, terminal states or goals, costs, input/output, etc.). This infrastructure is fundamental in an AI agent, but domain-dependent. This assignment asks you to do that part as well.

At a minimum, your program should do the following:

You are encouraged to go beyond these minimum requirements and the grade will reflect your effort. For example, you could improve the user interface to get a suggested move from the computer if the human asks for it; to replay the last n moves; to undo the last n moves; to switch to computer-vs-computer play; to rotate or flip the board (to aid visualization for the human); to save the game; etc. The plot of the board could be as simple as ASCII text symbols, or as fancy as you like.

But, most importantly, the computer should play correctly (using any possible legal action), well (to win) and efficiently (in memory and time); and you must follow the format above to input/output moves and to accept an initial state.

Suggestions: review the AIMA book, in particular chapter 5; understand and take advantage of symmetry; play the game with each other to understand what works, possible strategies or good positions, etc.

What you have to submit: one submission per group, including:

  1. A file report.pdf (no more than 10 pages) containing:
  2. A single file L-game.py with your Python source code, nicely formatted and commented.

Submitting just the code will earn no grades, even if it works.


Miguel A. Carreira-Perpinan
Last modified: Wed Nov 20 23:19:39 PST 2024