Creating a Simulation Engine

C++, C#, Java, PHP, ect...
Post Reply
Devereaux
Posts: 24
Joined: Wed Nov 28, 2012 3:50 am

Creating a Simulation Engine

Post by Devereaux »

Hey everyone, I'm hard at work developing the core of my game and being someone that has never messed with in depth algorithms for game development I was wonder if I could get some help/tips/pointers on how to approach this aspect in my game. First off let me explain by saying my game is a wrestling simulation similar to THEWRESTLINGGAME. A user will create a wrestler, wrestle matches, train, and equip more advanced moves. Now the meat and potatoes will be the simulation engine which I was to construct to be as fun as possible to read match results.

Now there will be a ton of variables for each character. My first question is should I use all of these variables combined to come up with an overall number to determine skill then calculate it with the strength of the characters moveset (which will also be averaged out?)? Is there a different approach you would take?

Second is providing the text for the match results. I am completely clueless as to how to do this. Should I created a table with a bunch of action texts along with reaction texts and then just randomize them in certain situations or just pull the moves from the table and just within the results page itself create a buttload of if/else with a randomizer? Or if I'm completely off base feel free again to share any ideas.

Lastly, I included a few examples of simulation engines that are currently working in a few games just for reference on how I should approach the engine itself.

Example #1:

Code: Select all

Ladies and gentlemen. This fight is 3 rounds, in the heavyweight division.
Introducing the fighter to my left, fighting out of the red corner.
With a record of 0 wins, 0 losses and 0 draws, fighting out of London, Pavel Svoboda!
And introducing the fighter to my right, fighting out of the blue corner.
With a record of 0 wins, 0 losses and 0 draws, fighting out of London, Steve McQueen!
The judges for this bout are Daniel Bishop, Andrew Berry and James Ackerman.


The bell rings for round one and we are underway! 
Svoboda pulls out of a head kick attempt. 
Svoboda shoots for a takedown but McQueen saw that one coming a mile off and avoided it easily. 
The crowd cheers as Svoboda lands an impressive looking overhand right. McQueen doesn't seem phased though.

It looks like Steve McQueen has been cut. 
Svoboda fails with a takedown attempt. 
McQueen tries to clinch up. 
No luck for McQueen with that takedown attempt. 
Svoboda misses with a kick to the body. 
Svoboda throws a right and a left that both miss. 
McQueen fails to land the takedown.
 
McQueen gets a clinch.	
McQueen has had enough of the clinch but Svoboda keeps him there for the moment.

That's one minute gone in the round. 
Svoboda tries to take the fight to the ground by pulling guard but can't manage it. 
That's three failed takedown attempts in the round for Pavel Svoboda. That's going to take a lot out of him. 
McQueen slowing the pace effectively. 
McQueen gets double underhooks to prevent a takedown attempt from Svoboda. 
A right hook to the body lands for McQueen. 
McQueen wants to get back to striking at distance but Svoboda won't allow it. 
McQueen is trying to work for a single leg takedown but Svoboda pulls him back up using the underhooks. 
 
Svoboda gets a nice trip takedown into half guard. 
Svoboda seems very keen to just sit and control from half guard but McQueen does not like that idea so much and is remaining active off his back. 
The fighters are pressed up against the cage, both looking to find a bit of space to work. 
Svoboda perhaps working for something from half guard, or maybe not. It looks like he's just sitting there. 
McQueen trying to control from the bottom. 
 
Svoboda decides to stand up.	

That's two minutes gone in the round. 
McQueen with a poor takedown	
 
and Svoboda counters with a nice double leg into guard.	
Wooooo! Give it up for these two warriors! They are putting on a show! 
Svoboda tries to free his leg and advance position but McQueen is retaining full guard.	
McQueen looking for a sweep. Not yet McQueen, not yet.	
Svoboda looking to pass the guard.	
Svoboda is working hard here to advance position.
Svoboda is breathing heavily. 
McQueen looking to control. 
McQueen wants to stand and escape but Svoboda is having none of it.	
We've had a lack of effective grappling in the last minute or so, which could well see a referee standup. 
McQueen lands a beautiful switch and he's in full mount! That could spell trouble for Svoboda!	
McQueen can't control as he wanted to and Svoboda manages to get the fight back to his half guard.	

