Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

SecurePlayLibrary::SPTRandomClass Class Reference

#include <SPTRandomClass.h>

Inheritance diagram for SecurePlayLibrary::SPTRandomClass:

SecurePlayLibrary::SPAbstractTransactionClass SecurePlayLibrary::SPRootTransactionClass SecurePlayLibrary::SPAbstractTransactionInterface List of all members.

Detailed Description

This transaction class extends the SPAbstractTransaction class. It provides for the generation of fair random events over a network based on a Random. The APIconfigureTransaction method sets the 3 unique parameters - deckSize, repacement, and expirecount for the Random. The Random class can be used for a typical game with a shared Random and a dealer or for games without shared Randoms (in which case each Random is a separate instance of the class). Randoms can contain multiple "decks", but this is handled at the game rules level outside of the SecurePlay library
Author:
IT GlobalSecure
See also:
SecurePlay License Information


Public Member Functions

 SPTRandomClass ()
 ~SPTRandomClass ()
 SPTRandomClass (SPGameInterface *gameobj, string master, vector< string > playerIDList, bool virtualflag, string transactionID)
void pruniqueinit ()
bool APIconfigureTransaction (string sender, vector< string > args)
bool APIconfigureTransaction (string sender, int decksize, bool replacement, int expiration)
bool onprepareRandom (SPMessageClass *incoming)
bool onsendPlayerKeyTransform (SPMessageClass *incoming)
bool onsendPlayerKey (SPMessageClass *incoming)
bool prcheckPlayerKeyLoad ()
bool prbuildRandom ()
void prcreateRandomKey ()
bool APIgenerateRandomEvent (string sender, vector< string > receivers, bool privacy, int count)
bool prgetRandomValue (string playverifyflag)
bool onrequestRandomEvents (SPMessageClass *incoming)
bool onRandomEvents (SPMessageClass *incoming)
int APIgetRandomEvent (int index)
vector< string > APIgetlastRandomEvents ()
bool APIcompleteTransaction (string pid)
bool oncompleteTransaction (string sourceid, vector< string > body)
SPUEctf APIverifyRandom ()
bool pronincomingTransaction (SPMessageClass *incoming)
void onrequestconfigureTransaction (SPMessageClass *incoming)
string APISPawn (string pid)
bool spawnConfigureRandom (SPTRandomClass *a)
bool APIbeginTransaction (string pid)
bool APIrequestbeginTransaction (string pid)
SPTRandomAPIClassSPgetAPI ()
bool oncompleteTransaction (SPMessageClass *incoming)
bool isBuilt ()
vector< string > getDealtEventList ()
int getLastcount ()
int getPrdeckSize ()
int getPrexpireeventcount ()
vector< int > getPrkeyArray ()
int getPrkeySize ()
map< string, string > getPrplayerKeyList ()
map< string, string > getPrplayerKeyTransformList ()
vector< int > getPrremainingValuesList ()
bool isPrreplacement ()
SPTRandomAPIClassAPITAOcreateTransaction (SPGameAPIClass *gapi, string transmaster, vector< string > playerIDList, bool privateflag)
SPAbstractTransactionInterfacecreateTransaction (SPGameAPIInterface *gameapiobj, string master, vector< string > playerIDList, bool privateflag, string transactionID)

Static Public Member Functions

SPTRandomClassAPIcreateTransaction (SPGameAPIClass *gapi, string transmaster, vector< string > playerIDList, bool privateflag)
bool APIBcreateTransaction (SPGameAPIClass *gapi, string transmaster, vector< string > playerIDList, bool privateflag)
string gettranstype ()
bool registerTransaction ()

Protected Member Functions

SPAbstractTransactionInterfacebuildSPawn ()
SPTRandomClassbuildRandomSPawn ()
bool onSpawn (SPMessageClass *incoming)

Private Attributes

vector< string > dealtEventList
int lastcount
int prdeckSize
int prexpireeventcount
int prkeySize
vector< int > prkeyArray
map< string, string > prplayerKeyList
map< string, string > prplayerKeyTransformList
vector< int > prremainingValuesList
bool prreplacement
vector< int > prvremainingValuesList
vector< string > vdealtEventList
bool built
SPUEctf verified


Constructor & Destructor Documentation

SPTRandomClass::SPTRandomClass  ) 
 

Default Constructor

SPTRandomClass::~SPTRandomClass  ) 
 

Default Destructor

SPTRandomClass::SPTRandomClass SPGameInterface gameobj,
string  master,
vector< string >  playerIDList,
bool  virtualflag,
string  transactionID
 

Overloaded Constructor

