w24 PYTHON CSD 4523: Assignment 1 (Version 1.0 Due February 5)

Expanded set of requirements for Version 2.0 of the Game Due February 12

For February 12: Version 1.2 of Assignment 1

*-- Adding on Top of Version 1.0 of Asssignment 1
Here is where you upload your Word Document:
Word Document just contains your TRELLO BOARD LINK.
Everything else goes into the TRELLO BOARD.
You will do the following Additions: 3 THINGS:
Working in Collab Notebook Your additions
1. IN A TEXT Cell of your Google Collab Notebook: Tell me your idea of the 2 BOXES we need as inputs to Unified Process: Box A: List of Algorithms Box B: List of your Classses which you got from from doing Lexical Analysis on your BOX A List of Algorithms.
2. Make a Class Interaction Diagram which will show assigning Methods and Data Attributes to your OBJECTS.
*-- Draw a Diagram of your Class Interaction Diagram on Paper. Take a picture : embed the picture: LINK In your Google Collab Notebook to your document containing your CID.
<OID we will talk about on FEB 12>
Amp up your PYTHON CODE In your Google Collab Notebook to show me enhanced Python Code to deliver your classes with Data Attributes and Method For example: Can you implement: DeclareWinner() for Example.
(You did already submit a text file to the dropbox location with the LINK to your Google Sheet: And in that Google Sheet: You did put your Student Name/ID, LINK to your Google Collab Notebook - in that notebook: you an Editor of your Notebook)


Video recapping our discussion:
PowerPoint recapping our Core Concepts and Recipes for using Unified Process and UML to build the PYTHONIC MVC in OO Programming Languages:
You have already uploaded a TEXT FILE with a LINK to your TRELLO BOARD or Google Sheets.
Your revised Code with be updated in your Google Collab Notebook - You have already provided me with your Goggle Collab Notebook and make and editor of your Google Collab Notebook.
Additional Work you need to do for PYCARD 21 Game 2.0:
Make a Google Doc with your OOAD analysis which will be a knowledge Capture of your AAR analysis → Provide a LINK to your GOOGLE DOC in your TRELLO Board. Make sure that this link is PUBLICLY Readable and that I can read it!
Revise your PYTHON Code in your PYCARD 21 Game 2.0 to reflect your OOAD AAR analysis.

OOAD Worksheet

Create a Document (Word, Google Docs) to present your OOAD following the example in this Worksheet.

Version 1.0 of your Game requirement included providing me with a Google Colab Notebook URL

Make an Editor of your Notebook.

The PYTHON Card Game

How to get started on Assignment 1:

Step 1 :
Make a TRELLO Board: The purpose of the TRELLO Board is to do the OOAD object oriented analysis and design of the game - based on our prescription of our algorithms that we must implement.
Step 2:
Make Swimlanes for your RULES and DOMAIN OBJECTs
Make a LIST of Domain Objects you will need to implement in PYTHON to deliver the requirements of your Card Game.
Use to draw and visualize what Domain Objects you need and how they will connect together.
We will be doing our PYTHON programming using GOOGLE COLLAB Notebook:
Introduction to Google Colab Notebooks
Google Colab is a hosted Jupyter Notebook service provided by Google. It allows users to create and run Jupyter notebooks without any setup or installation required. Colab provides free access to computing resources, including GPUs and TPUs, making it particularly well-suited for machine learning, data science, and education
Features and Usage of Google Colab Notebooks
Access and Storage: Colab notebooks can be stored in Google Drive or loaded from GitHub. They can be shared with others, similar to Google Docs or Sheets, by clicking the Share button or following Google Drive file sharing instructions
Execution Environment: Code in Colab notebooks is executed in a virtual machine that is private to the user's account. These virtual machines are deleted when idle for a while and have a maximum lifetime enforced by the Colab service
Downloading Notebooks: Users can download any Colab notebook they have created from Google Drive or from within Colab's File menu. All Colab notebooks are stored in the open-source Jupyter notebook format (.ipynb)
Integration with Google Drive: Colab notebooks are stored in a user's Google Drive account, making it easy to access, manage, and share them with others.
Support for Multiple Languages: While Jupyter notebooks support multiple programming languages, including Python, Julia, and R, Colab currently only supports Python

Current work item:
Now that your TRELLO Board is ready to use:
In your TRELLO Board: Make a SWIM Lane and CARDS: => Object Analysis and Design:
To describe the Algorithms that your CARD GAME MUST DELIVER.

Simple work flow to get started: This is version 1.0 of your PYCARD Game.

Due FEB 5.

