# Simple AI?

• 12-23-2009, 02:18 AM
Atriamax
Simple AI?
I created a game like TRON, (ok, the same game just in java) but i have no idea how to program AI into it. Its just like the original tron, you just have to avoid running into the walls that are created behind each player. I just want to create a simple AI to play against.
I really dont know how to approach this. The only thing i can really think of is a huge load of if statements (lol) but i know that wont work.
any tips?
• 12-23-2009, 07:59 AM
tim
I've created a modern version of a game called Digger in Java. There's a Wikipedia article on it. It's also a maze game similar to TRON, assuming this is the subgame you want to implement.

For my game, I used a two dimensional array of cells, which you define according to the needs of the game. Then, I did my scene drawings based in this matrix. In addition, I had actors. Such actors, like the player, baddies or collectibles moved about my matrix by linear interpolation and responded to collisions according to the defined AI. Programming actor AI from here is simple. I had a huge switch for actor interactions and actions. Now, Java is OO, so you can do better, but the switch is simpler. Besides, if your not planning to rescale the game, then don't overkill. ;)

Good luck and ask if you think I can help. :D
• 12-23-2009, 10:44 AM
Atriamax
I just dont know how to approach it code wise, It has to be a combination of random movement, and reaction based movement. I could try a switch but i feel like with a game like this it will make the ai too perfect.
Ill try it, I was just searching for a better way.
• 12-23-2009, 01:10 PM
gcampton
You could add a increasing randomness to the switch the more random the easier the game obviously, with hard mode being virtually no randomness.

Just to compensate for the perfectness of the actor acting out the switch.
eg. easy mode it would take the right path every 10 moves, 11th move could be a random switch, which may also be the right move, but it may also be the wrong move. and for medium mode, just scale this to every 25 moves, and for hardmode over 50 or so.
• 12-23-2009, 11:35 PM
Atriamax
Yeah, ill try it out thanks for the info