Artificial Intelligence (AI) for Super Truckin’

With AI comes many complications. We not only wanted AI for racing, but we wanted it for all of our game types.  I would like to go over what we needed for the game type, what problems happened and how we battled it. If you’d like to see some code let me know! Want be in the beta? contact us!  https://twitter.com/in8bitgames

 -Soccer-

Need: Each AI follows the ball to knock it into the opposing goal.
First thing we needed to add was how to track a single way-point. This is pretty standard and allowing our trucks to follow a way-point was pretty straight forward.
Image

You want to hit a ball… you make the ball the way-point and your done. Right? Wrong! this will allow the AI to just smash into the ball with no clear direction. The soccer field will be like a 5 year old playing pool and smashing the ball off every wall in hopes to  make it in the pocket.

So we thought about adding direction.  Adding this was a little bit more complicated, we had to basically get the AI to get behind the ball and aim it towards the goal. Math cant do this? or can it! We need to know the goal and ball location, the direction in which to hit the ball towards the goal and some math magic to get the arch to go around the ball. Our first test results with this logic.

Image

Whew… we started playing with it… and wow… this made it a lot harder to play against. They would steal the ball away from you and try to knock it towards their goal. It is not perfect but it works pretty well.

The problem with this approach is it acts as if the target is stationary for that moment in time. By the time the next update happens the trajectory changes. This makes the AI not as accurate when the ball is moving quickly.

That is all it really took to get AI working for soccer. Can we make it better? Oh yes, there are many ways to improve it. We could look at the trajectory of the ball, and speed of the vehicle and account that in the algorithm to where it needs to hit the ball. Eventually we will add this but for now the AI is already pretty challenging. If you guys want it to be harder then we wont want to disappoint.

-Hay-

Need: Each player tries to go for the hay and knock it out of the arena
We now have single way-point navigation, all we need to really do is turn off ability for aiming it towards a soccer goal. Sweet! Done and done…  until we tried it….
Image

They became experts in finding the hay, and knocking it out before you ever have a chance to get to it as well.  They were impossible to play against and it wasnt fun.

So we added Object avoidance Which i will explain later. not only are they trying to always hit the hay, but they are actively trying to avoid it as well. This nifty trick made them just easy enough to be playable. They don’t score every time they get the hay just like a real player would.

-Racing-

Need: Each player follows the track.
So adding onto the single way-point system we already have. we needed to add more to be able to allow the AI to follow a track. Awesome, easy enough. Just make the way-point a list of way-points and when it gets close to the current way-point make it go to the next one.
Image

So now we have an AI set up for our racing level but this is when we saw problems we were not expecting.

The problem we had with this approach was we have several areas that a vehicle can get knocked into (such as the quad jump and hills they can fall off of) and how does the AI react when this happens? Right now they will keep trying to get to the next way-point and get stuck on a wall. So how we battled this was to implement zones. This allowed the AI to validate that this is the zone it should be in, and if not to react by either going to a new way-point or follow the track where it dropped like a normal player would.

Bad behavior:
Image
Good behavior with Zones:
Image

AWESOME! it looks like we have a way-point system and a zone system that the AI follows and if knocked out of either system it can figure its way back. We now have pretty amazing race AI.

-Object Avoidance-

I believe this needed its own section because we have now integrated this behavior in each of our AI’s.
  • In every Level (especially racing) the trucks would pile up  leaning into each other as they go to a way-point, ball or hay. This caused the trucks to crash and slow down and didn’t look fluid. I could easily pass them when they are in this state. 
  • Early tests on the Soccer level you would see the vehicles stuck against a wall because they were trying to go through the wall to get to the other side of the ball.
  • Testing the hay level they would pile up more than hitting the hay as well as clipping edges of jumps and causing them to lose control all the time.

The answer to these issues is to make the cars see. we basically gave them eyes so that they can listen to things around them and react. This changed our game. This made the AI react in ways that were more what a player would. It felt they were more human when obstacles popped up.

 Image

we added ray’s in front of the vehicles  that listen to touching objects such as cars, sides of jumps, and walls. Left ray is touched turn to the right, right ray is touched turn to the left.

We could add the barral mine to the things to avoid but this gif wouldn’t have been as awesome.

It has been a lot of trial and error. Testing constantly with and without people. We think we have solid AI for each level and each having completely different behaviors. Are we done with the AI? nope! We do plan to constantly improve and balance each level to make them as fun as possible.

Thank you guys for reading and check back often for more awesome posts! If you guys want more information about anything else we have done please let us know!

Advertisements

Super Truckin’ : Smartphone & Second Screen Gameplay

Today we are announcing the gameplay mechanics of our racing game Super Truckin’.

2Screen

Using your smart phone as the controller you can connect to your PC and race, smash, and score!

We are currently focused on a PC/Android release where you use your Android phone as the controller to the Super Truckin’ game running on your PC. Initial tests with Android tablets, iPads and the Ouya has shown that we can leverage all of these as second screens as well – so when we get closer to being done we hope to try and support those too.

Each of the three initial levels we have created allows up to eight different people to control eight separate trucks on the same screen at the same time, over the local Wi-Fi.

ControlLayout

Today the controller is where you select your truck color, find the game that is already started on the PC and then join it. We are hoping to add more to the controller in time with vehicle add-ons truck selection and similar, but at this early stage customization is just color. Once joining a Super Truckin’ game you turn your truck by turning your phone like a steering wheel (leveraging the accelerometer), gas by pressing the right hand side of the phone, and after picking up a power up you can press the left hand side of the screen to use it. Double tapping the gas will enable turbos and releasing the gas for a quick second turns the turbo’s off. Tapping the center of the screen will honk the truck horn and also display your name on screen in case you lost your truck after getting blown up or respawning after going out of bounds.

We are really excited about getting this out there and getting feedback from real gamers so we are taking requests to be one of the first 10 to try this game out. You must have an Android phone, and a PC and you must be willing to help give feedback on a regular basis to help make this the best game we can make it.

If you are interested please fill the form out below or tweet:

“I want to use my phone to start racing today w/ #SuperTruckin by @in8bitgames”.

We will put all the names in a hat (figuratively) and pull the 10 random gamers on Friday Dec. 20th. That means you can be playing just in time for Christmas!

Get your friends to contribute and retweet to increase your chances of being one of the first to experience Super Truckin’!

 

 

Fireballs

Electro Ball

3d_SuperTrucking