gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

C/C++ > questions - ai and "far" pointers

#17189 - ken2 - Wed Mar 03, 2004 6:13 am

I was recently working on taking an existing incomplete light cycles demo and putting in AI, and I noticed a pointer wih "unsigned long far *". I'm a little confused as to what "far" does exactly to affect the pointer, i wasn't able to find info on it anywhere. If anyone could clear it up for me, that would be great.

Also, I was wondering exactly how I could put in good AI for light cycles.
I was thinking I could have a table or structure of some sort of situations it might be in, along with some basic avoiding the walls, but some other functions to try and block off the player. However, I'm not too sure about AI, i've never really done anything too close to it before, so some help would be appreciated greatly.

thanks

#17196 - tom - Wed Mar 03, 2004 1:23 pm

was that demo for x86, and are you trying to port it to the gba ?
if so, don't worry about far pointers, they're x86 specific. just omit the far keyword.

#17209 - sajiimori - Wed Mar 03, 2004 9:14 pm

As far as AI, you'll definitely want to start simple. Initially, you could just have it look ahead slightly, and turn if it's about to crash, making sure that the direction it turns won't also cause a crash immediately. (Of course, it will eventually encounter a situation where neither direction can avoid a crash.)

Then you can add some behaviors for specific circumstances. When it is near the player, moving in the same direction and ahead of the player, you could have it try to cut the player off.

After that you can play against it a lot and try to find the mistakes it makes most often, and focus your attention there. Large-scale thinking is hard to do, and even humans aren't that good at deciding where to go next. A general heuristic would be "go where there's a lot of space", if the intention is to simply wait for the other player to screw up and die.

#17212 - Miked0801 - Wed Mar 03, 2004 10:35 pm

Far could have been typedef'd to mean an ARM long jump. Just guessing, but that's what far would mean to me on GBA.

#17215 - ken2 - Thu Mar 04, 2004 2:04 am

Yes, the demo was in fact for x86. =) It was in DOS mode 13h and pretty simple, so i figured i could port it to Mode3 or 4 on GBA and focus on adding collision and AI. And also, I'll take your advice about the AI, sajimori. Thanks