Parameters:
gameobj SPAbstractGameInterface - the game object with which the transaction will be associated
master string - the master of the transaction
playerIDList vector<string> - the player id list
virtualflag bool - virtual flag
transactionID string - the transaction id


Member Function Documentation

bool SPTRandomClass::APIBcreateTransaction SPGameAPIClass gapi,
string  transmaster,
vector< string >  playerIDList,
bool  privateflag
[static]
 

This method allows the creation of a new MultiPartSimultaneous type, internally controlled transaction. It also sends a message to the other transaction and game participants about this new transaction.

Parameters:
gapi SPGameAPIInterface - the game that will be associated with this transaction.
transmaster String - player id of the master of the transaction
playerIDList String[] - This is an array that holds the Player IDs of the players within the game that are participating in this transaction.
privateflag boolean - This is a flag to describe whether the specific transaction is a private transaction to the non-participating Players.
Returns:
result - Boolean: TRUE, if successful, FALSE, if not.

bool SPTRandomClass::APIbeginTransaction string  pid  ) 
 

This action can only be initiated by the Transaction master. It sends a "beginTransaction" message to all of the transaction participants. A Transaction can only be begun if it has been successfully configured.

Parameters:
pid string - id of the transaction beginner, must be the master and internal.
Returns:
result - bool: TRUE, if successful, FALSE, if not

Reimplemented from SecurePlayLibrary::SPAbstractTransactionClass.

bool SPTRandomClass::APIcompleteTransaction string  pid  ) 
 

This method overrides the SPAbstractTransactionClass method. It supports the distribution of the shoe master player key to allow the shoe to be subsequently verified.

Parameters:
pid string - ID of requesting Player
Returns:
result - bool: TRUE, if successful, FALSE, if not

Reimplemented from SecurePlayLibrary::SPAbstractTransactionClass.

bool SPTRandomClass::APIconfigureTransaction string  sender,
int  decksize,
bool  replacement,
int  expiration
 

This method handles the specific configuration required for a Shoe

Parameters:
sender string - player id of the sender
decksize int - deck size of the shoe transaction
replacement bool - flag for replacability of the deck of this shoe transaction
expiration int - number of transactions before stop.
Returns:
status - bool: TRUE, if successful, FALSE, if not

bool SPTRandomClass::APIconfigureTransaction string  sender,
vector< string >  args
 

This method overrides the APIconfigureTransaction included in the SPAbstractTransactionClass. It supports the configuration of the decksize,replacement, and shoeexpire parameters. NOTE, this method also triggers a series of onXXX handlers to completely configure the shoe. it does not use or override the onconfigureTransaction portion of the AbstractTransactionClass, also, the handlers for this method are triggered by the local princomingTransaction handler.

Parameters:
sender string - the sender
args vector<string> - the configuration array
Returns:
bool TRUE, if successful, FALSE, if not

Reimplemented from SecurePlayLibrary::SPAbstractTransactionClass.

SPTRandomClass * SPTRandomClass::APIcreateTransaction SPGameAPIClass gapi,
string  transmaster,
vector< string >  playerIDList,
bool  privateflag
[static]
 

This method allows the creation of a new MultiPartSimultaneous type, internally controlled transaction. It also sends a message to the other transaction and game participants about this new transaction.

Parameters:
gapi SPGameAPIInterface - the game that will be associated with this transaction.
transmaster String - player id of the master of the transaction
playerIDList String[] - This is an array that holds the Player IDs of the players within the game that are participating in this transaction.
privateflag boolean - This is a flag to describe whether the specific transaction is a private transaction to the non-participating Players.
Returns:
tran - SPMultiPartSimultaneousClass(but returns the actual object) - if successful, null if not

bool SPTRandomClass::APIgenerateRandomEvent string  sender,
vector< string >  receivers,
bool  privacy,
int  count
 

This method handles either requests or local generation of random events by the shoe master. Either a request message will be sent to the shoe master or the shoe master will generate the number of random events specified by (count) and send them to the specified receivers. This value is protected based on the privacy flag.

Parameters:
sender string - sender
receivers string - player id list of the recievers
privacy bool - privacy policy
count int - the number of random events to be generated
Returns:
result - bool: TRUE, if successful, FALSE, if not

vector< string > SPTRandomClass::APIgetlastRandomEvents  ) 
 

This method returns an array that includes the last set of random events provided by the shoe master.

Returns:
rmevents - vector<string> - the last batch of random events

int SPTRandomClass::APIgetRandomEvent int  index  ) 
 

This method returns a random event from the dealtEventList property as specified by the index.

Parameters:
index int - the specifier of the random event
Returns:
rmevent - int - the corresponding dealtEventList entry to the index