That's three minutes gone in the round. 
Svoboda is looking to improve his position. 
Svoboda wants to control but McQueen is keeping busy. 
 
McQueen is looking for a kimura but Svoboda is holding onto that half guard position, so it's hard for McQueen to get the leverage. 
Svoboda manages to get to full guard. 
Svoboda seems keen to control rather than go for a submission, at least for now. 

That's four minutes gone in the round. 
McQueen's corner is telling him to maintain position. 
Svoboda working a defensive guard here. 
Svoboda keeping moving, preventing McQueen from controlling successfully.	
 
Svoboda is throwing his legs up, looking for submissions. McQueen is aware though and is defending well.
As the round comes to an end the crowd are showing their appreciation for a great round of action. 
McQueen would like to get this fight back to the feet but can't get free from the closed guard.	
And that’s the end of the round – the fighters go back to their corners.

Pavel Svoboda dominated that round.
The cut man is working on Steve McQueen's cut.
That's the end of the round. The referee orders the cornermen out of the cage so we can get back down to business.

 
Svoboda tries to clinch but is not successful on this occasion.	
Svoboda takes a nasty kick to the mid section... That should keep him thinking. Does he try and block and risk a head kick landing? 
A good leg kick by McQueen.	
A head kick by Svoboda misses	
 
and McQueen holds on and brings the fighters into a clinch.	
McQueen is looking to take this one to the mat. 
Svoboda working hard to break the clinch. 
McQueen keeps the fight in the clinch, despite Svoboda's efforts to push away. 
McQueen is looking for a takedown up against the cage. Svoboda gets underhooks though and prevents the takedown attempt. 
Svoboda is trying to pull guard but being pressed up against the cage enables McQueen to keep the fight standing.
 
McQueen breaks the clinch and we're back to striking at distance. 
 
McQueen moves into the clinch successfully. 

That's one minute gone in the round. 
McQueen tries to score a body lock takedown but Svoboda shows good agility there to stay on his feet.
Pavel Svoboda has stuffed three takedown attempts in the round now. That's going to take a lot out of Steve McQueen. 
Svoboda wants to take the fight to the mat but McQueen manages to get underhooks and keep the fight in the clinch. 
Svoboda can't get the takedown. 
Both fighters are absolutely exhausted here.
 
McQueen jumps guard. 
The ref warns both fighters not to hold the cage as they work up against the meshing. 
McQueen is striking off his back. Svoboda thinks nothing of it though and passes easily into half guard.	
McQueen tries to roll over but Svoboda keeps him under control. 
Svoboda wants to lay and pray for a moment but McQueen keeps working.	

That's two minutes gone in the round. 
McQueen trying to control but Svoboda postures up. 
McQueen preventing any damage for now, controlling his opponent's head.	
 
McQueen looking to work for a kimura from the bottom.
 
Svoboda is trying for a guillotine from the top but the pressure isn't in the right place so McQueen is just riding it out for now. Svoboda eventually gives up the hold.	

That's three minutes gone in the round. 
Svoboda tries to stand but can't do so whilst McQueen controls his leg.	
The referee calls for the fighters to work. 

Pavel Svoboda has forced the referee to step in and bring the fight back to the feet. 
A telegraphed takedown attempt from Svoboda is defended easily by McQueen.

That's four minutes gone in the round. 
McQueen shoots in for a takedown - he's clinched up with Svoboda but Svoboda pushes him off and we're back to square one. 
McQueen is trying hard to land a takedown here. Svoboda sprawls well and keeps this one on the feet. 
McQueen ducks right into an uppercut from Svoboda. 
McQueen shoots in looking for a takedown. Svoboda tries to sprawl out of it but McQueen keeps driving through. The fighters are pinned against the cage. Svoboda manages to get underhooks and after a bit of a struggle, circles away and we're back to standing. 
Svoboda shoots in for a takedown. "Ole!" shouts McQueen as he jumps to the side. 
The crowd applaud the fighters efforts here as the round comes to an end.
 
Svoboda shoots in for a takedown and gets it.
And that’s the end of the round – the fighters go back to their corners.

