This forum is in archive mode. You will not be able to post new content.

Author Topic: sports match engine  (Read 7933 times)

0 Members and 1 Guest are viewing this topic.

Offline halfblood

  • /dev/null
  • *
  • Posts: 17
  • Cookies: 2
    • View Profile
sports match engine
« on: November 25, 2012, 01:28:30 PM »
i want to build a web application. its an engine that simulates a match based on the statistics of each team. iv decided to go with asp.net that is vb.net. im not building for commercial purposes but generally for fun and also because i can. so anybody ever thought of it?? perhaps might want to share some views/ideas?? i want to see how people would approach this,might also give me some ideas. so post away how you would do it... thanks :)
"They never Learn!" - Lord Voldemort

Offline Daemon

  • VIP
  • Baron
  • *
  • Posts: 845
  • Cookies: 153
  • A wise man fears a gentle mans anger
    • View Profile
Re: sports match engine
« Reply #1 on: November 25, 2012, 06:34:07 PM »
First things first, asp.net != vb.net. and if you dont understand != then your not ready for this project. Idk what your experience is and idc, I'm just going to assume you know what your getting into and have the experience needed for this. That said, here's what I would do and I'm applying it to soccer cause I don't like american football and you never specified :P

The math would be the hardest part, a first step would be applying a point system to each stat for a team. So on a scale of say 10 points per stat, the better they are the lower their score. A 1 is a perfect score and 10 is the worst. This will help keep numbers low so the program runs better. So lets say you have five stats: pass completion, possession, shooting percentage, goals scored, and total game won percentage. Now well do this for Barcelona:
Pass completion: 2
Possession: 1
Shooting percentage: 4
Goals scored: 3
Game won percentage: 3

Just an approximation made up off the top of my head, real stats would be much different.

Now after doing this per team you would then have to do some.math to calculate the percentage chance of a win between any two teams. At first you'd calculate this just on stats, but later you'd have to tweak it to account for the unpredictability that makes sports so lovable. Id have to think harder about how to do that before I could tell you. Your better off doing it yourself imo.

Now when you build the program your going to have to make sure your output is backwards, low scores are the *winners*.

Of course to make it more accurate, you'd need to look at other stats and possibly change how you do point percentages. Maybe make 100 the total per stat for more accurate results, add in stuff like whether the team usually wins in a comeback or not etc.


Its a huge undertaking mate, but if its something your into then good luck. I honestly think the hardest padrt will be the math as long as your keeping its graphics simple. Cheers
This lifestyle is strictly DIY or GTFO - lucid

Because sexploits are for h0edays - noncetonic


Xires burns the souls of HF skids as a power supply

Offline halfblood

  • /dev/null
  • *
  • Posts: 17
  • Cookies: 2
    • View Profile
Re: sports match engine
« Reply #2 on: November 25, 2012, 10:23:41 PM »
As i said it is just for fun. so there really isnt a right way or wrong way to do this. nobody is going to test me for this. anyway my point of approach was actually the opposite, 1 is the lowest skill point while 10 might be the highest. so we go for a player say cristiano ronaldo,
speed 10
handling 10
attack 10. you get the average of this which is 10 then 10 is a perfect set, you get it into percentage which is 100% so it would now be 10=100%.. then you get a random number between 1 and 100 and if the random number <= player skill percentage then he scores a goal. anyway thats just my view. again i say i dont need tutorials or lectures in this just other peoples views. but thanks chap i appreciate it certainly you have given me more facts that should take into account. :)
« Last Edit: November 25, 2012, 10:26:05 PM by halfblood »
"They never Learn!" - Lord Voldemort

Offline techb

  • Soy Sauce Feeler
  • Global Moderator
  • King
  • *
  • Posts: 2350
  • Cookies: 345
  • Aliens do in fact wear hats.
    • View Profile
    • github
Re: sports match engine
« Reply #3 on: November 25, 2012, 11:20:47 PM »
Skill set still needs randomness. No one is 100%, plus you need to factor in things such as weather, moral, homefiled advantage, illness, other players effecting the outcome, wear/tear such as longevity of the game, crowds rooting/booing, previews games played, etc...


I would suggest getting actual stats for all games and then average  then add probability of only a couple factors. Once you have the code working, add more factors, making things modular/OOP. It might be a great exercise to learn programming whether it fails or not. I can even see a few places where something such as recursion or sorting algorithms could come into play.
>>>import this
-----------------------------

Offline Daemon

  • VIP
  • Baron
  • *
  • Posts: 845
  • Cookies: 153
  • A wise man fears a gentle mans anger
    • View Profile
Re: sports match engine
« Reply #4 on: November 26, 2012, 03:01:53 AM »
yea you could do it 1-100 with 100 being the highest. but your code will be more efficient if 1 is the highest, because lower numbers compute faster. Will it make a difference in this program? No. Is it a good habit to get into? Hell yea
This lifestyle is strictly DIY or GTFO - lucid

Because sexploits are for h0edays - noncetonic


Xires burns the souls of HF skids as a power supply

Offline halfblood

  • /dev/null
  • *
  • Posts: 17
  • Cookies: 2
    • View Profile
Re: sports match engine
« Reply #5 on: November 26, 2012, 07:15:50 AM »
actually what i had in mind was a rugby game. it lasts 14mins. so during that time i loop around all players with calculation of their stats. the game shouldnt be too predictable and it also shouldnt be based on luck too much. generally make it such that the higher stats you team has the higher chambes of you winning the game. after the main stats coding is where i can factor moral,energy,weather,fans.. but to me the tricky parts gets to automation using a time control. id want after 7mins they go for half time then resume play automatically after 2mins for the rest of the game... should be a fun project..:) actually il go with 1 as the highest, generally consumes less memory,
« Last Edit: November 26, 2012, 07:18:27 AM by halfblood »
"They never Learn!" - Lord Voldemort

