Assignment2_2020_v2.pdf - CSCI3180 u2013 Principles of...

This preview shows page 1 - 2 out of 13 pages.

CSCI3180 – Principles of Programming Languages – Spring 2019 Assignment 2 — Your First Date with Python and Duck Typing Deadline: Mar 15, 2020 (Sunday) 23:59 1 Introduction 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 3.6 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 Typing. NOTES: all your codes will be graded on the Linux machines in the Department. You are welcome to develop your codes on any platform, but please remember to test them on Department machines. 2 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 en/sixmensmorris . 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. 2.1 Description The game board consists of a grid with 16 intersections or points as shown in Figure 1. Each player has six pieces , or “men”, coloured black or white . Players try to form “ mills ”— three 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 white pieces and Player 2 uses the black ones. The game proceeds in the following two phases. 1. 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 Phase 1 . After all men are placed, Phase 2 begins.

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture