University | Ngee Ann Polytechnic |
Subject | Programming in Python I |
1.OBJECTIVE
This assignment assesses the student’s ability to apply relevant programming concepts to develop a simple application using Python programming language.
2.BACKGROUND
Develop a city-building strategy game called Simp City.
Buy Custom Answer of This Assessment & Raise Your Grades
3.SCOPE
You are the mayor of Simp City, and you want to build the happiest and most prosperous city possible, i.e., score the most points.
This city-building strategy game is played over 16 turns. In each turn, you will build one of two randomly-selected buildings in your 4×4 city. In the first turn, you can build anywhere in the city. In subsequent turns, you can only build on squares that are connected to existing buildings. The other building that you did not build is discarded.
Each building scores in a different way. The objective of the game is to build a city that scores as many points as possible.
There are 5 types of buildings, with 8 copies of each:
- Beach (BCH): Scores 3 points if it is built on the left or right side of the city, or 1 point otherwise
- Factory (FAC): Scores 1 point per factory (FAC) in the city, up to a maximum of 4 points for the first 4 factories. All subsequent factories only score 1 point each.
- House (HSE): If it is next to a factory (FAC), then it scores 1 point only. Otherwise, it scores 1 point for each adjacent house (HSE) or shop (SHP), and 2 points for each adjacent beach (BCH).
- Shop (SHP): Scores 1 point per different type of building adjacent to it.
- Highway (HWY): Scores 1 point per connected highway (HWY) in the same row.
See Section 4 part 4 for more information on how these buildings score.
The assignment consists of “Basic Requirements” and “Advanced Requirements” as described in sections 4 and 5 respectively. You are advised to complete the basic requirements BEFORE proceeding with the advanced requirements.
For this assignment, you are expected to:
- Understand the problem completely and plan your program layout before you start coding
- Develop the solution for each task by using functions
- Functions developed should be as generic as possible – values used in functions should be passed in as the function parameters
- You may use global variables sparingly
- Implement and test each feature as it is developed
4. BASIC REQUIREMENTS
The application should provide the following basic features:
1. Display main menu
When the program is first run, it should display the main menu as shown in Figure 1.When a user enters an option 1, 2 or 0, the program will process the option accordingly.
Welcome, mayor of Simp City!
1. Start new game 2. Load saved game 0. Exit Your choice? |
1.1. Start New Game
This option starts a new game. The player is given an empty 4×4 board; the building “pool” is initialized with 8 copies of each building (40 buildings in total); and two buildings are randomly selected from the pool:
Your choice? 1
Turn 1 A B C D +—–+—–+—–+—–+ 1| | | | | +—–+—–+—–+—–+ 2| | | | | +—–+—–+—–+—–+ 3| | | | | +—–+—–+—–+—–+ 4| | | | | +—–+—–+—–+—–+ 1. Build a HSE 2. Build a BCH 3. See remaining buildings 4. See current score 5. Save game 0. Exit to main menu Your choice? |
Figure 1.1 – New Game
1.2. Load Saved Game
This option reads the save file and restores the game state. Since you can only save onegame.
1.3. Exit Game
This option quits the game and exits.
Hire a Professional Essay & Assignment Writer for completing your Academic Assessments
Native Singapore Writers Team
- 100% Plagiarism-Free Essay
- Highest Satisfaction Rate
- Free Revision
- On-Time Delivery
2.Playing the Game
When you are playing the game, it should display the game menu as shown in Figure 1.1.When a user enters an option from 1 to 5 (or 0), the program will process the option accordingly.
2.1. Build a Building
When the player chooses option 1 or 2, the game will ask for a location expressed as a letter-number pair.
Your choice? 1
Build where? b2 Turn 2 A B C D +—–+—–+—–+—–+ 1| | | | | +—–+—–+—–+—–+ 2| | HSE | | | +—–+—–+—–+—–+ 3| | | | | +—–+—–+—–+—–+ 4| | | | | +—–+—–+—–+—–+ 1. Build a SHP 2. Build a SHP 3. See remaining buildings 4. See current score 5. Save game 0. Exit to main menu Your choice? |
Figure 2.1a – Building on Turn 1
The player may build on any square on Turn 1. In subsequent turns, buildings must be built orthogonally adjacent to existing buildings.
Your choice? 2
Build where? c3 You must build next to an existing building. Turn 2 A B C D +—–+—–+—–+—–+ 1| | | | | +—–+—–+—–+—–+ 2| | HSE | | | +—–+—–+—–+—–+ 3| | | | | +—–+—–+—–+—–+ 4| | | | | +—–+—–+—–+—–+ 1. Build a SHP 2. Build a SHP 3. See remaining buildings 4. See current score 5. Save game 0. Exit to main menu Your choice? |
Figure 2.1b – Illegal placement: not next to existing building
2.2b. See Remaining Buildings
When the player chooses option 3, a list of buildings still remaining in the “pool” is displayed.
Your choice? 3
Building Remaining ——– ——— HSE 7 FAC 8 SHP 6 HWY 8 BCH 7 |
Figure 2.2 – See Remaining Buildings
2.3. See Current Score
This shows the current score of the player if the game were to end now.
Turn 8
A B C D +—–+—–+—–+—–+ 1| | HWY | | | +—–+—–+—–+—–+ 2| | SHP | HSE | BCH | +—–+—–+—–+—–+ 3| | HSE | HSE | BCH | +—–+—–+—–+—–+ 4| | | | | +—–+—–+—–+—–+ 1. Build a SHP 2. Build a HSE 3. See remaining buildings 4. See current score 5. Save game 0. Exit to main menu Your choice? 4 HSE: 4 + 2 + 4 = 10 FAC: 0 SHP: 2 = 2 HWY: 1 = 1 BCH: 3 + 3 = 6 Total score: 19 |
Figure 2.2 – See Current Score
2.4. Save Game
This saves the current state of the game, so that after the player quits the game, they can return to the current state by selecting “Load Saved Game” in the main menu (see 1.2).
Enter choice: 5
Game saved! |
Figure 2.3 – Save Game
2.5. Exit to Main Menu
This option ends the current game and returns to the main menu.
Your choice? 0
1. Start new game 2. Load saved game 0. Exit Your choice? |
Figure 2.4 – Save to Main Menu
3. End of Game
When the player fills up the board after Turn 16, the score will be computed and displayed.
Turn 16
A B C D +—–+—–+—–+—–+ 1| SHP | SHP | HSE | | +—–+—–+—–+—–+ 2| BCH | HSE | HSE | BCH | +—–+—–+—–+—–+ 3| BCH | SHP | HSE | HSE | +—–+—–+—–+—–+ 4| HWY | HWY | HWY | HWY | +—–+—–+—–+—–+ 1. Build a HWY 2. Build a FAC 3. See remaining buildings 4. Save game 0. Exit to main menu Your choice? 2 Build where? d1 Final layout of Simp City: A B C D +—–+—–+—–+—–+ 1| SHP | SHP | HSE | FAC | +—–+—–+—–+—–+ 2| BCH | HSE | HSE | BCH | +—–+—–+—–+—–+ 3| BCH | SHP | HSE | HSE | +—–+—–+—–+—–+ 4| HWY | HWY | HWY | HWY | +—–+—–+—–+—–+ HSE: 1 + 5 + 5 + 3 + 3 = 17 FAC: 1 = 1 SHP: 2 + 2 + 3 = 7 HWY: 4 + 4 + 4 + 4 = 16 BCH: 3 + 3 + 3 = 9 Total score: 50 |
Figure 3 – End of Game
The game will then return to the main menu.
4. Additional Clarifications on Buildings
4.1. Beach (BCH)
A Beach (BCH) scores 3 points if it is built in column A or column D, or 1 point otherwise.
4.2. Factory (FAC)
A Factory (FAC) scores 1 point per factory (FAC) in the city, up to a maximum of 4 points for the first 4 factories; all subsequent factories only score 1 point each.For example,
- If there are 3 factories in the city, each factory will score 3 points, for a total of 3+3+3 = 9 points.
- If there are 5 factories in the city, the first 4 factories will score 4 points each while the 5th factory will score 1 point, for a total of 4+4+4+4+1 = 17 points.
4.3. House (HSE)
If a House (HSE) is next to a factory (FAC), then it scores 1 point only. Otherwise, it scores 1 point for each adjacent house (HSE) or shop (SHP), and 2 points for each adjacent beach (BCH).
A B C D
+—–+—–+—–+—–+
1| HWY | HWY | HWY | FAC |
+—–+—–+—–+—–+
2| BCH | HSE | HSE | SHP |
+—–+—–+—–+—–+
3| BCH | SHP | HSE | FAC |
+—–+—–+—–+—–+
4| HWY | FAC | HWY | HWY |
+—–+—–+—–+—–+
HSE: 4 + 3 + 1 = 8
In the above example,
- The HSE at B2 scores 2 points for being next to the BCH at A2, 1 point for being next to the HSE at C2, and 1 point for being next to the SHP at B3, for a total of 2+1+1 = 4 points.
- The HSE at C2 scores 3 points for being next to two HSE and one SHP. It does not score any points for being next to a HWY.
- The HSE at C3 scores only 1 point as it is next to a FAC at D3.
4.4. Shop (SHP)
A Shop (SHP) scores 1 point per different type of building adjacent to it.
A B C D
+—–+—–+—–+—–+
1| HWY | HWY | HWY | FAC |
+—–+—–+—–+—–+
2| BCH | HSE | HSE | SHP |
+—–+—–+—–+—–+
3| BCH | SHP | HSE | FAC |
+—–+—–+—–+—–+
4| HWY | FAC | HWY | HWY |
+—–+—–+—–+—–+
SHP: 4 + 3 = 7
In the above example,
- The SHP at D2 scores 2 points for being next a FAC at D1 and a HSE at C2. The additional FAC at D3 does not add to the score.
- The SHP at B3 scores 3 points for being next to a HSE, a BCH and a FAC.
4.5. Highway (HWY)
A Highway (HWY) scores 1 point per connected highway (HWY) in the same row (not column).
A B C D
+—–+—–+—–+—–+
1| HWY | HWY | HWY | FAC |
+—–+—–+—–+—–+
2| BCH | HSE | HSE | SHP |
+—–+—–+—–+—–+
3| BCH | SHP | HSE | FAC |
+—–+—–+—–+—–+
4| HWY | FAC | HWY | HWY |
+—–+—–+—–+—–+
HWY: 3 + 3 + 3 + 1+ 2 + 2 = 14
In the above example,
- The three HWY at A1, B1 and C1 score 3 points each as they are all part of a 3-square highway.
- The HWY at A4 scores 1 point. Even though it is in the same row as the HWY at C4 and D4, they are not connected.
- The HWY at C4 and D4 score 2 points each.
5. Program documentation
The program should have sufficient comments, which includes your name, class, date, overall description of what the program does, as well as the description of the functions.
Stuck with a lot of homework assignments and feeling stressed ? Take professional academic assistance & Get 100% Plagiarism free papers
Struggling to complete Programming in Python I Assignment? then no need to worry. At Singapore Assignment Help we have a team of skilled programming experts who have relevant industry experience in providing faultless solution on python programming assignment at a cheap price.
Looking for Plagiarism free Answers for your college/ university Assignments.
- CH2123 Assignnment : Fugacity, VLE Modeling & Henry’s Law Applications
- BAFI1045 Assignment -Constructing and Evaluating Passive and Active Portfolios Based on the Straits Times Index (STI)
- PSB501EN Assignment 1: Engineering Systems Integration: A Multi-Technique Approach to Mechanical Analysis
- FIN2210E/FIN2212E Group Assignment: Financial Risk Management Analysis of Bursa Malaysia Companies
- FLM101 Assignment: A Cinematic Dissection: Stylistic Elements and Their Thematic Significance
- Assignment: Transforming Talent in the AI Era: From War to Wealth through Ecosystem Innovation
- COMP 1105 Assignment: Health-Focused E-Commerce Website: A Web Technologies Project Using HTML5, CSS, and JavaScript
- Assignment: Machine Learning in Robo-Advisory Services: Evolution, Applications, and Future Trends
- OMGT2229 Assignment: Quantitative Forecasting, Economic Order Analysis, and Strategic Sourcing Decision-Making for JB Hi-Fi
- Assignment 2: Corporate Finance and Planning: An In-Depth Financial Analysis of Company