bool SPTRandomClass::APIrequestbeginTransaction string  pid  ) 
 

This method allows any transaction participant excluding the Transaction master to request that the transaction be begun. This can only be done after the transaction has been configured.

Parameters:
pid string - the id of the requestor, can not be master, must be internal
Returns:
result - bool: TRUE, if successful, FALSE, if not

Reimplemented from SecurePlayLibrary::SPAbstractTransactionClass.

string SPTRandomClass::APISPawn string  pid  ) 
 

This method creates a new transaction with the identical participants and configuration as the spawning transaction.

Parameters:
pid string - player id must be master of the transaction
Returns:
tid - string - transaction id of the new spawned transaction.

Reimplemented from SecurePlayLibrary::SPAbstractTransactionClass.

SPTRandomAPIClass * SPTRandomClass::APITAOcreateTransaction SPGameAPIClass gapi,
string  transmaster,
vector< string >  playerIDList,
bool  privateflag
 

This method allows the creation of a new MultiPartSimultaneous type, internally controlled transaction. It also sends a message to the other transaction and game participants about this new transaction.

Parameters:
gapi SPGameAPIInterface - the game that will be associated with this transaction.
transmaster String - player id of the master of the transaction
playerIDList String[] - This is an array that holds the Player IDs of the players within the game that are participating in this transaction.
privateflag boolean - This is a flag to describe whether the specific transaction is a private transaction to the non-participating Players.
Returns:
tran - SPMultiPartSimultaneousAPIClass - if successful, null if not

SPUEctf SPTRandomClass::APIverifyRandom  ) 
 

This method verifies a shoe once the transaction has been completed. There is a third state that is possible - where a shoe was used for virtual events that did not include specific players. If those events are not exchanged elsewhere, a partial verification is all that is possible - that the shoe is "consistent" with known data.

Returns:
result - bool: TRUE, if successful, FALSE, if not, "consistent" if consistent, but not completely verified

SPTRandomClass * SPTRandomClass::buildRandomSPawn  )  [protected]
 

This method provides the unique transaction creation services for spawned Random transactions

SPAbstractTransactionInterface * SPTRandomClass::buildSPawn  )  [protected, virtual]
 

This method provides the unique transaction creation services for spawned Random transactions

Reimplemented from SecurePlayLibrary::SPAbstractTransactionClass.

SPAbstractTransactionInterface * SPTRandomClass::createTransaction SPGameAPIInterface gameapiobj,
string  master,
vector< string >  playerIDList,
bool  privateflag,
string  transactionID
[virtual]
 

This method creates a SPMultiPartSimultaneousClass transaction.

Parameters:
gameapiobj SPGameAPIInterface - the game that will be associated with this transaction.
master String - player id of the master of the transaction
playerIDList String[] - This is an array that holds the Player IDs of the players within the game that are participating in this transaction.
privateflag boolean - This is a flag to describe whether the specific transaction is a private transaction to the non-participating Players.
transactionID String - transaction id.

Reimplemented from SecurePlayLibrary::SPAbstractTransactionClass.

vector< string > SPTRandomClass::getDealtEventList  ) 
 

Getter function that returns the property: dealtEventList

Returns:
dealtEventList - vector<string>

int SPTRandomClass::getLastcount  ) 
 

Getter function that returns the property: lastcount

Returns:
lastcount - int

int SPTRandomClass::getPrdeckSize  ) 
 

Getter function that returns the property: prdeckSize

Returns:
prdeckSize - int

int SPTRandomClass::getPrexpireeventcount  ) 
 

Getter function that returns the property: prexpireeventcount

Returns:
prexpireeventcount - int

vector< int > SPTRandomClass::getPrkeyArray  ) 
 

Getter function that returns the property: prkeyArray

Returns:
prkeyArray - vector<int>

int SPTRandomClass::getPrkeySize  ) 
 

Getter function that returns the property: prkeySize

Returns:
prkeySize - int

map< string, string > SPTRandomClass::getPrplayerKeyList  ) 
 

Getter function that returns the property: prplayerKeyList

Returns:
prplayerKeyList - Hashtable

map< string, string > SPTRandomClass::getPrplayerKeyTransformList  ) 
 

Getter function that returns the property: prplayerKeyTransformList

Returns:
prplayerKeyTransformList - Hashtable

vector< int > SPTRandomClass::getPrremainingValuesList  ) 
 

Getter function that returns the property: prremainingValuesList

Returns:
prremainingValuesList - vector<int>

string SPTRandomClass::gettranstype  )  [static]
 

This method gets the transaction type.

Returns:
String

