• Hey, guest user. Hope you're enjoying NeoGAF! Have you considered registering for an account? Come join us and add your take to the daily discourse.

Documentation of the creation of a Soccer Simulation

Toma

Let me show you through these halls, my friend, where treasures of indie gaming await...
Current idea for the tactics:
rud1p.jpg


This way you'd set the tactics for the whole team, and the idea is that if you click on "Individual", you'd be able to finetune those settings for each individual player in your team. Before that I need to actually give those players a value for it and show the overall average for the team here, though. And make it so that changing the overall team value would result in changing the stats for every player to that value.
 

Toma

Let me show you through these halls, my friend, where treasures of indie gaming await...
Now you can change 4 tactical values individually for each player with this window:

wVyVB.jpg


The 4 values you can change are:

Aggressiveness
Shooting Behaviour
Passing Style
Defensive/Offensive

Additionally there is a fifth one for the whole team, whether they should play mostly along the wings or through the center.

So, I guess I can finally move onto the Match reports. There still might be one serious bug I need to find and exterminate, though. I dont even know whether its still existing in the current version of the program, but there might be a problem where the results arent correctly saved after 70% of the games or something. Pretty random.
 

Toma

Let me show you through these halls, my friend, where treasures of indie gaming await...
Yeah, I was able to replicate the bug. It happens if you save in the second half of the season. I assume its a problem with loading, it seems to save the values to the wrong team if saved during the second half of the season.

Hm... Definitely need to fix this one before doing anything else.

Edit: Fixed it! (Hopefully)

For some stupid reason I had a function in it that was changing back the correct sequence of teams.
 

Reuenthal

Banned
Bravo sir, bravo. As a FM fan and football fan I can't but feel glad for this undertaking.

About tactics, it will be useful if through a slider or otherwise you could order a player about how often they will go forward or to which extend. So if you want a RB to play all the right side, you could use a slider to do that.

The defensive, offensive slider might make that superfluous but I was thinking that to have to do with behavior rather than what I described. How much the player will be playing offensively and contribute to defense. Unless you are doing what I suggested with the aggressive slider. From first impression it seems to me to be how aggressive player will be when going at the ball, committing fouls and so on, but I might had misunderstood that part. Another FM inspired attention and I hope you don't find me irritating for adding another one, is a tempo slider. How quickly team will play with the ball and move.
 

Toma

Let me show you through these halls, my friend, where treasures of indie gaming await...
Reuenthal said:
Bravo sir, bravo. As a FM fan and football fan I can't but feel glad for this undertaking.

About tactics, it will be useful if through a slider or otherwise you could order a player about how often they will go forward or to which extend. So if you want a RB to play all the right side, you could use a slider to do that.

The defensive, offensive slider might make that superfluous but I was thinking that to have to do with behavior rather than what I described. How much the player will be playing offensively and contribute to defense. Unless you are doing what I suggested with the aggressive slider. From first impression it seems to me to be how aggressive player will be when going at the ball, committing fouls and so on, but I might had misunderstood that part. Another FM inspired attention and I hope you don't find me irritating for adding another one, is a tempo slider. How quickly team will play with the ball and move.

Hm, I definitely will include tool tips in the game later to tell the player what these aspects are referring to, but I was hoping to get it sort of intuitive.
My current idea was to have aggressiveness for the tackles, meaning a high aggressiveness would let you win a higher percentage of battles, but will also raise the foul count (and therefore chance for cards).

The idea for Offense/Defense, was basically what you described. If you set a defense player to the highest offense setting, he'd try to stir up trouble in front of the enemy goal, with the drawback that he might not be back in time for a counter attack.

The tempo slider is a good idea though. I could use this to measure dribble effectiveness (on top of aggressiveness and a dribbling stat), with the drawback of the player exhausting faster.

And I just noticed that there isnt a dribbling stat currently. Need to change that immediately.

Edit: Please tell me if any of this doesnt sound quite right.
 

Toma

Let me show you through these halls, my friend, where treasures of indie gaming await...
Added the Dribbling stat and the Tempo tactical value. I also added a second page for the tactical options, so that I wont need to make the window bigger if I want to include more tactical options.

Guess I now really will tackle the matchreport since I should have every important aspect by now, which brings a whole lot of new problems! Yay!
I mentioned earlier that I was already starting that, but due to the lack of team stats (formation, tactics etc) needed to postpone that.

This is what I have currently (right side):
e9gEO.jpg


