420 likes | 623 Views
Horse Racing Simulation System Presented By Ting Hin Chau Supervised By Professor Michael R. Lyu April 2004. Agenda. Objectives of Project Background of Horse Racing Major Business Functions of Objects System Design Simulation Algorithm Conclusion Q & A.
E N D
Horse Racing Simulation System Presented By Ting Hin Chau Supervised By Professor Michael R. Lyu April 2004
Agenda • Objectives of Project • Background of Horse Racing • Major Business Functions of Objects • System Design • Simulation Algorithm • Conclusion • Q & A
Objectives / Background / Business Functions / System Design / Simulation Algorithm Objectives • To demonstrate CORBA implementation • To demonstrate horse racing simulation
Objectives / Background / Business Functions / System Design / Simulation Algorithm Background of Horse Racing • Jockey Club • Stable • Gambler
Objectives / Background / Business Functions / System Design / Simulation Algorithm Background of Horse Racing Inefficient Procedures • Race Registration: Paper Work • Betting: Off-course betting branches
Objectives / Background / Business Functions / System Design / Simulation Algorithm Background of Horse Racing Difficult Result Prediction • Personal Judgement
Objectives / Background / Business Functions / System Design / Simulation Algorithm Business Functions Jockey Club • Formulating Horse Racing Schedule • Schedule Query by Stable • Processing Horse Registration for a Race by Stable
Objectives / Background / Business Functions / System Design / Simulation Algorithm Business Functions Jockey Club • Race Query by Gamblers • Accepting Bets from Gamblers • Calculating Odds (Appendix 1) • Running Races • Dividend Payout
Objectives / Background / Business Functions / System Design / Simulation Algorithm Business Functions Stable • Horse Query by Gamblers • Horse Registration for a Race
Objectives / Background / Business Functions / System Design / Simulation Algorithm Business Functions Gambler • Depositing Money to Betting Account • Placing Bets
Database (Oracle 8i) Server Object 1 Server Object N Object Request Broker (VisiBroker for Java 4.0) Client Object 1 Client Object N Java Applet Objectives / Background / Business Functions / System Design / Simulation Algorithm System Design • Interaction
Objectives / Background / Business Functions / System Design / Simulation Algorithm System Design Object Request Broker • VisiBroker for Java 4.0 • Service Lookup • Object Instantiation • Connection Setup between Client and Server Objects
Objectives / Background / Business Functions / System Design / Simulation Algorithm System Design Object Request Broker
Objectives / Background / Business Functions / System Design / Simulation Algorithm System Design Server Objects • Interfaces defined in CORBA/IDL interface Buyer { attribute unsigned longBuyerID; attribute stringBuyerPassword; attribute stringBuyerName; attribute floatBalance; attribute stringAccountNumber; exception NotEnoughMoneyInAccount { }; void deposit(in float amount); void withdraw(in unsigned long amount) raises(NotEnoughMoneyInAccount); void edit(in string buyerName, in string buyerPassword, in string accountNumber); };
Objectives / Background / Business Functions / System Design / Simulation Algorithm System Design CORBA/IDL to Java Mapping
Objectives / Background / Business Functions / System Design / Simulation Algorithm System Design idl2java • Interface file • Helper file • Holder file • Stub file • POA file
Objectives / Background / Business Functions / System Design / Simulation Algorithm System Design Server Objects • Buyer • BuyerProcessor • Stable • StableProcessor • Race
Objectives / Background / Business Functions / System Design / Simulation Algorithm System Design Client GUI • RaceAdminClient • StableClient • BuyerClient
Objectives / Background / Business Functions / System Design / Simulation Algorithm System Design Client GUI • RaceAdminClient
Objectives / Background / Business Functions / System Design / Simulation Algorithm System Design Client GUI • StableClient
Objectives / Background / Business Functions / System Design / Simulation Algorithm System Design Client GUI • BuyerClient
Objectives / Background / Business Functions / System Design / Simulation Algorithm System Design Database Server • Oracle 8i • Persistent storage of data • Maintaining data integrity • E-R diagram (Appendix 2)
Objectives / Background / Business Functions / System Design / Simulation Algorithm Simulation Algorithm Monte Carlo Simulation • Simulation with a built-in random process • Different possible outcomes
Objectives / Background / Business Functions / System Design / Simulation Algorithm Simulation Algorithm Steps of Simulation (Appendix 3) 1. Data Input • Gather data on historical ranks of a horse • Transform these ranks to a value R/N, which is rank/number of horses in the race
Objectives / Background / Business Functions / System Design / Simulation Algorithm Simulation Algorithm Steps of Simulation 2. Distribution Construction • Form frequency distribution • Form probability distribution • Form cumulative probability distribution
Objectives / Background / Business Functions / System Design / Simulation Algorithm Simulation Algorithm Steps of Simulation
Objectives / Background / Business Functions / System Design / Simulation Algorithm Simulation Algorithm Steps of Simulation 3. Draw a sample from distribution • Generate a random number N from 0 to 1 • N refers to P(X <= x), where X is R/N
Objectives / Background / Business Functions / System Design / Simulation Algorithm Simulation Algorithm Steps of Simulation
Objectives / Background / Business Functions / System Design / Simulation Algorithm Simulation Algorithm Steps of Simulation 4. Compare R/N across horses • Sort the R/N values of the horses in a race • A horse with a smaller R/N beats out a horse with a higher R/N
Objectives / Background / Business Functions / System Design / Simulation Algorithm Simulation Algorithm Assumptions of Simulation • Independent distribution of R/N • Factors including location of racecourse, lane, and jockey are insignificant • Data from the 10 most recent races are used
Objectives / Background / Business Functions / System Design / Simulation Algorithm Conclusion CORBA • Language independent • Different platforms • ORB expensive
Objectives / Background / Business Functions / System Design / Simulation Algorithm Conclusion Simulation • Mimics the “random” factor in horse racing • Choice of size of distribution is hard to determine • Error of prediction can be estimated
Objectives / Background / Business Functions / System Design / Simulation Algorithm Appendix 1 Calculation of Odds 1. Win Odds • dw = bi / bw 2. Place Odds • dw1 = (bi - bw1 - bw2 - bw3) /( 3 * bw1) + 1
BetAccountBal GamblerName Status AccountNum Status Password SID Password GID Stable_t Gambler_t Gambler-bet BetType Horse_t Race_t Bet_t BetAmount Owns Race-bet TxnStatus Birthday HID RaceDate Weight Status RaceEventNumber HLane Joins HorseRank Objectives / Background / Business Functions / System Design / Simulation Algorithm Appendix 2
Objectives / Background / Business Functions / System Design / Simulation Algorithm Appendix 3 Simulation Calculation
Objectives / Background / Business Functions / System Design / Simulation Algorithm Appendix 3 Simulation Calculation
Objectives / Background / Business Functions / System Design / Simulation Algorithm Appendix 3 Simulation Calculation
Objectives / Background / Business Functions / System Design / Simulation Algorithm Appendix 3 Simulation Calculation • Two points on the cumulative distribution (x1, y1) and (x2, y2), for instance, for horse 1, they correspond to (0.25, 0.5) and (0.25, 0.6), will be used to calculate the final score of a horse by linear equation , based on the random number generated.
Objectives / Background / Business Functions / System Design / Simulation Algorithm Appendix 3 Simulation Calculation • For horse 1, point 1 (x1, y1) is (0.4, 0.2) and point 2 (x2, y2) is (0.5, 03) • R/N of horse 1 = (rand1-y1)*((x2-x1)/(y2-y1)) + x1 = (0.5379783655654367 – 0.2)* (0.25 – 0.25)/(0.6-0.5) + 0.25 = 0.25
Objectives / Background / Business Functions / System Design / Simulation Algorithm Appendix 3 Simulation Calculation • For horse 2, point 1 (x1, y1) is (0.4, 0.2) and point 2 (x2, y2) is (0.5, 0.3). • R/N of horse 2 = (rand2-y1)*((x2-x1)/(y2-y1)) + x1 = (0.21096296234313094 – 0.2)* (0.5 – 0.4)/(0.3-0.2) + 0.4 = 0.410962962
Objectives / Background / Business Functions / System Design / Simulation Algorithm Appendix 3 Simulation Calculation • For horse 3, point 1 (x1, y1) is (0, 0) and point 2 (x2, y2) is (0.125, 0.1). • R/N of horse 3 = (rand2-y1)*((x2-x1)/(y2-y1)) + x1 = (0.02229991816731558 – 0)* (0.125 – 0)/(0.1-0) + 0 = 0.027874898
Objectives / Background / Business Functions / System Design / Simulation Algorithm Appendix 3 Simulation Calculation • For horse 4, point 1 (x1, y1) is (0.5355, 0.4) and point 2 (x2, y2) is (0.545455, 0.5). • R/N of horse 3 = (rand2-y1)*((x2-x1)/(y2-y1)) + x1 = (0.4920612612595172 – 0.4) * (0.545455 – 0.5355)/(0.5-0.4) + 0.5355 = 0.544664699