CSCI3180 – Principles of Programming Languages – Spring 2019
Assignment 2 — Your First Date with Python and Duck Typing
Deadline: Mar 15, 2020 (Sunday) 23:59
The purpose of this assignment is to offer you the first experience with Python, which supports
the Object-Oriented programming paradigm.
Our main focuses are Dynamic Typing and Duck
Typing. Please use Python
to finish this assignment.
The assignment consists of 4 tasks.
You need to implement a famous board game called Six Men’s Morris in Python.
You are asked to demonstrate the advantages/disadvantages of dynamic typing through some
example code, which could be taken from any code you write for this assignment.
We give you the Java source code of a game called “Save The Tribe”.
You need to re-
implement the game in Python to make the code cleaner with the help of Duck Typing.
Additional features and mechanisms are introduced to the “Save The Tribe” game. You need
to implement the enhanced game in both Java and Python.
After completing the 4 tasks, you need to write a report elaborating on Dynamic Typing and Duck
all your codes will be graded on the Linux machines in the Department.
welcome to develop your codes on any platform, but please remember to test them on Department
Task 1: Six Men’s Morris
This is a programming exercise for you to get familiar with Python, which is a dynamically typed
language. In this task, you have to strictly follow our proposed OO design and the game rules for
the 2-player “Six Men’s Morris” game stated in this section.
Six Men’s Morris is a popular game in Italy, France and England during the Middle Ages but
was obsolete by 1600. You can have a try to play this game in
For simplicity, we want you to implement a watered-down version of Six Men’s Morris. The
detailed specification or game rules are described as follows.
The game board consists of a grid with 16 intersections or
as shown in Figure 1.
, or “men”, coloured
. Players try to form “
of their men lined up horizontally or vertically
—allowing a player to remove the opponent’s
man from the game board. For simplicity, Player 1 always uses the
pieces and Player 2 uses
The game proceeds in the following two phases.
Placing the pieces.
The game begins with an empty board. Player 1 first starts to play
and the two players take turns placing their men, one per turn on empty points. This phase
will last for 6 rounds since each player has only 6 men. Note that a player forming a mill
can remove one of the opponent’s pieces from the board. However,
no one can win during
. After all men are placed, Phase 2 begins.