Title: Horse Racing Simulation System
1- Horse Racing Simulation System
- Presented By Ting Hin Chau
- Supervised By Professor Michael R. Lyu
- April 2004
2Agenda
- Objectives of Project
- Background of Horse Racing
- Major Business Functions of Objects
- System Design
- Simulation Algorithm
- Conclusion
- Q A
3Objectives
Objectives / Background / Business Functions /
System Design / Simulation Algorithm
- To demonstrate CORBA implementation
- To demonstrate horse racing simulation
4 Objectives / Background / Business Functions /
System Design / Simulation Algorithm
Background of Horse Racing
- Jockey Club
- Stable
- Gambler
5Objectives / Background / Business Functions /
System Design / Simulation Algorithm
Background of Horse Racing
- Inefficient Procedures
- Race Registration Paper Work
- Betting Off-course betting branches
6Objectives / Background / Business Functions /
System Design / Simulation Algorithm
Background of Horse Racing
- Difficult Result Prediction
- Personal Judgement
7Objectives / 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 -
8Objectives / 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
-
9Objectives / Background / Business Functions /
System Design / Simulation Algorithm
Business Functions
- Stable
- Horse Query by Gamblers
- Horse Registration for a Race
-
10Objectives / Background / Business Functions /
System Design / Simulation Algorithm
Business Functions
- Gambler
- Depositing Money to Betting Account
- Placing Bets
-
11Objectives / Background / Business Functions /
System Design / Simulation Algorithm
System Design
12Objectives / 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
13Objectives / Background / Business Functions /
System Design / Simulation Algorithm
System Design
14Objectives / Background / Business Functions /
System Design / Simulation Algorithm
System Design
- Server Objects
- Interfaces defined in CORBA/IDL
interface Buyer attribute unsigned
longBuyerID attribute stringBuyerPassword attrib
ute stringBuyerName attribute floatBalance attri
bute 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)
15Objectives / Background / Business Functions /
System Design / Simulation Algorithm
System Design
- CORBA/IDL to Java Mapping
IDL Java
module package
interface interface
operation method
attribute method pair
exception exception
16Objectives / Background / Business Functions /
System Design / Simulation Algorithm
System Design
- idl2java
- Interface file
- Helper file
- Holder file
- Stub file
- POA file
17Objectives / Background / Business Functions /
System Design / Simulation Algorithm
System Design
- Server Objects
- Buyer
- BuyerProcessor
- Stable
- StableProcessor
- Race
18Objectives / Background / Business Functions /
System Design / Simulation Algorithm
System Design
- Client GUI
- RaceAdminClient
- StableClient
- BuyerClient
19Objectives / Background / Business Functions /
System Design / Simulation Algorithm
System Design
- Client GUI
- RaceAdminClient
20Objectives / Background / Business Functions /
System Design / Simulation Algorithm
System Design
21Objectives / Background / Business Functions /
System Design / Simulation Algorithm
System Design
22Objectives / 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)
23Objectives / Background / Business Functions /
System Design / Simulation Algorithm
Simulation Algorithm
- Monte Carlo Simulation
- Simulation with a built-in random process
- Different possible outcomes
24Objectives / 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
25Objectives / 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
26Objectives / Background / Business Functions /
System Design / Simulation Algorithm
Simulation Algorithm
27Objectives / 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 lt x), where X is R/N
28Objectives / Background / Business Functions /
System Design / Simulation Algorithm
Simulation Algorithm
29Objectives / 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
30Objectives / 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
31Objectives / Background / Business Functions /
System Design / Simulation Algorithm
Conclusion
- CORBA
- Language independent
- Different platforms
- ORB expensive
32Objectives / 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
33Objectives / 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
34Objectives / Background / Business Functions /
System Design / Simulation Algorithm
Appendix 2
35Objectives / Background / Business Functions /
System Design / Simulation Algorithm
Appendix 3
36Objectives / Background / Business Functions /
System Design / Simulation Algorithm
Appendix 3
37Objectives / Background / Business Functions /
System Design / Simulation Algorithm
Appendix 3
38Objectives / 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.
39Objectives / 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
40Objectives / 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
41Objectives / 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
42Objectives / 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