The first problem is that I need to find a way of colorcoding teams and players for each team, which harder than it sounds since I need to save those matchreports. And I cant save blue text in a txt file. Therefore, I'll probably try including a parser that will look for certain text segments like T1 (as in T1:Argentina) to color the text and then delete the T1 afterwards. Hopefully that works out.

Oh and yeah, I need to find a way to save these matchreports at all. *goes back into the thinking chamber*
 

Toma

Let me show you through these halls, my friend, where treasures of indie gaming await...
MK2qP.jpg


Yay! Giving individual words a color was way more complicated than I thought it would be.. I needed to manually edit a RTF header and add RTF tags within the tags where I wanted them to be. After 1 hour of trial and error, I think I finally got the idea of RTF tags.

...well, learned something new.
 

Toma

Let me show you through these halls, my friend, where treasures of indie gaming await...
Part 11: Planning the Pre Report for the Match Simulation system.

Okay, after thinking a while about it, I noticed that I probably wont get around some match report specific data, that will again need to be saved. However, once I implement the saving structure for the matchreport data, I wont need to bug myself with saving anymore as it will automatically save every number of items stored in it.

So, to sort my thoughts out and get some feedback from you guys, these are the things I thought of up till now for the pre report:

Match type:
Currently everything will be classified as League match, because I dont have anything else atm, but I plan to introduce friendly and cup matches later, so why not include it now.
Examples:
"Welcome to today's league cup match, between..."
"Today's friendly is probably a good chance to measure the strength and weakness of both trainer's teams." (Reminds me, need a randomized trainer name)


League/Cup progress:
Depending on the tournament a statement whether its the first game , the final one, right before half season, right after half season, or just in the middle.
Examples:
"Both teams arrived at the semi-finals, who will be the one to advance?"
"First half of the season is almost over, will they go out with a bang?"


League standing
I would probably sort of measure the strength of teams by their table ranking and if they are within a certain number of ranks, include for example:
"This match is going to be heated! Both teams are ranked 5 and 7 repectively, so they won't give up point to their direct rivals."
or if they are too far apart:
"Team A sure has the better odds in this game, but who knows? Anything might happen."
"It would be pretty bad for Team A, to lose this one. Fans probably wouldnt like to lose against Team B."


League Series
Only if they have an outstanding record of the last 3 or more games all won or lost.
Examples:
"Team A won the last 3 games in the league. They are on a roll!"
"Doesnt look too good for team A these days, last 4 games lost. Hopefully, they get back to their feet soon."


Rivals
I want to dynamically create rivals over the years, either with teams that were sooo close to promote to the next league, but a competing team snapped it away or by making team rivals who were unusually harsh in a game, 3 red cards or something. I could use this to adjust the aggression in the next game between these two.
Examples:
"Last match against Team A sure got heated. Hopefully we won't see too many red cards today."
"Those two teams really cant stand each other. This could get ugly."


Scorer
Measuring every players goals, and assists and making a Top Goalgetter and Top scorer list. I could probably also measure the % of wins/losses in tackles/dribblings and then come of with reports like this:
"Team A really needs to be careful of Team B's Guy C, he already scored x goals out of y games in this season. [Depending on how much this actually is] Incredible! Probably one of the most dangerous players this season."
"Guy D from Team A already has x assists this season, this guy is a big asset to the team."


Best player
Sort of similar, but I want to have one category with the best player statswise. Probably by calculating all the values in the different positions and then giving an exact number which is the best player. Depending on the position and the number of games in starting position:
"Guy D is the backing of the team, he saved his team quite a few times."
"Team A sure is lucky to have Guy D, I can imagine other teams would love to have him as well."
"I am not too sure why Guy C isnt playing today, he is a very good player and probably a good addition to any team."


Injured Players/Red Cards
Checking which players are injured, how many and whether they were important for the team by checking how many games they played from the beginning or how much goals/assists they made. Examples:
"Team A sure isnt lucky these days, 3 players injured."
"Team A is missing Guy A today, They wont be glad to need to play without their top scorer."

Formation
Actually something that I'll check during the game. To see how offensive they play, or how much over the wings to make comments like this during the game:
"This game sure is fun to watch, both teams play very offensive."
"Team A seems to have decided to try to win this match over the wings."



So, yeah. Now you know why I said this part might take me a while.
 

Toma

Let me show you through these halls, my friend, where treasures of indie gaming await...
Took me a while but I implemented the automatic save routines for team information and matchreport information. Now I can add to it without ever needing to bother about saving new information.

Team information will include:
Trainer name
Stadion name
Stadion Capacity
Fan Trust level (later)
Nick name of the team (later)

