Solved

About probabilty

Posted on 2003-11-19
5
239 Views
Last Modified: 2010-04-05
Hi,

I'm developing a soccer manager game, and I need to simulate the games result, then I do something like that:

First  I got  the power of the two teams, for example, Team A has 150 of power, and team B 80 of power. Then the probabilty of Team A win a game against Team B is higher. But soccer like any other sport is not a question of determinism. Then I will put some random possibility in the game. I think about this:

The soccer game has 90 minutes, then I put a timer (the player can change the delay) to simulate each minute, then this timer call a function to define if in that minute a team scores or not. In this function I use a random with different intervals for each team, for example Team A (150 of power) random(100), Team B (80 of Power) random (200) then If random = 1 then it's goal.  The possibility of Team A scores is higher then B.

What do you think about my method? Can I do it in a more precise and cientific way? I also wish to add more variables to change the goal probability (for eg. if a team play at home, has player with more energy etc). Can anyone help-me with this topic? Please, pieces of code are welcome.

Thanks in advance.
0
Comment
Question by:scoopbh
5 Comments
 

Accepted Solution

by:
siu01spa earned 168 total points
ID: 9786703
The delphi random function isn't very good, if possible you could get more realistic results by using the RandG function (need to include the "Math" library). This function gives you a result with a gaussian probability.

function RandG(Mean, StdDev: Extended): Extended;

if you use the mean as 0 then the results will be 66% likely to be 1 standard deviation away from 0 (could be + or - through)

The teams power could then be related to the StdDev that you use

ie higher team power = smaller StdDev = more chance of result being nearer 0.

0 could then be a goal.

The result for this function is an EXTENDED that is 3.45643 for example. You will need to round or trunc these results to then get an integer result but then it sould work well!

Below is an example of this function.

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, Math, StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    Edit1: TEdit;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
  Edit1.Text := FloatToStr(RandG(0,10));
end;

end.

The edit box will show the result of the function call and it will be between -10 and +10 about 66% of the time.

Hope this helps.

Steve A
0
 
LVL 34

Assisted Solution

by:Slick812
Slick812 earned 166 total points
ID: 9790173
I do not think a better Randomizer will do much for you. . .

Although you are Programming in Delphi, , , , it seems to me that this question does not have much to do with programming and code . . . it is a statistalcal MATH question , you might find more help in the Math and Science area here at EE

http://www.experts-exchange.com/Miscellaneous/Math_Science/
0
 
LVL 2

Assisted Solution

by:odissey1
odissey1 earned 166 total points
ID: 9799493
Hi,

I would go with neural network (NN) here. Basically what you do first is to 'collect'  some data on yor team like
playofs/score
teams    A     B   C    
A           X   0:0 1:0
B          2:1   X   2:2
C          1:3  1:2   X

+ you may have extra info (home field, rainy day, coach salary, beer price...) so it is multi-dimensional array.
Score = F( team, home field, rainy day, coach salary, beer price...)

First you will 'train' your neural network on some 'previously collected' data (say, last season). Then you can use obtained NN matrix to predict future games (and correct NN after each game). You can elaborate model further. Lets include ALL player names into array F(..., Smith, Jones, Barni,... )  - more valuable information, same code.
There are plenty NN examples for delphi available. But do not expect small code here (~1000 lines at least). Good luck!

Finally, I would suggest first to precize what the goal is. Otherwize it is not clear what are you up to.

regards,
odissey1
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Best Firemonkey component pack 1 116
Connection between libmysql.dll and MySQL Versions 7 110
Create Database on Android via Delphi dbExpress 3 108
find a node in VST 2 70
The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

789 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question