Assignment 3: Sushi Go

In this assignment, you will develop an AI that plays a variant of the Sushi Go card game. We have implemented the rules of the game for you, but you will have to decide how best to play the game.

This assignment is worth 15% of your final grade.

Overview of Tasks

All students are required to complete the same set of tasks, but COMP1130 students have an additional card to consider when developing their AI:

  COMP1100 COMP1130
Main Task: Sushi Go AI (no Chopsticks) 55 Marks N/A
Main Task: Sushi Go AI (with Chopsticks) N/A 65 Marks
Unit Tests 10 Marks 10 Marks
Style 10 Marks 10 Marks
Technical Report 25 Marks 35 Marks

As with assignment 2, code that does not compile will be penalised heavily. It is essential that you can write code that compiles and runs. If you have a partial solution that you cannot get working, you should comment it out and write an additional comment directing your tutor’s attention to it.

Getting Started

Fork the assignment repository and create a project for it in IntelliJ IDEA, following the same steps as in Lab 2. The assignment repository is at

Overview of the Game

The aim of Sushi Go (and our restricted version) is to collect cards (representing dishes) to make the highest-scoring (most delicious) meal possible. There are two players: Player 1 and Player 2. Each player is given a hand of cards and on their turn, they chose a single card to keep. After Player 2’s turn, both players swap hands and keep going. The game is over when everyone’s hand is empty. The winner is the person whose cards are worth the most points, according to the scoring rules below.

The Cards

Players must therefore select cards that are valuable to them. Careful selection can also deny your opponent valuable cards. The cards are represented by constructors of the Card type, defined inSushiGo.hs:


Nigiri (Nigiri Int) is your basic meal, and is worth the number of points in its argument (between 1 and 3, inclusive). It is more delicious if you add Wasabi, below.


Wasabi (Wasabi (Maybe Card)) makes Nigiri taste even better! The next Nigiri you take will be attached to the Wasabi, and is worth triple points. Taking Wasabi after Nigiri has no effect. A Wasabi with no Nigiri is worth zero points at the end of the game.


Dumplings (Dumplings) are delicious - the more you have, the more you want! They are scored based on the number you have:

Count Score
1 1
2 3
3 6
4 10
5 or more 15


Eel (Eel) is an acquired taste - the first one tastes gross, but it gets better with time. It is also scored based on the number you have:

Count Score
1 -3
2 or more 7


Tofu (Tofu) is good for you, but eat too much and you will feel sick! It is also scored based on the number you have:

Count Score
1 2
2 6
3 or more 0


Sashimi (Sashimi) is tasty, but best served in threes. Every three sashimi is worth 10 points, but any leftovers are worth zero.

Chopsticks (COMP1130 Only)

Chopsticks (Chopsticks) will only show up for COMP1130 students. They are worth zero if you are holding them at the end of the round, but you can trade them for an extra pick on a future turn.

Overview of the Repository

Most of your code will be written in src/AI.hs, but you will also need to write tests in test/AllTests.hs. A small program to play the game (either Human vs. Human, or Human vs. AI, or AI vs. AI) is provided atapp/Main.hs, and you can run it with cabal run.

src/SushiGo.hs implements the rules of the game. You should read this file carefully as many types and functions defined there will be useful to you. You do not need to understand the implementation ofplayMove or scoreCards, but knowing what they do will be helpful.

test/SushiGoTests.hs is the suite of unit tests we used to develop this assignment. You should read over as an example of unit testing style, or to understand how edge cases in the rules are resolved.

The only files you are allowed to modify in your submission are src/AI.hs and test/AllTests.hs. Any other modifications risk changing the rules of the game, so you would be playing a different game to the one in the assignment.

Other Files

  • app/Main.hs implements an interface to play the game, and for you to test your skills against your AI. You are not required to understand it.

  • duel/Main.hs implements a test program that tests your AIs against each other. You are not required to understand it.

  • comp1100-assignment3.cabal tells the cabal build tool how to build your assignment. You are not required to understand this file, and we will discuss how to use cabal below.

  • The files under src/Dragons/ contain advanced code that you are not required to understand or modify.

  • src/ListUtils.hs contains some helper functions for manipulating lists. You might find these handy, or you might not need them.

  • src/TextLayout.hs contains a helper function to render a grid of strings. You probably will not need this.

  • test/Testing.hs is a testing library that is similar to the ones used in previous assignments. It has been extended to allow you to group related tests together.

  • Setup.hs tells cabal that this is a normal package with no unusual build steps. Some complex packages (that we will not see in this course) need to put more complex code here. You are not required to understand it.

Overview of Cabal

As before, we are using the cabal tool to build the assignment code. The commands provided are very similar to last time:

  • cabal build: Compile your assignment.

  • cabal run sushigo: Build your assignment (if necessary), and run one of the test programs.

  • cabal run duel: Build your assignment (if necessary), and run the other test program. We discuss the test programs in detail below, as there are a number of ways to launch them.

  • cabal repl comp1100-assignment3: Run the GHCi interpreter over your project.

  • cabal test: Build and run the tests. This assignment is set up to run a unit test suite, and as with Assignment 2 you will be writing tests. The unit tests will abort on the first failure, or the first call to a function that is undefined.

You should execute these cabal commands in the top-level directory of your project: ~/comp1100/assignment3 (i.e., the directory you are in when you launch the IntelliJ Terminal tool for your project).

Overview of the Test Programs


When you run cabal run sushigo, you play the game against your AI called “default”. On player turns, you will be presented with a list of cards you can take, and you can type in the letters next to a card to pick it from your hand.

You can change the behaviour of the programm by calling it with different arguments, like this: cabal run sushigo -- arg1 arg2 arg3.... These are the arguments you can provide:

Argument Effect
-chopsticks Add Chopsticks to the game (COMP1130 students will almost always want this)
-p1ai ainame Use AI called “ainame” for Player 1
-p1human Use human input for Player 1 (default)
-p1random Use random moves for Player 1
-p2ai ainame Use AI called “ainame” for Player 2
-p2human Use human input for Player 2
-p2random Use random moves for Player 2

Example: cabal run sushigo -- -chopsticks -p1ai skynet -p2random: Add Chopsticks to the game, and play the AI called “skynet” as player 1 against random moves for player 2.


When you run cabal run duel, two of your AIs will square off against each other ten times. You can select which AI to run, and whether or not to use Chopsticks by passing in arguments from the table below:

Argument Effect
-chopsticks Add Chopsticks to the game (COMP1130 students will almost always want this)
-p1ai ainame Use AI called “ainame” for Player 1
-p1random Use random moves for Player 1 (default)
-p2ai ainame Use AI called “ainame” for Player 2
-p2random Use random moves for Player 2 (default)

Example: cabal run duel -- -p1ai skynet -p2ai mother: Add Chopsticks to the game, and play ten games where the AI called “skynet” plays against the AI called “mother”. Player 1 will always move first, and Player 2 will always move second.

With ten games and two AIs each taking four seconds to make each of its 15 moves, a full duel will take about 20 minutes. You should not have to run too many duels, but it is important to keep that running time in mind. You can tweak the time limits by editing the definition of timeLimit in either app/Main.hs or duel/Main.hs, but we will be using four second timeouts in our tests.

Main Task: Sushi Go AI (COMP1100: 55 Marks; COMP1130: 65 Marks)

Your Task

Implement an AI (of type AIFun