Matchreport information will include:
Weather
name of the referee
list of people with cards
list of players who scored

If you got any idea what else might be included, just say it. I havent included any of this anyway, just took care of the save routine so that I can actually include it. I'll start now by filling these fields.
 

Toma

Let me show you through these halls, my friend, where treasures of indie gaming await...
sefskillz said:
cool thread. keep it up!

Thanks! I am not coming along as fast as I'd like to but steady progress is better than no progress, I guess.
 

Toma

Let me show you through these halls, my friend, where treasures of indie gaming await...
Sooo, I had a bit of fun with the randomized nicknames for the teams and stadiums. You will probably be able to rename your nicknames in some way within the game later but here a few examples of the teams you will play against, and their stadium names:

Flying Longhorns
Longhorn Park

Sluggish Woodswords
Woodsword Pit

Cozy Slugs
Slug Arena

Pink Kingsmen
Kingsmen Stadium

Dancing Clothmakers
Clothmaker Range

Sucking Goombas (oops, how did that happen? Random nickname-ization is fiendish. Anything might happen :-o )
Goomba Turf

Slow Muleriders
Mulerider Field

Undead Devils
Devil Park

Aggressive Cougars
Cougar Amphitheater

Smoochy Pirates
Pirate Park

I admit the stadium names aren't too inventive, but they'll do for now.
 

Toma

Let me show you through these halls, my friend, where treasures of indie gaming await...
Weather conditions plus chance of appearance are in!

* [0] sunny/normal 50%
* [1] Cloudy/normal (chance to rain within the game) 10%
* [2] bright 10%
* [3] rain (chance to get normal within the game) 10%
* [4] Heavy rain 2,5%
* [5] Fog 2,5%
* [6] Snow 2,5%
* [7] Scorching hot 2,5%

I'll use this mostly as flavor text within the games, but maybe I'll have some small modifiers that will effect the speed of the ball when being shot in snow, or the ability of the goalkeeper to react in Brightness or Fog. I also want to include some sort of weather forecast system. Still need to think about how to do that though. Buying your own meteorological institute as a football team just to have precise knowledge about the weather is kind of a funny idea.

Note to myself: Abilities need to be included. Here I could use a "Fog resistant" Goal keeper for example.
 

Toma

Let me show you through these halls, my friend, where treasures of indie gaming await...
FoxSpirit said:
I'm really curious about the routines you'll use to actually simulate a match :)

Me too actually. I got a whole lot of ideas and my goal is to get it as natural as possible. Since I dont visualize the full 2D/3D match, I can cheat a bit though. Every game minute will have a certain percentage chance of something happening (which will probably be affected by aggression and play speed level). If something happens, I'll calculate chances for something happening. Either a flavour text, a goal scene, a foul whatever I'll include. Obviously havent done them yet.

A goal scene for a particular team could look like this:

---------------------------------------------------------------------------------

[A random midfielder will be chosen]


"Guy A snapped the ball, he..."

[check for whether he is supposed to play along the wings or center, and if he has a high stat in tactics, follow the tactical setting, if not, randomize]


"...searched for Guy D on the wings, made a..."

[Check for high pass or low pass setting, if high tactics stat, do what tactical setting told you, if not, randomize]

"...low pass to him. Guy D runs along the field to cross the ball into the penalty box where Guy E is already waiting."

[Check defense value of the opponents, if yes, defender is in the way]

"But Opponent A is standing in the way! Guy D tries to dribble around him..."

[Check for defense of Opponent A and Dribbling Stat of Guy D, if Guy D wins..]

", and succeeds with a ball through Opponent A's legs! He crosses the ball to Guy E waiting..."

[randomize position plus way of shooting]

"...at the penalty spot, ready to make a header."

[Check defense of opponent plus jumping capabilities of Guy E and opponents defenders]

"Guy E and Opponent D both jump to the ball, and Opponent D wins!"

[Always chance of random stuff happening, especially fouls, which are randomized according to the aggression level]

", but Guy E got pushed from behind and fell on his back!"

[penalty check - aggression, referee "Short sightedness"..]

"Referee says the game goes on. No penalty kick."

[Random flavor text]

"That sure was an exciting scene."

------------------------------------------------------------------

But I am still weeks (or months even) away from that. Before I can do anything about the simulation I need to have all data I need. I just noticed today that I need Referee values as well, which might a bit "short sighted", or neglecting more fouls than others. It will be hard to implement such far reaching factors after I've done the whole system, which is why I am trying to add everything I can think of beforehand.