That was a close second round but I would say that Pavel Svoboda will probably get the nod.
The cut man is working on Steve McQueen's cut.
The minute break is over - no more time for sponges and pep talks - back to the action! And we move into the final round!

 
Svoboda shoots in for a takedown but doesn't get it. 
McQueen throws a sloppy head kick and Svoboda moves out of range easily.	
Svoboda fails with a rather predictable takedown attempt. 
McQueen scores with a head kick. Svoboda tried to block it but didn't get his arm up in time.

It looks like Pavel Svoboda has been cut. 
McQueen tries to clinch up. 
McQueen takes a body punch that cleary hurt but he's trying not to show any weakness.
 
McQueen moves into range and clinches up with Svoboda. 
Svoboda tries for a takedown. No joy. 
That's three failed takedown attempts in the round for Pavel Svoboda. That's going to take a lot out of him.
Both fighters are breathing heavily. 
McQueen jumps guard but his hands slip and he falls flat on his back. Well, he's made himself look a right mug there, as Svoboda walks away with a smile on his face. McQueen gets slowly back to his feet and shakes his head. 

That's one minute gone in the round. 
Svoboda slaps away a takedown attempt from McQueen, before circling back to the center of the mat. 
McQueen tries to clinch but Svoboda moves away	
and Svoboda counters with a one-two to the body.	
Svoboda tries to close the distance and clinch but McQueen swats him to one side with an open hand palm strike and circles away. 
Svoboda with a body punch. A glancing blow. 
 
Svoboda looking to score a takedown here. McQueen is defending well but Svoboda drives through and ends up in McQueen's guard. 
Svoboda trying to control but McQueen is working from the bottom.	

That's two minutes gone in the round. 
Svoboda wants to pass the guard but McQueen is keeping the position.

We're going to have a standup here because Pavel Svoboda wasn't active enough for the referee's liking. 
Svoboda shoots in for a takedown but McQueen shows good takedown defense.	
The crowd cheering loudly, showing their appreciation for the quality fight we're seeing here. 
McQueen misses with a series of wild punches. 
McQueen throws a head kick that misses.	
Svoboda displays good takedown defense there as he swats away a double leg from McQueen. 
Svoboda misses with a takedown attempt. He shot from a bit too far out. 
McQueen shoots in for a takedown but doesn't get it.

That's three minutes gone in the round. 
Svoboda shoots for a double leg takedown but McQueen sprawls well. He's pushed Svoboda's face into the mat and manages to get back to his feet relatively easily. 
McQueen shoots in for a takedown but Svoboda shows good takedown defense there and keeps this one on the feet. 
McQueen tests Svoboda's chin there with a solid looking shot. 
Svoboda misses with an attempted mid kick. 
Svoboda is looking to clinch but McQueen is avoiding it. 
McQueen fails with a rather predictable takedown attempt.
 
McQueen gets caught napping as Svoboda dives in and scores a takedown. McQueen manages to retain guard.

That's four minutes gone in the round. 
McQueen working the defensive guard well to avoid strikes from Svoboda.	
Pavel Svoboda overall seems to be getting the better of the ground position in the fight so far. 
Svoboda is fighting to break McQueen's control of his arms but McQueen is doing a good job of controlling the position at the moment. 
McQueen looking to sweep here. No luck so far.	
McQueen is trying to control the position but Svoboda postures up.	
 
Svoboda drops back looking for a leg! McQueen is in trouble here! The fighters roll with the hold and McQueen manages to kick Svoboda off! Svoboda jumps back into McQueen's guard.	
Svoboda wants to get up but he can't break McQueen's closed guard. He needs to be careful trying to break the legs open, as he's open to submissions here. 

And that's the end of the fight!
Pavel Svoboda showed his dominance in that final round.
Well I reckon that's a shut out for Svoboda, winning every round. Will the judges agree? They are the ones who matter, even if they are often depressingly incompetent. Over to the ring announcer for the scorecards. 

Ladies and gentlemen, after 3 rounds of action, we go to the scorecards for a decision.
Judge Daniel Bishop scores the fight 30:27
Judge Andrew Berry scores the fight 30:27
Judge James Ackerman scores the fight 29:28
Example #2:

Code: Select all

Ring Announcer: "The following contest is scheduled for One Fall!"

