Advertisement

Arcade game opponent logic / AI

Started by May 09, 2017 12:56 PM
0 comments, last by Ivorne 7 years, 6 months ago

Hi there,

I'm a retro gamer and hobby-programmer. Currently I'm programming a simple Atari game. The programming language is plain C (Ansi-C / C89) . I'm using the CC65-crosscompiler package, but I don't think the platform/language is of big importance to my question.

I'm facing the challenge to program a real arcade game. But I have some difficulties to start on implementing the logic of my opponent "gopher". It's getting more and more complicated and I would like to ask here to get some introduction/best practice from you.

[attachment=35844:reference_320.png]

A little introduction to my game: It's a about a gopher (AI/opponent) who lives in the cave. It's digging in 6 pre-defined slots up to the surface where the the farmer (player) watches his carrots. The gopher wants to steal the carrots. The farmer has a shovel and can hit the gopher while it is on the surface. If the gopher got all carrots, the game is over. If the farmer catches the gopher he get points. The farmer also can close the slots by using his shovel.

So the game itself is pretty basic. But I don't know where to start and how I should construct / define the behavior and map that to actions like left, right, up, down.

Of course the Atari is not a particular AI/algorithm platform, so there must be some basic principles. I just wonder how it could be done using some simple C-control / switch statements.

thanks for any help,
Thomas

For example you can have a variable 'target' which denotes the slot which the ghpher currently wants to steal. This value will be randomized each 5 seconds (once per 300 frames on 60 fps). Then each frame when you want to move the gopher, if target slot is right from gopher, move 1 pixel to right, if target slot is left from gopher, then move 1 pixel to left, if the gopher is under the target, then move 1 pixel up. Time to re-randomize target and the gopher speed can be tuned so that the gopher sometimes unexpectedly changes target but is still able to reach some targets. You also want to somehow handle the possible situation, that the random generator selects empty slot.

This topic is closed to new replies.

Advertisement