Edit: And all of these checks probably will have a possibilty of opponents intervening or fouls happening. But these are balancing concerns, right now I still got some preparations to do as mentioned above.
 

Toma

Let me show you through these halls, my friend, where treasures of indie gaming await...
Part 12: How to structure the Match report segments

Yeah, I am indeed finally about to tackle the match reports. I am still not simulating anything, even though that should be one of the next parts. What I am going to write about now is how to actually write each match report entry.

If you consider reading at least 38 match reports for your team alone in a league with 20 teams, you notice really fast that you need to have quite a bit of variety to keep these match reports interesting or surprising. One way of ensuring that is to have many different random events possibly taking place so that even after your first 38 matches you wont have seen every outcome and action the game has to offer. One easy example would be the penalty kicks.

There are 3 basic outcomes:

- He scores a goal.
- The goalkeeper clears the ball.
- He misses.

This means, there are 3 possible ways for this outcome, which is already a nice variety. However, since 3 isn't too terrible much the player might soon be tired of reading "He scores a goal!", after the 10th penalty kick. If the player already knows any given result by heart, he won't bother with the game for too long, so what to do? Easy! Include simple "Flavor" text.

Here a few "flavor" text examples for the different outcomes:

He scores a goal.
- "He shot it right under the bar!"
- "He pounded it into the the corner of the goal!"
- "The shot went straight by the goalkeeper who was only able to touch the ball lightly."

The goalkeeper clears the ball.
- "The goalkeeper catches the ball!"
- "The goalkeeper managed to direct the ball over the goal!"
- "The ball went directly to the goalkeeper who was easily able to catch it."

He misses.
- "He hit the crossbar! What a chance!"
- "Oh no, he hit it way above the goal."
- "He slipped and barely shot the ball, what a wasted chance."

Out of 3 possible outcomes you get 9 different texts that make the text feel different, even though it did the same calculations. This is very important to catch the imagination of the player. Of course some of those might be even calculated as well, as for example with an accuracy stat to measure whether the players shooting will hit the post, straight in, or from the post into the goal. I'll probably even do that, but this was just for the sake of showing what I am talking about.

Synonym System:

And nooow, we come to the most interesting part. We already got quite a few possible flavor texts, but they are still a bit static. As soon as you read a certain flavor text the 3rd time, it will get old as well, so what can you do to counter that? My solution is a Synonym System. What I did was creating small databases inside my program which will get triggered by the function Syn("word"). To use it, of course I actually need to program a list with synonyms for the chose word. So what Syn("word") does, is the following:

- It will check my mini database whether I have an entry for that specific word, for example "teams".
Code:
            if (c == "teams")
            {
                word.Add("teams");
                word.Add("sides");
                word.Add("squads");
                word.Add("clubs");
            }
... and then will randomly select one of those words. On top of that, if I ever need it, I programmed it in a way that will automatically give me the random corresponding word with the same capitalization, which means Syn("teams") might give me "sides", while Syn("Teams"), could give me "Sides". That way I dont need to bother about 2 making databases for different capitalized input. It automatically capitalizes the words how I want them. This leads to a whole lot of variety in the wording of the reports, making it way less static. Look at the following example for the sentence "The game is about to start":

Code:
" The " + [U][I][B]Syn("match")[/B][/I][/U] + " is about to start."
" The " + [B][I][U]Syn("match")[/U][/I][/B] + " will start " + [B][I][U]Syn("soon")[/U][/I][/B] + "."
" The " + [B][I][U]Syn("referee")[/U][/I][/B] + " "+[B][I][U]Syn("intents")[/U][/I][/B]+" to start the " + [B][I][U]Syn("match")[/U][/I][/B] + " " + [B][I][U]Syn("soon")[/U][/I][/B] + "."
" "+[B][I][U]Syn("Both")[/U][/I][/B]+" " + [B][I][U]Syn("teams")[/U][/I][/B] + " "+[B][I][U]Syn("cannot wait")[/U][/I][/B]+" to start playing."
" The kickoff will be " + [B][I][U]Syn("soon")[/U][/I][/B] + "."

I included 5 different sentences, which all have different possibilities for the exact wording. This will hopefully minimize the Deja-Vu's the player of my game will have during his playtime if I can keep this structure up. In this example it means there are already 165 different varieties of this one "The game is about to start"-sentence , 120 different possibilities in the third sentence alone. Of course I know that simply exchanging a few words doesnt make the text interesting on itself, but its a good way to start having a less static report, which hopefully doesnt feel like the last one the player has read. Couple this with a pool of sentences which might not appear at all and there should be quite a variety of things to happen and read over the course of a league season.

