Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com
Answertopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 

Hand Scoring - Points

A hand has a point value, based on the mixture of Sets. This point value is used to resolve the amount owed to the winner by the losers in the game. There is a subtlety to this evaluation that we have to gloss over, and that is the rules about for concealed and exposed or melded sets. For now, we will assume that all sets are concealed.

We need to expand our definition of SuitTile. There are two different score values for SuitTiles: the terminals (one and nine) have one score, and the simples (two through eight) have a different score. This will lead to two subclasses of SuitTile: TerminalSuitTile and SimpleSuitTile.

A winning hand has a base value of 20 points plus points assigned for each of the four scoring sets and the pair.

Set Simples Terminals or Honors
SequenceSet 0 0
ThreeSet 4 8
FourSet 16 32

The PairSet is typically worth zero points. However, the following kinds of pairs can add points to a hand.

  • A pair of dragons is worth 2 points.

  • A pair of winds associated with your seat at the table is worth 2 points.

  • A full game consists of four rounds. Each round has a prevailing wind. Within each round, each of the players will be the dealer. A pair of the round's prevailing winds is worth 2 points.

  • A double wind pair occurs when your seat's wind is also the prevailing wind. A pair of this wind is worth 4 points.

There are a few more ways to add points, all related to the mechanics of play, not to the hand itself.

Update the Tile Class Hierarchy. You will need to add two new subclass of SuitTile: TerminalSuitTile and SimpleSuitTile.

You will need to add a simple method to the Tile class which returns False. The SimpleSuitTile (ranks 2 to 8), however, will override this method to return True.

You will need to add a lucky( prevalingWind , myWind ) method to the Tile class which returns False. The HonorsTile will override this method to return True if the name is a dragon ("Red", "Green" or "White") or prevalingWind or myWind .

You will want to upgrade Wall to correctly generate the various HonorsTile, TerminalSuitTile and SimpleSuitTile instances.

You may also want to create a Generator for tiles. A function similar to the following can make programs somewhat easier to read.

def tile( *args ):
    """tile(name) -> HonorsTile
    tile( rank, suit ) -> SuitTile
    """
    if len(args) == 1:
        return HonorsTile( *args )
    elif args[0] in ( 1, 9 ):
        return TerminalSuitTile( *args )
    else:
        return SimpleSuitTile( *args )

Update the Set Class Hierarchy. You can then add a points( prevailingWind , myWind ) to the Set class hierarchy. This function will examine the first Tile of the Set to see if it is simple or not, and return the proper number of points. The wind isn't used for most Sets.

In the case of PairSet, however, the first Tile must be checked against two rules. If prevailingWind is the same as myWind and the same as the tile's name, this is worth 4 points. If the tile's lucky method is True (a dragon, or one of the two winds), then the value is 2 points.

Update the Hand Class. You'll want to add a points function which computes the total number of points for a hand. You may also want to write a pointReport which prints a small scorecard for the hand, showing each set and the points awarded.

You will want to revise your unit tests, also, to reflect these changes. You'll also need to add additional unit tests to check the number of points in each hand.

For the first test cases in the previous the section called “Some Test Cases”, here are the scores.

Set Points
Winning 20
ThreeSet['2B', '2B', '2B'] 4
StraightSet['3B', '4B', '5B'] 0
PairSet['5B', '5B'] 0
ThreeSet['2D', '2D', '2D'] 4
ThreeSet['Green', 'Green', 'Green'] 8
Points 36

For the second test cases in the section called “Some Test Cases”, here are the scores.

Set Points
Winning 20
ThreeSet['2B', '2B', '2B'] 4
StraightSet['3B', '4B', '5B'] 0
PairSet['5B', '5B'] 0
ThreeSet['2D', '2D', '2D'] 4
StraightSet['2D', '3D', '4D'] 0
Points 28

Be sure to add a test case with lucky tiles (dragons or winds) as the pair.


 
 
  Published under the terms of the Open Publication License Design by Interspire