These are behaviors you need to implement:
Use KNOWLEDGE PRINCIPLE to decide into which of your UML entities will you provision each behavior.
Make a some PYTHON classes with methods and data to create :
A Game
A dealer:
Issue one face down CARD to Each player
Issue a second face up card to each player
wait to be asked by players for more cards
A Deck
ONE Player:
Methods: Ask for another card <how they choose to do that is up to you>
Here is where you upload your Word Document:
Word Document just contains your TRELLO BOARD LINK.
Everything else goes into the TRELLO BOARD.

Design notes for this Assignment:

This is our Data Structures worksheet from last week. In this Worksheet we provided some sample code to start this assignment.
In the starter for the Card Game, we make the DECK to contain the CARDS as data points within the DECK : In this approach, the cards are NOT separate objects — Why this approach?
It would have made sense for the CARDS to be separate OBJECTS if the cards have methods. Since the CARDS are just DATA (suit and rank) - there is no advantage to modelling them as separate objects.

We will do the Coding for this in Google Collab:
You will make an editor of your Google Collab Notebook:
Share the LINK to your Google Collab Notebook. You will share the LINK to your Google Collab Notebook in your Word Document.

Innstructor Provided Materials:

Student Learning Materials / resources you canuse:

Python Documentation:
What you are to hand-in:
(This is an individual NOT group assignment)
Make a Word File → Named as StudentName_StudentID.docx
Into this Word File: Provide the Invite LINK to your TRELLO Design Board:

In your TRELLO Board, PUT:
Your name/student ID
UML Diagram made using You can copy/paste this Image into your Word Document.
LINK to your Google Collab Notebook

How to hand this assignment in:

Make a Word Document: Named as StudentName_StudentID.docx
What needs to be in your Word Document is the LINK to your TRELLO BOARD
Here is where you upload your Word Document:

Grading Rubric: Your Python 21 Card Game will be graded on a Scale of 100 POINTS assigned as follows:

Grading Rubric for Python 21 (Blackjack) Card Game

Your Python 21 Card Game will be graded on a scale of 100 points, distributed across various aspects of the project as outlined below. This rubric aims to assess your understanding of Python programming, particularly in using data structures, implementing game logic, and creating user interactions.

1. Code Functionality (40 Points)

Game Works as Expected (20 Points): The game runs without errors and accurately follows the rules of 21 (Blackjack).
Logical Flow and Efficiency (10 Points): The program demonstrates efficient use of data structures and algorithms.
Error Handling (10 Points): The code gracefully handles unexpected inputs and situations (e.g., invalid moves).

2. Code Structure and Organization (20 Points)

Modularity and Use of Functions (10 Points): Code is well-organized into functions, each handling a specific aspect of the game.
Code Readability (5 Points): The code is easy to read, with appropriate naming conventions for variables and functions.
Consistent Formatting (5 Points): Consistent indentation, spacing, and comment style.

3. User Interface (15 Points)

Clarity and Usability (10 Points): The text-based interface is clear and user-friendly, with understandable prompts and messages.
Gameplay Experience (5 Points): The game provides a smooth and engaging user experience, including clear indications of game progress and outcomes.

4. Documentation and Comments (15 Points)

Comprehensive Comments (10 Points): Code is well-documented with comments explaining the purpose and functionality of blocks of code.
Project Documentation (5 Points): Includes a README file or similar documentation that explains how to run the game, game rules, and any additional information about the program.

5. Creativity and Additional Features (10 Points)

Innovation (5 Points): Creative elements or features that enhance the game beyond the basic requirements (e.g., betting system, multiplayer option).
Advanced Programming Concepts (5 Points): Use of advanced Python concepts or additional libraries to improve the game (e.g., GUI implementation, enhanced AI for dealer).

Total: 100 Points

Note: Instructors may adjust the point distribution based on specific course focuses or additional assignment requirements.
This rubric provides a balanced approach to evaluating the fundamental aspects of the Python 21 (Blackjack) card game project.

Learning how to build a Software Application:

Python Data Structures Assignment: Card Game Creation

Assignment Deliverable:

Develop a Python program to simulate a simple card game using various data structures. The purpose of this assignment is to demonstrate your understanding of data structures like lists, tuples, sets, and dictionaries in Python.


1. Game Selection

Choose a simple card game (e.g., War, Blackjack, Old Maid). Provide a brief description of the game rules.

2. Card Representation

Implement a card as a tuple with two elements: rank and suit. (e.g., ('Queen', 'Hearts'))
Create a standard deck of 52 cards using a list or set.

3. Game Setup

Shuffle the deck before the start of the game.
Depending on the game, deal cards to players or create a draw pile.

4. Game Mechanics

Implement the core mechanics of your chosen game. This might include:
Player turns.
Drawing and discarding cards.
Keeping track of scores or collected cards.