Colorcoding the Team actions:


One other thing I am really glad I was able to implement is an easy way for me to color the teams and players. If you read a match report, you immediately want to know to which team the player actually belongs to and for this I wouldnt want to edit the RTF (rich text format) code every time I include something that needs to be colored, so I wrote a short check to search for everything in <> and [] brackets, color it green or red, and then delete the brackets afterwards. The sentence "Team A and Team B play today", would look like "<Team A> and [Team B] play today." within my program and then colored accordingly.

And now after the wall of text, 3 random intro paragraphs, currently created in the game:

Osmfv.png
 

Toma

Let me show you through these halls, my friend, where treasures of indie gaming await...
Its crazy. Building a somewhat integrated language system that isnt doing everything 100% the same everything takes ages. Took me about 2 hours to integrate a small note about the weather inside the the greeting Paragraph, so that in 1 out of 5 cases it will say:

"Welcome on this rainy day."

..instead of just "Welcome!". But there are many varieties to that, and if a special weather condition is taking place (Snow (for now), heavy rain, scorching heat), it will get their own paragraph describing it in more detail. Each only has a 2,5% chance to appear anyway.

God, I can see me losing myself in trying to create complex sentences with different randomized meaning items. Its much fun, though. I should have wrote a term paper about this stuff in one of my linguistics courses.
 

Toma

Let me show you through these halls, my friend, where treasures of indie gaming await...
Killed a few instant quit errors, and continued working on the weather stuff. I had a programming logic problem that was hindering my progress for a few days. Was able to kick that out today after rewriting a bit of code :) Back on track.

Still currently on the weather. I have 2 different parts of weather depending on which kind of information I want to give (obviously I cant make comments about the current goals if the game hasnt even started yet):

1. Weather in the pre match report ("Today's sunny weather is great for a match")
2. Weather as flavor text within the match report ("Team A cant blame their goals on the weather. Still looks beautiful out there.")

Still, lots of stuff to think about and I currently only have the first weather condition (of 8) for the first part. Meaning I need this:

Code:
GamestartWeather.Add("The weather is "+Syn("sunny")+".");
GamestartWeather.Add("The weather is "+Syn("perfect")+" for a " + Syn("match") + ".");
GamestartWeather.Add(Syn("Today's")+" "+Syn("sunny")+" weather is "+Syn("perfect"));
GamestartWeather.Add("The "+Syn("clear")+" sky looks "+Syn("beautiful")+" today.");
GamestartWeather1.Add(Syn("This")+ " "+Syn("seems")+" to be a "+Syn("great")+ " "+Syn("foundation for a ")+Syn("match"));
GamestartWeather1.Add(Syn("Everyone")+ " "+Syn("cannot wait")+" to start the " +Syn("match")+".");

another 7 times for different weather conditions and then 8 similar sentences as the aforementioned random flavor. What kills the most time right now is coming up with appropriate sentences for every condition.
Sorry! It will take still quite a while until i get to the actual match report, I guess.
 

Toma

Let me show you through these halls, my friend, where treasures of indie gaming await...
Added a few of those weather conditions, stadium capacity and fan trust, upon which the current fans in the stadium are calculated. Also something minor, which I thought is fun: If a fan is fainting due to the hotness he will be correctly subtracted from the current number of people in the stadium (He is out of the stadium, on his way to the hospital obviously).
 

Toma

Let me show you through these halls, my friend, where treasures of indie gaming await...
I sort of "meta"-programmed a program for programming today. I kept adding to the current prematch conditions, and for that also added synonyms to my "database", which keeps growing and growing. Looking it up in the code, whether I already have a certain word as "synonym" was kind of troubling, which is why I needed something to keep track of that. Possibilty A was creating a txt file, which I'd need to update with new stuff, possibility B was finding a way to read out what I already programmed, delete the fat and keep the important information.

...thankfully I got possibility B working! (which means, I can continue programming, and "Syncheck" will update itself :) )
cakSB.jpg
 

Toma

Let me show you through these halls, my friend, where treasures of indie gaming await...
Kalnos said:
Are you using an actual database Toma (SQL) or are you pulling from text files?

This is directly from the *.cs file of my program =/
I still havent looked at SQL in depth, but I'd need to read out the data of the *.cs file anyway because its changing while I program when I add new entries or synonyms.
 
Top Bottom