Ring Announcer: "Introducing first, Mark Devereaux"!
Mark Devereaux makes his way to the ring

Ring Announcer: "and his opponent, Thantanos"!
Thantanos makes his way to the ring

The two wrestlers stare proudly at each other
and then engage in a exciting test of strength, trying to overcome their opponent
after a few, seemingly endless, seconds and an enormous effort Thantanos prevails
Thantanos points to Mark Devereaux with decision
and hits his face with an light Ear Slap showing no respect
Thantanos prepares to hit the rival
Mark Devereaux moves and dodges a Forearm Smash, taking the initiative back
Mark Devereaux grasps Thantanos
and lifts him up, slamming him down to the mat performing a light Body Slam
Mark Devereaux gets besides the laying opponent
Thantanos blocks the Knee Stomp easely
Thantanos gets close to his grounded opponent
and hits him executing a light Knee Stomp
Thantanos grabs Mark Devereaux's hair
Thantanos grabs one of his opponent's arms and swings him into the ropes
Thantanos takes a run-up on the ropes, runs towards his opponent
stretching his arm hitting his back with a light Clothesline to Back
Thantanos pulls Mark Devereaux still groggy, by his hair
Thantanos puts his opponent on his shoulders
Mark Devereaux climbs down his rival's shoulders dodging the Samoan Drop regaining the initiative
Mark Devereaux grabs Thantanos's hair
lunges himself on the ropes
Mark Devereaux runs toward Thantanos and jumps
Thantanos prevents from being thrown with a Running Arm Drag
Thantanos puts his opponent on his shoulders
and throws himself backward, trampling him with light Samoan Drop
Thantanos grabs Mark Devereaux's hair
Thantanos grabs one Mark Devereaux's arms and spins, swinging him into the ropes, then lunges himself as well
Thantanos hooks Mark Devereaux from behind
Mark Devereaux suddenly dodges the Backslide Pin, and starts to counterattack
Mark Devereaux grabs Thantanos's hair
Mark Devereaux grabs one Thantanos's arms and spins, swinging him into the ropes, then lunges himself as well
Mark Devereaux grabs Thantanos from behind
and attempts a pinfall with a light Backslide Pin
Referee starts counting...
Referee: ....Oneeeeeeeeeeeeeeeee....
Referee: ....Twooooooooooooooooo....
Thantanos gets up and resolutely fights back
Thantanos stares at Mark Devereaux in front of him
and hits his face with an light Ear Slap showing no respect
Thantanos loads his arm chop style and
Mark Devereaux moves and dodges a Forearm Smash, taking the initiative back
Mark Devereaux grasps Thantanos
and slams him down to the mat performing a light Body Slam
Mark Devereaux grabs Thantanos's hair
Mark Devereaux grabs one Thantanos's arms and spins, swinging him into the ropes, then lunges himself as well
Mark Devereaux hooks Thantanos from behind
hooking him by the arms sliding him across his back while falling performing a light Backslide Pin
Referee starts counting...
Referee: ....Oneeeeeeeeeeeeeeeee....
Referee: ....Twooooooooooooooooo....
Thantanos gets up and resolutely fights back
Thantanos stares at Mark Devereaux
Mark Devereaux avoids an Ear Slap and takes the initiative
Mark Devereaux loads an arm towards himself
Thantanos blocks the rival's arm preventing the execution of a Forearm Smash
Thantanos loads his opponent on his shoulders
and throws himself backward, trampling him with violent Samoan Drop
Thantanos gets close to his grounded opponent
and strikes his forehead with a light Knee Stomp
Thantanos approaches his laying opponent
Mark Devereaux avoids the Knee Stomp and counterattacks
Mark Devereaux approaches his laying opponent
Thantanos blocks the Knee Stomp easely
Thantanos gets besides the laying opponent
and strikes his forehead with a strong Knee Stomp
Thantanos grabs Mark Devereaux's hair
Thantanos grabs one Mark Devereaux's arms and spins, swinging him into the ropes, then lunges himself as well
Thantanos runs toward Mark Devereaux
and spins hitting him with a light Rolling Elbow Smash
Thantanos pulls Mark Devereaux still groggy, by his hair
Thantanos lifts his opponent on his shoulders
and throws himself backward, trampling him with violent Samoan Drop
Thantanos grabs Mark Devereaux's hair
Thantanos grabs one of his opponent's arms and swings him into the ropes
Thantanos takes a run-up on the ropes, runs towards his opponent
and he hits his back with his arm taut performing a strong Clothesline to Back
Thantanos grabs Mark Devereaux's hair
Thantanos grabs one of his opponent's arms and swings him into the ropes
Thantanos bounces on the ropes running towards his opponent
Mark Devereaux gets down and avoids the Clothesline to Back. gaining the initiative
Mark Devereaux gets close to his grounded opponent
to hit him with a light Knee Stomp
Mark Devereaux pulls Thantanos still groggy, by his hair
Mark Devereaux loads his opponent on his shoulders
Thantanos firmly blocks the execution of the Samoan Drop
Thantanos grabs his opponent's nape from behind with his right hand
and kneels down, flipping him over his shoulder down to the mat, back first connecting with a light Snapmare
Thantanos grabs Mark Devereaux's hair
Thantanos grabs one Mark Devereaux's arms and spins, swinging him into the ropes, then lunges himself as well
Thantanos grabs Mark Devereaux from behind
hooking him by the arms sliding him across his back while falling performing a light Backslide Pin
Referee starts counting...
Referee: ....Oneeeeeeeeeeeeeeeee....
Referee: ....Twooooooooooooooooo....
Referee: ....Threeeeeeeeeeeeeeee....
THANTANOS WINS THE MATCH AND DEFEATS MARK DEVEREAUX!!!
Any guidance is well appreciated. Thanks guys!
Unnamed Wrestling PBBG in Production
User avatar
Xaos
Posts: 940
Joined: Wed Jan 11, 2012 4:01 am