Reimplemented from SecurePlayLibrary::SPAbstractTransactionClass.

bool SPTRandomClass::isBuilt  ) 
 

Getter function that returns the property: built

Returns:
built - bolean

bool SPTRandomClass::isPrreplacement  ) 
 

Getter function that returns the property: prreplacement

Returns:
prreplacement - bool

bool SPTRandomClass::oncompleteTransaction SPMessageClass incoming  ) 
 

This method handles incoming "completeTransaction" messages. It overrides the default SPAbstractTransactionClass method. It also stores the incoming shoe master player key.

Parameters:
incoming SPMessageClass - incoming message
Returns:
result - bool: TRUE, if successful, FALSE, if not

Reimplemented from SecurePlayLibrary::SPAbstractTransactionClass.

bool SPTRandomClass::oncompleteTransaction string  sourceid,
vector< string >  body
 

This method handles incoming "completeTransaction" messages. It overrides the default SPAbstractTransactionClass method. It also stores the incoming shoe master player key.

Parameters:
incoming SPMessageClass - incoming message
Returns:
result - bool: TRUE, if successful, FALSE, if not

bool SPTRandomClass::onprepareRandom SPMessageClass incoming  ) 
 

This method/event handles the initial response to the APIconfigureTransaction call by the Transaction Master. It verifies that the message was from the transaction master, loads the master player key transform, and triggers the configuration of the shoe (prbuildShoe) method. It also initiates sending of all internal player key transforms to the other remote players.

Parameters:
incoming SPMessageClass - incoming message
Returns:
result - bool: TRUE, if successful, FALSE, if not

bool SPTRandomClass::onRandomEvents SPMessageClass incoming  ) 
 

This method handles incoming random events from the shoe master. The new random events are appended to the dealtEventlist array.

Parameters:
incoming SPMessageClass - incoming message
Returns:
result - bool: TRUE, if successful, FALSE, if not

void SPTRandomClass::onrequestconfigureTransaction SPMessageClass incoming  ) 
 

This method handles the unique processing associated with incoming requests to configure a Shoe Class.

Parameters:
incoming SPMessageClass - incoming message

Reimplemented from SecurePlayLibrary::SPAbstractTransactionClass.

bool SPTRandomClass::onrequestRandomEvents SPMessageClass incoming  ) 
 

This method handles incoming requests to generate Random events. This message must be sent by a party not the shoe master with a recipient of the shoe master. It also includes the proposed parameters for the shoe master to use. api.rulesgenerateRandomEvent is used to determine if this request is accepted.

Parameters:
incoming SPMessageClass - incoming message
Returns:
result - bool: TRUE, if successful, FALSE, if not

bool SPTRandomClass::onsendPlayerKey SPMessageClass incoming  ) 
 

This method handles incoming "sendPlayerKey" messages. It is the third stage in the configuration of the shoe. Once all player keys are recieved, excluding the shoe master's, the shoe master will create the game key (prKeyArray) and the shoe status will move to "ready";

Parameters:
incoming SPMessageClass - incoming message
Returns:
result - bool: TRUE, if successful, FALSE, if not

bool SPTRandomClass::onsendPlayerKeyTransform SPMessageClass incoming  ) 
 

This method handles incoming "sendPlayerKeyTransform" messages. This is the second stage of the shoe configuration process. Once all of the player key transforms are received, all of the player keys are sent to the remote players, excluding the shoe master/transaction master key.

Parameters:
incoming SPMessageClass - incoming message
Returns:
result - bool: TRUE, if successful, FALSE, if not

bool SPTRandomClass::onSpawn SPMessageClass incoming  )  [protected]
 

This method handles incoming spawn messages.

Parameters:
master string - id of the master
tid string - id of the transaction to be spawned
Returns:
result - bool: TRUE, if successful, FALSE, if not

Reimplemented from SecurePlayLibrary::SPAbstractTransactionClass.

bool SPTRandomClass::prbuildRandom  ) 
 

This method provides the core configuration common to all shoes. It sets the deckSize, replacement, and expireevent counter.

Returns:
result - bool: TRUE, if successful, FALSE, if not

bool SPTRandomClass::prcheckPlayerKeyLoad  ) 
 

This method is used to check the status of the loading of Player Keys during the Shoe configuration process. It is used internally to determine that the initialization phase has been complete.

Returns:
result - bool: TRUE, if successful, FALSE, if not

void SPTRandomClass::prcreateRandomKey  ) 
 

This method actually builds the game key from the various player keys. It combines them by essentially doing "character by character" addition.

bool SPTRandomClass::prgetRandomValue string  playverifyflag  ) 
 

