Your Course Project will be to build a MONOPOLY Game with a Graphical User Interface.
In your Project: A person can play Monolopy with the Computer.
Today’s Activity is STEP ONE towards that Program.
The Rules of the MONOPOLY Game:
As a computer programmer writing a SWIFT program to simulate the MONOPOLY game, it's important to understand the rules of the game to ensure that the program is accurate and functional. Here's a brief summary of the rules of the game:
By the end of your Project, you will need to write Use Cases and Algorithms to deliver each of these 9 requirements:
The game is played on a board with 40 spaces, each representing a property, utility, or other space. [How will you model BOARD Spaces in Swift Code?]
Players take turns rolling two six-sided dice and moving their token accordingly. [How will you model players and their activities in Swift code - How to roll dice? How to track how much money a player has?]
When a player lands on an unowned property, they have the option to buy it or let it go up for auction. If they choose to buy it, they pay the listed price and become the owner.
If a player lands on a property owned by another player, they must pay rent to the owner based on the property's value and the number of buildings on it.
Players can also collect rent from properties they own, as well as from railroads and utilities.
Chance and Community Chest cards provide bonuses or penalties to players.
Players can build houses and hotels on their properties to increase rent.
If a player lands on the "Go to Jail" space, they must go to jail and either pay a fine or roll doubles to get out.
The game ends when one player has bankrupted all other players, or when a predetermined time limit has been reached.
By understanding these rules, you can start building the logic for your MONOPOLY program in SWIFT.
For version 1 of your Program, you will interact with the Game through the command line (buy, sell, roll dice, other inputs). For Version 2, you will implement a Graphical User Interface.
This might involve creating classes for the board, properties, and players, as well as implementing the game mechanics, such as rolling dice and handling property transactions.
(Version 3:) You can also add in additional features, such as different game modes and win conditions, to make the program more complex and interesting.
Each player in MONOPOLY starts with $1500 (or the equivalent currency in the country of play). Money can move between players in a number of ways:
Buying and selling properties: When a player buys a property, they pay the price listed on the board to the Bank. If another player lands on that property later in the game, they must pay rent to the owner, which goes directly to the owner's cash balance.
Taxes and fines: Some spaces on the board, such as Income Tax and Luxury Tax, require players to pay money to the Bank. Additionally, if a player lands on certain spaces, such as Go to Jail, they may be required to pay a fine to the Bank.
Chance and Community Chest cards: These cards can provide bonuses or penalties to players, often involving the exchange of money.
Free Parking: In some variations of the game, money collected from fines and taxes goes into a pool in the center of the board. When a player lands on Free Parking, they collect the money in the pool.
The Bank plays a crucial role in MONOPOLY as the holder of all money and properties not owned by players. The Bank is responsible for managing the sale and purchase of properties, collecting rent
SWIFT program to simulate a MONOPOLY Game
Write a UML Diagram to describe the operation of the MONOPOLY GAME.
You will build and continually update your UML Diagram as you go along: This will be one of the hand ins for your final project submission.
To simulate a MONOPOLY game in Swift, you can start by creating a Board class, which represents the game board.
The board must contain a list of properties, each with its own name, price, and rent value.
You must also create a Player class, which represents a player in the game, with properties such as name, cash, and properties owned. You can create several computer players to play a Human Player interacting via the command line.
Next, you can implement the game logic. This involves rolling dice, moving the player's token on the board, and handling the player's actions when landing on a property. If the player lands on an unowned property, they can choose to buy it or leave it. If they land on a property owned by another player, they must pay rent.
You will also implement other features of the game, such as Chance and Community Chest cards, which can provide bonuses or penalties to the player. Additionally, you can implement the Free Parking space, where players can collect money for landing on it.
To make the game more complex, you can add in different game modes, such as a timed game or a game with different win conditions. You can also add in different types of properties, such as utilities and railroads, which have their own rules and behaviors.
Step 1: Write a UML Diagram to describe all the core elements of the Game - and of your Program.
Lesson Outcome: Get this code working and commit it to your GITHUB REPO for this Project.
__ Activity A: Set up a GITHUB REPO and provide the URL here:
Here's some sample code to get you started: Enter this code into your GITHUB
Let me know when you are done:
From here, you can build upon this code and add in additional functionality to create a full MONOPOLY game simulation.
What do you you think you should do for STEP 3?
Here's the driver code that creates instances of the classes and demonstrates their use:
Your Task: Add this to your previous code base and get it running: DONE
Get this code working. Debug and troubleshoot as needed.
This code imports the Foundation library to enable using Int.random(in:). It then creates instances of Property, adds them to a Board, and creates instances of Player. Player1 buys a property, Player2 pays rent to Player1, and the details of the two players are printed to the console.
Next Task: Extend this application to include a GameRunner method that will play a game with Bob and Alice to completion: When one of the players is bankrupt
To play a game to completion, we need to make some modifications and additions to the existing code.
First, let's update the Player class to include a bankrupt property and a method to check if a player can afford a property or not:
Next, let's create a GameRunner class that will handle the game loop and logic:
#todo: You type this in and get it to run:
Finally, let's update the driver code to run the game:
This code adds a GameRunner class that manages the game loop and game logic. The game continues until one of the players becomes bankrupt.
When the game is over, the final details of the players are printed to the console.
Note that this implementation is a simple version of the game and does not include all the rules and features of a full-fledged board game.
Get your entire Monopoly Game running:
Post the updated code into your GitHub REPO.
Think about how to make the Algorithms more intelligent.
In next week’s class, we will layer some APIs in your application:
External Storage in Firebase
Web APIs you can use to enhance your Swift Monopoly game with more intelligent and interesting algorithms.
): Use OpenAI's GPT models to generate creative and intelligent game descriptions, hints, or suggestions for player actions. You can also use it for more advanced natural language understanding tasks, like parsing user input.
): Use Wit.ai to integrate natural language processing (NLP) capabilities into your game. It will help you understand user input and create intelligent responses, making the game more interactive and engaging.
): Integrate real-world locations into your Monopoly game to make it more dynamic and interesting. You can use the Google Maps API to fetch geographical data, geocode addresses, and display maps in your game.
): Access BoardGameGeek's database of board games, including Monopoly, to fetch game-related data such as descriptions, ratings, and images. Use this data to enhance your game's presentation or to generate new challenges and scenarios.
): Leverage IBM Watson's AI capabilities to integrate machine learning, natural language processing, or visual recognition into your game. This can help make your game more engaging and responsive to user input.
Remember to follow the API documentation and terms of service when integrating them into your game. Additionally, ensure your app handles network requests and errors gracefully since web APIs rely on an internet connection.
Want to print your doc? This is not the way.
Try clicking the ⋯ next to your doc name or using a keyboard shortcut (