Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
Solved

Posted on 2003-11-19
Medium Priority
243 Views
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.

0
Question by:scoopbh
[X]
###### Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

• Help others & share knowledge
• Earn cash & points

Accepted Solution

siu01spa earned 672 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

Slick812 earned 664 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

odissey1 earned 664 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

Question has a verified solution.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
###### Suggested Courses
Course of the Month9 days, 12 hours left to enroll