• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 244
  • Last Modified:

About probabilty

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
scoopbh
Asked:
scoopbh
3 Solutions
 
siu01spaCommented:
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
 
Slick812Commented:
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
 
odissey1Commented:
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

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now