Re: Creating a Simulation Engine

Post by Xaos »

I would make attributes (punch, punch defense, kick, kick defense, etc.) and have those directly in the fight, not overalls. And for the P-B-P, you'd want to have it spit out depending on what happens. For example, take a look at this.

Code: Select all

<?php

$p1attack = $_POST['p1attack'];
$p2defense= $_POST['p2defense'];
$p2elusiveness=$_POST['p2elusiveness'];
$p1dexterity=$_POST['p1dexterity'];
$p1health=$_POST['p1health'];
$p1speed=$_POST['p1speed'];
$p2speed=$_POST['p2speed'];
$p2attack = $_POST['p2attack'];
$p1defense = $_POST['p1defense'];
$p1elusiveness = $_POST['p1elusiveness'];
$p2dexterity = $_POST['p2dexterity'];
$p2health=$_POST['p2health'];
$p1name=$_POST['name1'];
$p2name=$_POST['name2'];



function fight($attack,$defense,$elusiveness,$dexterity,$health){
    $hitchance = rand(1,$dexterity)-rand(1,$elusiveness);
    if($hitchance >= rand(1,$elusiveness)){
        echo "Hit! <br />";
        $damage = ($attack * rand(1,$attack))-($defense * rand(1,$defense));
        if($damage >= 0){
            $health = $health - $damage;
            echo "Damage dealt = $damage <br />"   ;
            echo "Health = $health <br />"   ;
        }else{
            echo "Attack paried!<br />"   ;
        }
    }else{
        echo "Miss!<br />";
    }

    return $health;
}

while($p1health > 0 && $p2health > 0){
  $p1speedchance = (($p1speed + $p1elusiveness)/2) * rand(1,100);
  $p2speedchance = (($p2speed + $p2elusiveness)/2) * rand(1,100);
    if($p1speedchance > $p2speedchance){
    echo "$p1name goes for the attack! <br />";
    $p2health = fight($p1attack,$p2defense,$p2elusiveness,$p1dexterity,$p2health);
        if($p2health <= 0){
        echo "$p2name has perished. $p1name has claimed victory!<br />";
        }
    }else{
    echo "$p2name goes for the attack! <br />";
    $p1health = fight($p2attack,$p1defense,$p1elusiveness,$p2dexterity,$p1health);
        if($p1health <= 0){
            echo "$p1name has perished. $p2name has claimed victory!<br />";
        }
    }
}
?>
Post Reply

Return to “Coding”