Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3368: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:472)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3370: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:472)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3371: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:472)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3372: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:472)
OrbWorks Community Forum • View topic - Smart opponent...

Smart opponent...

Discuss PocketC for Palm OS (including Desktop Edition)

Postby Todd Z on Tue Jan 28, 2003 1:06 am

In my racing game I obviously want to have opponents... I have no idea how to do this... The only thought I have is setting a predetermined track for the car, but then when the player crashes into the car, and the car doesn't move off its path, its pretty unrealistic. Anyone have any ideas? Thanx.
Todd Z
 
Posts: 186
Joined: Sun May 26, 2002 12:51 pm

Postby soinsg on Tue Jan 28, 2003 5:43 am

You could make damaged cars restart from the last checkpoint, but then it would be more of an arcade game the forumla 1.
Maybe use hidden checkpoints as path nodes, so if a computer car got bashed off its normal track it would still beeline to the next checkpoint (you have to be careful when making the maps).
Maybe an animation of a car spinning, make the crashed into car spin off the track in a random direction (obviously not towards the crasher).
soinsg
 
Posts: 198
Joined: Thu May 17, 2001 4:26 pm

Postby awschwab on Tue Jan 28, 2003 2:06 pm

First you need some check whether they intersect. I think that's been discussed on this forum. Next, you want to know where they hit, and which way to bounce. One way to do that is to take the position coordinates for each car, and subtract one from the other to get a vector from one car to the other (x2 - x1, y2 - y1). You can scale this somehow (multiply by a constant, or whatever...) and add it to the position and/or velocity vector for one car, and subtract it from the other. This will make the cars recoil in opposite directions away from the point of impact.

The computer controlled car after this point needs to have a path to follow. It's presumably following a track at some speed. The easiest way to define the track is to have a set of points it heads toward in sequence. Maybe if it strays from the desired path because of a collision, it could simply figure out the new direction toward the next track point, and go that way. Ideally, you want the speed to be constant, so that if it's jostled away from where it wants to go, it will take longer to get there.
awschwab
 
Posts: 270
Joined: Tue Feb 06, 2001 2:33 pm
Location: USA

Postby fletcher_the_dog on Tue Jan 28, 2003 4:17 pm

When implementing how your opponent drives,you can set up your AI to think how you would think. How this would work depends on your implementation of course. I would highly suggest that your track and car be implemented in some kind of object/data structure. This makes it easier to wrap your head around how to code the interaction between things. A simple opponent steering function might look something like this:

AIsteering(pointer Car,pointer Track){
int Turn;
//A function to see which way the track ahead turns
//returns the offset left or right to the center of the track
//a predetermined distance in front of you
Turn=LookAhead(Car,Track);
if(Turn==0) return 1; //Don't need to turn
else if(0<Turn) SteerToRight(Car);
else SteerToLeft(Car);
}
fletcher_the_dog
 
Posts: 30
Joined: Wed Dec 04, 2002 8:25 pm

Re: Smart opponent...

Postby antix on Mon Dec 17, 2007 6:51 pm

You could make the opponents car's move towards a point along the path. Then when you run into them, it shoves them away from the point they are following. Hope that made sense.
Image
antix
 
Posts: 17
Joined: Tue Nov 08, 2005 9:37 pm
Location: USA


Return to PocketC for Palm OS

Who is online

Users browsing this forum: No registered users and 3 guests

cron