Solved

About probabilty

Posted on 2003-11-19
5
235 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
Comment Utility
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 33

Assisted Solution

by:Slick812
Slick812 earned 166 total points
Comment Utility
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
Comment Utility
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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

771 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now