Java-Gaming.org    
Featured games (91)
games approved by the League of Dukes
Games in Showcase (581)
games submitted by our members
Games in WIP (500)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Car Driver AI  (Read 4064 times)
0 Members and 1 Guest are viewing this topic.
Offline rdcarvallo

Senior Member


Projects: 5
Exp: 15 years


2D Java games forever!


« Posted 2006-11-29 15:19:50 »

Hi,
  I have been programming a road simulator/game, and I'm having problmes
with the driver's AI.
  The game uses a tile map(with directed streets)

My algorithm has two parts:

Road Following:
-The driver knows the next 4 tiles the car will go. (tile 1 is the current tile where the car is)
-If there is a change in direction in the tiles 2 or 3, slows down the car
-For each step the dirver tries to mantain the car aligned with the road (tile direction).

Collision Avoidance:
-The driver look for cars near.
-If the car found is in front if the driver's car and in the next step the cars are nearer,  then slows down the car.

I still have problems on crossings, and the cars never stops completely. I want to include semaphores.

  Do some of you have some pointers to info on programming car driver's AI??

    Rafael.-


 
Offline Riven
« League of Dukes »

JGO Overlord


Medals: 606
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #1 - Posted 2006-11-29 15:28:46 »

If every tile has a vector (2d) describing the direction (and speed, if the vector isn't normalized) the AI should be moving there, you can make it steer smoothly along corners, and make the AI get back on track after it was pushed off the road, or turn the car around etc etc. On crossings, you just set the vectors to 0,0 so that the AI will simply continue.

You can use the vectors to avoid moving obstacles too, by influencing the vectors behind/next to the opponents' cars.

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Offline rdcarvallo

Senior Member


Projects: 5
Exp: 15 years


2D Java games forever!


« Reply #2 - Posted 2006-11-29 16:48:43 »

  Currently the tiles have flags for the exits, the driver selects one of
the exits(randomly) and uses ti to calculate the direction vector.

  There is no speed info on the tilemap.

  Using vectors for collision avoidance.. seems like using some kind
of repulsive potential field..
  How can I take this info and represent it as steering commands??
  The driver and the car are different entities, the car simulates the
physics and the driver interacts with the car using these 3 properties:
  *acceleration
  *brake
  *steering angle

    Rafael.-

EDIT: A screen from the editor.

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline ryanm

Senior Member


Projects: 1


Used to be bleb


« Reply #3 - Posted 2006-11-29 17:33:49 »

The behaviours on this page may be helpful.
Offline rdcarvallo

Senior Member


Projects: 5
Exp: 15 years


2D Java games forever!


« Reply #4 - Posted 2006-11-29 20:31:54 »

Steering Behaviors..  The problem with them is that I don't know how to represent the
steering force as commands from the driver to the car..

Here are some screenies..





Rafael.-
Offline moogie

JGO Knight


Medals: 11
Projects: 5
Exp: 10 years


Java games rock!


« Reply #5 - Posted 2006-11-30 00:59:47 »

Steering Behaviors..  The problem with them is that I don't know how to represent the
steering force as commands from the driver to the car..

Well, in my 2006 J4k entry (http://www.javaunlimited.net/results/view.php?id=104) I used steering behaviours to control the AI cars.

For the AI steering I calculated the angle between the cars' current direction vector and the 'desired' vector and based on this angle i commanded the car to rotate left or right.

Offline rdcarvallo

Senior Member


Projects: 5
Exp: 15 years


2D Java games forever!


« Reply #6 - Posted 2006-11-30 05:12:17 »

The model of the car simulates the physics.. the car cannot be rotated directly, only applying the
torque of the friction forces of the wheels

The next image shows all the forces applied to the car.
red:aceleration (applied in the center of the axis (this car has front drive)
light green: friction of the rotationof the wheels
dark green: sliding friction of the wheells (always ortogonal to the wheel direction)
blue: current velocity


In this image, the car is turning (the driver send the command to turn the wheel to the right)
This produces a change in the forces applied.


Now I need to know how to send the right command to stop and avoid the collision. (As used in the separation behavior)

  Rafael.-
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

xsi3rr4x (64 views)
2014-04-15 18:08:23

BurntPizza (62 views)
2014-04-15 03:46:01

UprightPath (75 views)
2014-04-14 17:39:50

UprightPath (58 views)
2014-04-14 17:35:47

Porlus (76 views)
2014-04-14 15:48:38

tom_mai78101 (101 views)
2014-04-10 04:04:31

BurntPizza (161 views)
2014-04-08 23:06:04

tom_mai78101 (256 views)
2014-04-05 13:34:39

trollwarrior1 (209 views)
2014-04-04 12:06:45

CJLetsGame (216 views)
2014-04-01 02:16:10
List of Learning Resources
by SHC
2014-04-18 03:17:39

List of Learning Resources
by Longarmx
2014-04-08 03:14:44

Good Examples
by matheus23
2014-04-05 13:51:37

Good Examples
by Grunnt
2014-04-03 15:48:46

Good Examples
by Grunnt
2014-04-03 15:48:37

Good Examples
by matheus23
2014-04-01 18:40:51

Good Examples
by matheus23
2014-04-01 18:40:34

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:22:30
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!