首页 > > 详细

解析python语言、R语言解析、讲解留学生python设计、C/C++讲解、讲解python开发

2-Player Blackjack
We will be writing a simple implementation of a card game called Blackjack, also known as 21. The goal of the game
is to draw cards that add up to a value as close as possible to 21 without exceeding it. In a standard game of 2-player
Blackjack the player and the dealer are dealt 2 cards. The player decides to draw cards or stop drawing. When they
want to draw a card they will say, "hit me." When they want to stop drawing, they will say, "stand". If they draw a card
and the total value of cards in their hand exceeds 21, the player "busts", which means they lose. If the player has not
"bust" and they decide to "stand", then it is the dealer's turn to draw cards. The dealer has a special rule that, as soon
as their hand value is equal to or greater than 17, they must "stand". If the dealer exceeds 21, the dealer will "bust",
which means the player wins. It is possible that both the player and dealer end with the same hand value, in which
case it is a draw.

When deciding which player has won or if a player has bust, the value of each card in that player's hand are added
together. Each number card is worth its number value. Face cards, such as Jacks, Queens and Kings are all worth 10.
The Ace is an unusual card because, if the combined value with other cards in hand does not exceed 21, it will be
worth 11, otherwise the Ace will be worth 1.

You are required to write a Python program, called game.py, that allows a player to play Blackjack against the
computer. You must implement the provided functions, and then use them to play the game. You will need to make
use of the provided module, blackjack.py and the classes defined within it. These classes include Player, Card,
and Deck.

When a game is complete, the player will be asked if they want to play again. The player should record how many
games they have won in a row. Players that win the largest number of games in a row should have their names and
scores recorded in a high scores file called highscores.txt. This file should only contain the top 5 high scoring
players and should be sorted from highest to lowest score.

PSP Assignment 2 - 201801 Page 11 of 24


REQUIREMENTS

It is expected that your solution will include the use of:

 The supplied game.py module. You must modify and complete this file and the function inside.
 Functions (output_player, play_game, player_turn, dealer_turn, read_high_scores,
get_high_score_index, insert_high_score, output_high_scores and write_high_scores)
implemented adhering to the assignment specifications.
 The supplied blackjack.py file and the classes and methods contained within. This is provided for you –
please DO NOT modify this file.
 Well constructed while loops. (Marks will be lost if you use break statements in order to exit from loops).
 Well constructed for loops. (Marks will be lost if you use break statements in order to exit from loops).
 Appropriate if/elif/else statements.
 Output that strictly adheres to the assignment specifications.
 Good programming practice:
o Consistent commenting and code layout. You are to provide comments to describe: your details, program
description, all variable definitions, all functions, and every significant section of code.
o Meaningful variable names.

 Your solutions MAY make use of the following:
o Built-in functions including range(), input(), print(), open(), min(), max(), format(),
len(), int(), str().
o List methods including append(), pop(), insert().
o String methods including find(), split(), strip(), format().
o Concatenation (+) operator to create/build new strings.
o Comparison operators (==, !=, , etc).
o Access to individual elements in a list or string with an index i.e. seq_name[index].
o Access to a sequence of elements in a list or string using slicing i.e. seq_name[start:stop:step]
o Use of any of the functions you have written in part 1 of the assignment.
o Use of any classes and methods in blackjack.py.

 Your solutions MUST NOT use:
o break, or continue statements
o quit() or exit()

Please ensure that you use Python 3.4 or later in order to complete your assignments. Your programs MUST run
using Python 3.4.

联系我们
  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-21:00
  • 微信:codinghelp
热点标签

联系我们 - QQ: 99515681 微信:codinghelp
程序辅导网!