Offline halfblood

  • /dev/null
  • *
  • Posts: 17
  • Cookies: 2
    • View Profile
Re: sports match engine
« Reply #6 on: December 27, 2012, 11:01:45 AM »
a question. so i got the match engine sorted out. and btw i decided to go with php. so how can i now implement it so that all matches in all the teams that have registered play out regardless of whether the owner of the team is online or not?
"They never Learn!" - Lord Voldemort

Offline Uriah

  • Sir
  • ***
  • Posts: 454
  • Cookies: 42
  • άξονας
    • View Profile
Re: sports match engine
« Reply #7 on: December 27, 2012, 11:15:49 AM »
Im not sure if I understood the question correctly, but couldn't you just not specify such a condition in the first place? Perhaps a code sample would help, though. I can't help with what I can't see! :)

Offline halfblood

  • /dev/null
  • *
  • Posts: 17
  • Cookies: 2
    • View Profile
Re: sports match engine
« Reply #8 on: December 27, 2012, 12:49:20 PM »
its some what like a sport management game. now suppose it has about 1000 teams. how do i get the match engine to simulate all the matches at the same time, probably 500 matches
"They never Learn!" - Lord Voldemort

Offline Uriah

  • Sir
  • ***
  • Posts: 454
  • Cookies: 42
  • άξονας
    • View Profile
Re: sports match engine
« Reply #9 on: December 27, 2012, 01:20:45 PM »
It would be a lot easier if I could see an excerpt of the code. :)
« Last Edit: December 27, 2012, 01:20:52 PM by Uriah »

Offline Daemon

  • VIP
  • Baron
  • *
  • Posts: 845
  • Cookies: 153
  • A wise man fears a gentle mans anger
    • View Profile
Re: sports match engine
« Reply #10 on: December 27, 2012, 07:18:52 PM »
It would be a lot easier if I could see an excerpt of the code. :)

There is.no.code atm, he's asking for ideas to generate it. Yhink.of what he's asking for as a function, a black box within a larger piece of code then write out the logic you would use for it. Its a good habit to get into, create a logic flow chart before actually writing the code to.reduce your logic errors.

@OP
It is impossible to do 500 calculations at the exact same.nanosecond, comouters just don't work tthat way. However if you just use a for loop, or a do while, to repeat the calculations for each match then to the end user it would appear simultaneous.

What I would do:
Create a random number genrator function then do this:

Do
CallRandomNumber()
Calculate here
X --
While (x > 0)

Roughly something like that, the random nunber generator would he the "luck" factor and is random.so its not human biased. Its not truly random since no computet can ever really ve, but its close enough for now
This lifestyle is strictly DIY or GTFO - lucid

Because sexploits are for h0edays - noncetonic


Xires burns the souls of HF skids as a power supply

Offline techb

  • Soy Sauce Feeler
  • Global Moderator
  • King
  • *
  • Posts: 2350
  • Cookies: 345
  • Aliens do in fact wear hats.
    • View Profile
    • github
Re: sports match engine
« Reply #11 on: December 27, 2012, 07:46:38 PM »
Well you could do multiple calculations at once kinda. Use threading. It is CPU time share, or parallel processing if you have multiple cores.
>>>import this
-----------------------------

Offline Daemon

  • VIP
  • Baron
  • *
  • Posts: 845
  • Cookies: 153
  • A wise man fears a gentle mans anger
    • View Profile
Re: sports match engine
« Reply #12 on: December 28, 2012, 01:51:42 AM »
Well you could do multiple calculations at once kinda. Use threading. It is CPU time share, or parallel processing if you have multiple cores.

It's really too complicated though for this project, there is no need to use multi-threading at this point, he needs to get it working first. Especially as the OP sounds like he's a bit new to coding...

Yes, multi-threading is possible. But honestly, not worth it here
This lifestyle is strictly DIY or GTFO - lucid

Because sexploits are for h0edays - noncetonic


Xires burns the souls of HF skids as a power supply

Offline techb

  • Soy Sauce Feeler
  • Global Moderator
  • King
  • *
  • Posts: 2350
  • Cookies: 345
  • Aliens do in fact wear hats.
    • View Profile
    • github
Re: sports match engine
« Reply #13 on: December 28, 2012, 02:01:44 AM »
It's really too complicated though for this project, there is no need to use multi-threading at this point, he needs to get it working first. Especially as the OP sounds like he's a bit new to coding...

Yes, multi-threading is possible. But honestly, not worth it here

I agree threading is a bit over le head. But with what was asked I gave appropriate answers. Like Daemon said, stick with looping for now. But if you have 1,000 sets to test, I would cut that down a bit if your going php.
>>>import this
-----------------------------

Offline halfblood

  • /dev/null
  • *
  • Posts: 17
  • Cookies: 2
    • View Profile
Re: sports match engine
« Reply #14 on: December 28, 2012, 02:12:18 PM »
i already got the code for the match engine sorted out.
just an example for you to get the point..

if (team1attack>tean2attack)

{ $team1points=7
$team2points=3
}
thats just a basic example...
 so lets say i have about 1000 team profiles on my website and i want the all matches to take place at the same time,how do i get this done? such as is on www.blackoutrugby.com or hattrick.... that my question, at the momment


oh and i really appreciate the contribution
« Last Edit: December 28, 2012, 02:14:14 PM by halfblood »
"They never Learn!" - Lord Voldemort

 



Want to be here? Contact Ande, Factionwars or Kulverstukas on the forum or at IRC.