5. Use of Data Structures

Demonstrate the use of:
Lists: For maintaining the deck, players’ hands, or a discard pile.
Sets: To check for duplicates or unique cards.
Dictionaries: To keep track of scores or player statistics.
Tuples: For individual cards.

6. User Interface

Create a simple text-based interface where:
Players can see their current cards.
Game status updates are displayed (e.g., who's turn, what actions were taken).

7. Bonus Features (Optional)

Consider adding:
Multiplayer functionality (more than two players).
Computer-controlled players (AI).
Enhanced game rules.


Choose a Game: Select a card game and write down its rules.
Card and Deck Setup: Implement your cards using tuples and create a deck. Ensure your deck contains all 52 cards.
Shuffling and Dealing: Use Python’s random library to shuffle the deck. Implement the dealing mechanism according to your game's rules.
Gameplay Mechanics: Write the logic for the turns, rules, and actions of your game.
Implementing Data Structures: Use lists, sets, tuples, and dictionaries appropriately throughout your game.
User Interface: Develop a text-based interface to interact with the game.
Testing: Play your game to ensure it follows the rules and mechanics correctly.
Documentation: Comment your code for clarity and document how to play the game.
Submission: Submit your Python script along with a README file explaining your game, its rules, and how to run your program.

Evaluation Criteria:

Correct use of data structures.
Implementation of game mechanics and rules.
Code readability and documentation.
Functionality of the game (it should work as intended).
Creativity in game design (especially for bonus features).
Let's focus on 21 since it has simple rules: teach the students how the game of 21 works

Understanding the Game of 21 (Blackjack)

The game of 21, also known as Blackjack, is a popular card game played in casinos and informally. The primary goal is to beat the dealer by having a total card value as close to 21 as possible without exceeding it. Here's a simplified guide to understanding the game:


The main objective is to have a hand with a value as close to 21 as possible, without going over 21.
Players compete against the dealer, not against each other.

Card Values:

Number cards (2-10) are worth their face value.
Face cards (Jack, Queen, King) are worth 10.
Aces can be worth either 1 or 11, whichever is more advantageous to the player.


Starting the Game:
Each player, including the dealer, is dealt two cards.
In most settings, one of the dealer's cards is face up (visible) and one is face down (hidden).
Player Decisions:
Players have the option to 'Hit' (take another card) or 'Stand' (keep their current hand).
Players can continue to 'Hit' as many times as they want but if their total exceeds 21, they 'Bust' and lose the round.
In some variations, other options like 'Double Down', 'Split', or 'Surrender' are available.
Dealer's Turn:
After all players have completed their turns, the dealer reveals their hidden card.
The dealer must hit until their cards total 17 or higher.
Winning the Game:
If a player's hand is closer to 21 than the dealer's, or if the dealer busts, the player wins.
If a player's hand is equal to the dealer's, it's a 'Push' (a tie), and the player's bet is returned.
If the player busts, or the dealer's hand is closer to 21, the player loses.
Special Hands:
'Blackjack': This is the best hand and consists of an Ace and a 10-value card (10, Jack, Queen, King) dealt as the first two cards. A Blackjack usually pays more than a regular win.

Tips for Teaching 21:

Start by explaining the card values, as understanding this is crucial.
Go through a sample round, showing how players decide to hit or stand.
Explain the role of the dealer and how their actions are typically more constrained.
Use real cards or visual aids to demonstrate how a hand is played.
Discuss the importance of strategy, such as when to hit or stand based on the visible dealer card.
Remember, while 21 is a game of chance, there's also a significant element of strategy based on probability and risk management. Encourage students to think about the odds of different outcomes as they play.

To implement the card game 21 (Blackjack) in Python, you'll need to follow a structured approach. Below is an outline of the algorithm that you can use as a guide:

Algorithm Outline for Implementing 21 (Blackjack) in Python

1. Setup and Initialization

Define Card Values: Create a dictionary to map card names (2-10, Jack, Queen, King, Ace) to their numerical values.
Create Deck:
Generate a deck of cards using nested loops – one for the four suits (hearts, diamonds, clubs, spades) and one for the 13 ranks (2-10, Jack, Queen, King, Ace).
Store each card as a tuple (rank, suit) in a list.
Shuffle Deck: Use random.shuffle() to shuffle the deck.

2. Dealing Cards

Initial Deal:
Deal two cards to the player and two to the dealer from the deck.
For the dealer, make one card hidden (face down) and one card visible.
Display Initial Hands:
Show the player's cards and their total value.
Show one of the dealer's cards (the visible one).

3. Player’s Turn

Implement Player Choices:
Allow the player to choose 'Hit' (take another card) or 'Stand' (end their turn).
If the player chooses 'Hit', deal another card and update the hand's total value.
Repeat until the player chooses to 'Stand' or busts (exceeds 21).
Check for Player Bust:
If the player's total exceeds 21, the player busts and loses immediately.

4. Dealer’s Turn

Reveal Hidden Card: Show the dealer's hidden card.
Dealer's Rules:
The dealer must hit (take cards) until their total is 17 or higher.
Check for Dealer Bust:
If the dealer's total exceeds 21, the dealer busts and the player wins.

5. Determine Winner

Compare Totals:
If both the player and dealer have 21 or less, compare their total values.
Decide Outcome:
The highest total wins, as long as it's 21 or under.
If there's a tie, it's a push (no one wins).

6. Round Conclusion

Display Results:
Show the final hands and totals of both the player and dealer.
Declare the winner or indicate if it's a push.
End of Round:
Ask the player if they want to play another round.
If yes, reshuffle the deck and start a new round. If no, end the game.

7. Additional Features (Optional)

Implement Betting System: Allow the player to bet virtual currency.
Support for Multiple Players: Adapt the game for multiple players against the dealer.
Advanced Options: Include options like 'Double Down', 'Split', or 'Surrender'.

8. Code Structuring

Functions: Create separate functions for each major step (e.g., deal_card(), calculate_total(), player_turn(), dealer_turn(), determine_winner()).
Main Loop: Have a main loop that controls the flow of the game, calling these functions as needed.
This outline provides a structured approach to implementing a basic version of Blackjack in Python. You can expand on this with more features and refinements as needed.

This checklist breaks down the project into manageable tasks, ensuring a structured approach to coding the game.

Instructor will demonstrate making a Memory Map, Class Interaction Diagram and Object Interaction Diagram to deliver the Business Domain of PYTHON 21.

### Checklist for Developing Python 21 (Blackjack)

#### 1. Understand the Game Rules - [ ] Research and understand the basic rules of 21 (Blackjack).
#### 2. Set Up the Development Environment - [ ] Install Python, if not already installed. - [ ] Set up a code editor or Integrated Development Environment (IDE) like VSCode, PyCharm, or Jupyter Notebook.
#### 3. Plan the Program Structure - [ ] Sketch out a basic flow of the game. - [ ] Decide on the functions and data structures needed.
#### 4. Start Coding: Core Game Elements - [ ] **Define Card and Deck Structures** - [ ] Create a card representation (tuples or classes). - [ ] Generate a standard deck of cards (list or set). - [ ] **Implement the Shuffling Mechanism** - [ ] Use Python’s `random` module to shuffle the deck.
#### 5. Game Mechanics - [ ] **Deal Initial Cards** - [ ] Write a function to deal cards to the player and dealer. - [ ] **Implement Player Actions** - [ ] Write functions for 'Hit' and 'Stand' actions. - [ ] **Implement Dealer Actions** - [ ] Automate dealer behavior according to the game rules.
#### 6. Game Logic - [ ] **Calculate Hand Values** - [ ] Write a function to calculate the total value of a hand. - [ ] **Check for Wins, Losses, and Busts** - [ ] Implement logic to determine the outcome of a round.
#### 7. User Interface - [ ] **Create a User Interface** - [ ] Implement a simple text-based interface for the player’s input and to display messages. - [ ] **Display Game Status** - [ ] Show the player's and dealer's hands and scores.
#### 8. Testing and Debugging - [ ] **Playtest the Game** - [ ] Run the program multiple times to ensure it works as expected. - [ ] **Debug Any Issues** - [ ] Fix any bugs or errors that arise during testing.
#### 9. Code Refinement and Documentation - [ ] **Refactor and Optimize Code** - [ ] Clean up the code, ensuring it's efficient and readable. - [ ] **Add Comments and Documentation** - [ ] Document the functions and the flow of the game for clarity.
#### 10. Submission Preparations - [ ] **Prepare a README File** - [ ] Write instructions on how to run the program and an overview of the game. - [ ] **Final Review** - [ ] Do a final check to ensure everything is complete and working. - [ ] **Submit the Assignment** - [ ] Follow the submission guidelines provided by the instructor or course.
#### 11. Optional Enhancements (If Time Permits) - [ ] Add advanced features like betting systems or multiplayer support. - [ ] Implement a graphical user interface (GUI) using a library like Tkinter or Pygame (advanced).
By following this checklist, students can systematically approach the development of the 21 game in Python, ensuring they cover all necessary aspects from understanding the game rules to final submission.

For the Part 1 of this Assignment we did last week, see:

Want to print your doc?
This is not the way.
Try clicking the ⋯ next to your doc name or using a keyboard shortcut (
) instead.