**News Alert:**Experts Exchange Confirmed as Safe in Cloudbleed Leak Read More

Solved

Posted on 2003-11-19

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.

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.

5 Comments

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

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

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/

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

Question has a verified solution.

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

Title | # Comments | Views | Activity |
---|---|---|---|

TVirtualStringTree search using TEdit | 7 | 122 | |

delphi prevent click fast | 2 | 220 | |

Best Firemonkey component pack | 1 | 106 | |

How to make Sign in, using Clientdataset? | 1 | 19 |

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