This method actually generates the random values. It generates a single random value based on the settings in the shoe and stores and updates the shoe properties appropriately.

Parameters:
playverifyflag string
Returns:
result - bool: TRUE, if successful, FALSE, if not

bool SPTRandomClass::pronincomingTransaction SPMessageClass incoming  )  [virtual]
 

This method provides the unique handlers for incoming Secret turn message types

Parameters:
incoming SPMessageClass - incoming message
Returns:
bool - TRUE, if handled internally, FALSE, if not

Reimplemented from SecurePlayLibrary::SPAbstractTransactionClass.

void SPTRandomClass::pruniqueinit  ) 
 

Unique initialization method

Reimplemented from SecurePlayLibrary::SPAbstractTransactionClass.

bool SPTRandomClass::registerTransaction  )  [static]
 

Registers this transaction.

Returns:

bool SPTRandomClass::spawnConfigureRandom SPTRandomClass a  ) 
 

This method provides the unique transaction configuration services for spawned Shoe transactions

SPTRandomAPIClass * SPTRandomClass::SPgetAPI  ) 
 

Gets this class's API

Returns:
classAPI - SPShoeAPIClass


Member Data Documentation

bool SecurePlayLibrary::SPTRandomClass::built [private]
 

This property is set to bool TRUE if the Shoe has been constructed and FALS E, if not

vector<string> SecurePlayLibrary::SPTRandomClass::dealtEventList [private]
 

This property holds the sequential array of dealt random events.

int SecurePlayLibrary::SPTRandomClass::lastcount [private]
 

This property holds the last requested number of random events generated. It is used by the APIgetlastRandomEvents method.

int SecurePlayLibrary::SPTRandomClass::prdeckSize [private]
 

This property holds the size of the deck or shoe. It is set during the configuration of the shoe.

int SecurePlayLibrary::SPTRandomClass::prexpireeventcount [private]
 

This property sets the number of random events that can be generated from the deck. If the value is 0 or negative, the shoe does not expire due to this limit (though it may expire if the shoe has other size limits, such as sampling with out replacement). This parameter is important in that generating an excessive number of random events from a single shoe may endanger the performance of the game (the obvious example being the "burning" of a shoe in Blackjack).

vector<int> SecurePlayLibrary::SPTRandomClass::prkeyArray [private]
 

The keyArray is the computed key generated from all of the player keys.

int SecurePlayLibrary::SPTRandomClass::prkeySize [private]
 

This property holds the size of the shoe key. The default is set by the SecurePlay library. Careful selection of this parameter is important as it determines the strength of the randomization function.

map<string, string> SecurePlayLibrary::SPTRandomClass::prplayerKeyList [private]
 

This is an associative array that holds the player key string associated with each player.

map<string, string> SecurePlayLibrary::SPTRandomClass::prplayerKeyTransformList [private]
 

This property holds the associative array of transforms of the player keys.

vector<int> SecurePlayLibrary::SPTRandomClass::prremainingValuesList [private]
 

This array holds the remaining values that are possible for shoes that are sampled without replacement. Actual random values are generated and then indexed into this array to determine the dealt random event.

bool SecurePlayLibrary::SPTRandomClass::prreplacement [private]
 

This flag determines whether the shoe uses sampling with replacement (like rolling a dice) or sampling without replacement (like dealing cards from a deck or a lottery number draw). If this is set to false, the prremainingValuesList array is created.

vector<int> SecurePlayLibrary::SPTRandomClass::prvremainingValuesList [private]
 

This is a duplicate of the prremainingValuesList property that is used for Shoe verification. See the other object for additional details.

vector<string> SecurePlayLibrary::SPTRandomClass::vdealtEventList [private]
 

This is a duplicate of the dealtEventList array that is used for verification purposes only. See the dealtEventList property for further details.

SPUEctf SecurePlayLibrary::SPTRandomClass::verified [private]
 

This property holds three states: TRUE, if the Random can be completely verified, FALSE, if verification fails or the Random is not complete, and CONSISTENT if the Random is complete and the data is consistent with a valid Random but the Random cannot be completely verified (due to private random events).


The documentation for this class was generated from the following files: 2006 Copyright Filed by IT GlobalSecure, Inc. All Rights Reserved. Not to be used without authorization by Author. SecurePlay, IT GlobalSecure, and IT Armor are registered trademarks by IT GlobalSecure, Inc. Software protected by software license, and one or more the following U.S. and International patent numbers: U.S. Patent 6,030,288, U.S. Patent 6,165,072, European Patent Office EP1016049A1,and World Intellectual Property Organization WO9912135C1 and additional filings worldwide.