A bit of help with AI (Tron Clone)

Blitz3D Forums/Blitz3D Programming/A bit of help with AI (Tron Clone)

Nexinarus(Posted 2014) [#1]
Can anyone give me some pointers on the basics of AI?

I have made a Tron Clone style game and I need AI.

How would i go about it? I have looked in a lot of different forums on this and i can not seem to find anything. Or its documents i can not fully comprehend.

The game is practically complete for Single Computer Multi-Play, but if someone wants to play alone... I need AI.

I would post the code but it is heading for 10,000 lines of code.
I compiled it and it is only 1.79MB. Oh yeah, all graphics are built in.

Getting back to the real question.... Anyone who can help me understand the basics of AI for a Tron Clone style game would be greatly appreciated. Thank you for your time.


RemiD(Posted 2014) [#2]
If you are talking about the Tron with the motorbike, in an arena or on a track, the idea is to have the bot avoid his trail and the trail of the player and the trails of the others bots.

To detect a collision between a motorbike and a trail you can use several colliders sphere for the hull of the motorbike and a collidable mesh for the trail (set each frame or each xms).

To detect a future collision and thus decide to change direction, you can use linepick from the front of the motorbike to forward and see if a trail is detected and how far it is.
With this you can decide to make the bot brake and change direction or not.

The difficult part would be to find a way to "trap" the player by making a bot go in front of him and then turn. If the game is on a track it will be easy to do this because the player will follow the track so his next position is known but if the game is in an arena, i don't know how you can do this. An easy way would be to choose a random target position and make the bot go here and when it has reached this position, suddenly change direction so that it is a bit unpredictable...

For the render you have already some examples of trails in the code archives and in the code examples with blitz3d.


_PJ_(Posted 2014) [#3]
"Trapping" the player may be available by some form of pathfinding, where any existing trails are given a huge value, and the target destination would be some form of interpolatede location in front of the player according to their speed, the AI's speed relative, and distance between the two ?


RemiD(Posted 2014) [#4]
Good idea PJ
But taking into account the current position of the bot, his current velocity, to calculate if he will be able to reach the area in front of the player can become complex if the game is in an arena.

An alternative would be to add the possibility to jump so a bot can jump above a trail if the area after the trail is "free" enough. Then make it turn suddenly from time to time and let the randomness do its thing.

Take a look at this tron racing game :
http://www.online3dgames.net/games/550/play-tron-legacy-light-cycle


H&K(Posted 2014) [#5]
@Remi,

Tron is a "grid" Game. Either the grid point you are moving to is a wall or a bike, or its empty.

You can program it so it appears that the transient places exist, but just store an array of empty / wall data, and avoid all that collision box / sphere nonsense.

@Nexinarus

10,000 lines of code is too many for tron, either you have bloated it beyond belief, or you have remmed the billy-oh out of it


Nexinarus(Posted 2014) [#6]
it is 10000 lines because of all the of not just the code but also the comments as well (i agree, this is probably what made it so large). I also created some options for the players. I may have done more work than needed to but the compiled result was less than 2MB as an EXE file. I made all the gfx a 4 color thing and they are built in.

I guess I should have mentioned that it is 2d not 3d. Sorry about that. Why 2d in Blitz3d? I was just curious to see if i could. I made it work for Multi-Play on 1 computer. And that works too. I played using 2 sets of controls for about 3 hours last weekend finding bugs. I even added collectables.

I used an array for the map to keep track of all the walls. And yes it is in an arena type thing. The point is to last longer than everyone else. There are menus, player setups, game setups etc... If i could. i would send a screenshot of it so everyone would know what it looks like.

@RemiD
An easy way would be to choose a random target position and make the bot go here and when it has reached this position, suddenly change direction so that it is a bit unpredictable...

I should give it a try. I could just add more to the ai to make it smarter later.

@_PJ_
"Trapping" the player may be available by some form of pathfinding, where any existing trails are given a huge value, and the target destination would be some form of interpolatede location in front of the player according to their speed, the AI's speed relative, and distance between the two ?

You do bring up a good point on that as well.

@RemiD
Good idea PJ
But taking into account the current position of the bot, his current velocity, to calculate if he will be able to reach the area in front of the player can become complex if the game is in an arena.

An alternative would be to add the possibility to jump so a bot can jump above a trail if the area after the trail is "free" enough. Then make it turn suddenly from time to time and let the randomness do its thing.
my characters can not jump but they can collect shields and shoot if they collect a weapon.

Everyone here has some great ideas. Thank you all. Again sorry that i did not mention it was 2D before. I just wanted to see if i could do it. If there are anymore ideas, let me know.


Blitzplotter(Posted 2014) [#7]
Whilst not AI centric, I did a little worm client / server stuff in Blitz3D a while ago, and whilst I confess that the client & server code is in the same LONG code listing at the mo, it still does the bizness:

http://www.blitzbasic.com/codearcs/codearcs.php?code=2789


Nexinarus(Posted 2015) [#8]
Well. I still do not know much about AI. I have been trying and for a tron game, i still do not get it. But i do have the options for up to 8 people on 1 pc. I still gotta code in the Joystick option though. Other than that it is done. Oh and the help files. I have played it multiple times with a few friends. We played it for about 3 hours. And it Loads and Runs pretty darn fast. On both my Fast PC and my "Slow as a turtle laptop."

Gotta do a help file, and somehow put it on the net.

for the help, i should probably explain everything inside. Menus, Goodies, controls, requirements. But what else? The reason why I ask is that i am not sure what else goes into one.

Even if it is only for 2+ players i find it really fun.