Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

ICS 33 Programming Assignment 3

Objectives:

1.   Get familiar with working with iles and directories using Python.

2.  Get familiar with interacting with a Python program through command line input.

3.  Get familiar with exception handling and making your program more robust.

Description:

In  this  assignment,  you  will  extend  and  modify  your  code  from  Programming Assignment 2 to add more functionalities. Your program will be extended to look more like a real Texas Hold’em game with interactive features. You should invoke diferent modes of playing the game through the terminal. Two modes should be supported: user mode and ile mode. Details for each mode are below.

User mode: When you use the user mode to run your program, you will be one of the players and interact with the game through the command line. You need to input from the command line the number of players you want to have for the game (excluding you). Then the program will randomly draw 2 cards for each player. The 2 cards for you will be displayed on the terminal, and the cards for the other players (called bot players) will be stored in the program and not visible to you. You will input your action: fold, bet (with amount), or check. Then 3 community cards will then be randomly drawn and displayed on the terminal. The bot players’actions will be displayed on the terminal. Then you will input your your action: fold, bet (with amount). Another 2 community cards will be randomly drawn and displayed on the terminal. Again, the bot players’actions will be displayed on the terminal. Then you will input your your action: fold, bet (with amount). Finally, the results will be displayed for whether you win or lose. The game rule is the same as the rule in PA2. Each player, including you, has $10 to start with. After each game, you will be asked whether you want to continue playing. If yes, a new game will be initialized, with the money left for each player carried over to the new game. If you do not have any money left, the program will terminate without prompting to start a new game or betting further. If any bot player does not any money left, it will be removed from the game but the game can continue as long as you have money left.

File mode: When you use the ile mode to run your program, the program will read in data from iles. You will also need to compare your results to the expected results stored in iles (test_cases.txt) and display the number of tests passed.

Program implementation

Your program for PA3 should be based on your code for PA2.

Assumptions

Assume you are drawing cards from one deck of cards. Assume that each player has $10 to start with.

Tie situations

Your program is expected to handle simple tie situations. Because we are using only one deck of cards, when the program randomly draws cards, it is very rare for two players to have the same rank. You are expected to handle, e.g., when two players both have a pair, then you need to compare who has the largest pair value.

Input format

User mode: The input for the user mode comes from the command line. You should be able to interact with your program to start the user mode by using the command line:

python script_name.py -u -p 3

The above command says: Run the program using user mode with 3 bot players.              Then your program should start drawing and displaying cards and bot players’actions. Your program should display prompts for user input through the terminal. You should

provide clear instructions for the expected user input through command line: e.g., enter ‘f’for fold,‘b’for bet, etc.

File mode: The input for the ile mode comes from a directory.  You should download the directory (test_cases) from Canvas to your local computer. You should also download the ile“test_results.txt”from Canvas. You should be able to run your program by entering the ile path through command line as below:

python script_name.py -f -i path_to_test_cases_directory

The above command says: Run the program using ile mode, read in test cases from path_to_test_cases_directory. You should display the number of tests passed.

Output format

User mode: The output for the user mode will just be on the terminal. It should display bot players’ decisions, prompts for the user in give input, the human player’s cards, community cards, and game results (who wins, money left).

File model:  Display the number of tests passed on the terminal.

Submission

Python programs (Name should be: PA3_FirstName_LastName.py, Readme.txt) should be submitted to Canvas by 8/9/2022, 11:59pm. You can submit as many times as you want before the deadline. You should submit a zip ile if you upload multiple iles. No late submissions will be accepted unless you communicate with the instructor ahead of time. If you have special circumstances that need to be accommodated, please contact the instructor and TA immediately.

Request for extension

Request for extension should be communicated directly with the instructor and no later than 48 hours before the due date.

Grading

The assignment will be worth 100 points, with the following breakdowns:

40 pt: user mode works correctly and the program has reasonable interactions with users. We will play with your program through command lines under user mode. 15 pts out of 40 are given based on the ability of your program to handle invalid user input. 10 pts out of 40 are given for clear prompts to users for entering input through command line.

40 pt: ile mode works correctly.

20 pt: good coding style. See the list of things that are helpful for checking your coding style. Since this is the last programming assignment before project, we will check your coding style more strictly compared to the previous two assignments. We will focus on function and variable naming and readability.

Bonus point (5 pt): a proper readme ile that instructs users and other programmers on how to run and use your program. (What is a Readme ile?)

Plagiarism

There are Texas Hold’em programs implemented in Python online. However, in this programming assignment, we have speciic requirements such as the data types you can use. You can refer to the ideas of how those programs were written, but you should not directly duplicate their codes. Put references to those resources in your submission. Discussion with your classmates is encouraged, but you should not directly duplicate their codes. If direct duplication of codes is found, you will receive no points in this assignments.

More notes about the assignment

1.   If you have any questions, please approach the TA and the instructor as soon as possible. Do not delay to the very last minute.

2.   The next two programming assignments and the project will be based on the irst one. So it would be the best if your programs have the lexibility to be extended, though this is not part of the grading.

References

[1] https://en.wikipedia.org/wiki/Texas_hold_%27em

*Table is adapted based on the Wikipedia source.