The Daily Click ::. Forums ::. Klik Coding Help ::. Traffic Engines, come on you smarites!
 

Post Reply  Post Oekaki 
 

Posted By Message

Assault Andy

Administrator
I make other people create vaporware

Registered
  29/07/2002
Points
  5686

Game of the Week WinnerVIP Member360 OwnerGOTM JUNE - 2009 - WINNER!GOTM FEB - 2010 - WINNER!	I donated an open source project
11th January, 2004 at 05:06:47 -

Hey everyone,
I've been working on a project with Yuyu for a little while now. It's a gta style clone and we've done a fair bit. We have tried to make it as flexible as possible, including map makers, customizable graphics. But we can't get around the traffic and the Peds. We've made several small traffic engines, failing somewhere in each. I've gotten very close in one, and it worked great until I overcomplicated it with roads and detectors going everywhere.

If you know of a good traffic engine or could shed any light on the idea, please feel free.

-Andy & Yuyu

 
Creator of Faerie Solitaire:
http://www.create-games.com/download.asp?id=7792
Also creator of ZDay20 and Dungeon Dash.
http://www.Jigxor.com
http://twitter.com/JigxorAndy

Shen

Possibly Insane

Registered
  14/05/2002
Points
  3497
11th January, 2004 at 06:10:14 -

The only game I can remember doing something like this is Harry Cars (or whatever it was) which used detectors at every junction showing what way the cars could go, and they turned at random.

 
gone fishin'

The Chris Street

Administrator
Unspeakably Lazy Admin

Registered
  14/05/2002
Points
  48488

Game of the Week WinnerClickzine StaffAcoders MemberKlikCast StarVIP MemberPicture Me This Round 35 Winner!Second GOTW AwardYou've Been Circy'd!Picture Me This Round 38 Winner!GOTM December Third Place!!
I am an April FoolKliktober Special Award Tag
11th January, 2004 at 07:49:35 -

Yup. Say for instance you had a road like:


__|__

A T-Junction.

You'd put a detector in the middle and then make an event which is something like:

ALWAYS: Set Alterable Value A of Car to random (1) - so it randomly flickers between Value 0 and 1.

Only one event while action loops and car is overlapping detector, and Alterable Value A of Car = 0: Set direction to UP

Only one event while action loops and car is overlapping detector, and Alterable Value A of Car = 1: Set direction to CONTINUE

Course, it'd need to be more complex than that, but as far as Im aware, you'd have to do something like this.



 
n/a

Smeggy

The Smegster

Registered
  08/01/2003
Points
  1062

VIP Member
11th January, 2004 at 08:02:24 -

Sounds a very difficult task, I hope you get around it..

 
http://www.klik-union.com

Cazra

Crazy?

Registered
  24/07/2002
Points
  4472

Game of the Week WinnerVIP Member
11th January, 2004 at 08:15:58 -

I've never played GTA but I've know that Jak II has an engine similar to it.
Like Circy said, use the turning detectors. For pedestrians, give them a more random movement.


 
n/a

AndyUK

Mascot Maniac

Registered
  01/08/2002
Points
  14586

Game of the Week WinnerSecond GOTW AwardHas Donated, Thank You!VIP Member
11th January, 2004 at 08:30:40 -

smarties have the answer
but they just wont tell me!!

i would start with the cars as bouncing ball objects and objects at set points in the road to turn them
mabye using flags to stop/start

 
.

Zane



Registered
  09/09/2003
Points
  1183
11th January, 2004 at 11:36:34 -

oh god. the memorys of taxi dash ar coming flooding back.
im attempting to make one now using the direction calculator. its not going well. ill keep trying though.

 
www.klikforever.co.uk
GO THERE!!!

Mr Coffee



Registered
  04/09/2003
Points
  440
11th January, 2004 at 12:42:18 -

Well, if you really want to make it good, you should have the cars change lanes, pull in and out of parking spots, etc. You would need to use fastloop and link detectors to each car. The cars would then use the detectors to see if it's safe to change lanes, turn right on red, etc. The cars would simply drive around randomly, changing lanes every once in awhile. I actually don't think it's that complicated, just very time consuming to program. The hard part would be programming the cars to navigate a parking lot. That would require quite a bit of work to pull off.

 
99 percent chance that the above post is 100 percent correct.

AndyUK

Mascot Maniac

Registered
  01/08/2002
Points
  14586

Game of the Week WinnerSecond GOTW AwardHas Donated, Thank You!VIP Member
11th January, 2004 at 14:10:34 -

you could get some ideas if you look at the ai in games like grand theft auto.
the normal traffic is simple.
they just stop when they get too close to other cars and red lights and turn at the right time.
the police cars are more tricky to code because they chase you when you're wanted and aviod other cars by changing lanes.

 
.

Kris

Possibly Insane

Registered
  17/05/2002
Points
  2017
11th January, 2004 at 14:51:30 -

hey, that reminded me of this little train simulation i started.

Works a treat, I just got bored of it too soon.

Image

edit: what bastard admin got rid of my amazing signiture?

Image Edited by the Author.

 
"Say you're hanging from a huge cliff at the top of mt. everest and a guy comes along and says he'll save you, and proceeds to throw religious pamphlets at you while simultaniously giving a sermon." - Dustin G

Pete Nattress

Cheesy Bits img src/uploads/sccheesegif

Registered
  23/09/2002
Points
  4811
11th January, 2004 at 15:12:22 -

eh? we can't edit signatures. you need database access.

 
www.thenatflap.co.uk

Kris

Possibly Insane

Registered
  17/05/2002
Points
  2017
11th January, 2004 at 15:14:06 -

then it was obviously one of the admins with that power

 
"Say you're hanging from a huge cliff at the top of mt. everest and a guy comes along and says he'll save you, and proceeds to throw religious pamphlets at you while simultaniously giving a sermon." - Dustin G

Karnage [Ragnarok Games]



Registered
  28/10/2003
Points
  664
11th January, 2004 at 15:22:24 -

Shadowcaster, maybe? He has the signature-changing power.

Well, here's a VERY simple engine, andy.

0 <---- Car
_|_ <---- Your basic t-junction.
^
Sensor

When the car hits the sensor, set alterable value a to random 1-3. 1=->, 2=->, 3 = ^.

 
Remember, there's a little darkness in all of us... we just express it best.
--Ragnarok Games



yuyu



Registered
  13/05/2003
Points
  202

VIP Member
11th January, 2004 at 20:04:13 -

Thanks for helpin out.

 
n/a

Ashman

Possibly Insane

Registered
  12/06/2002
Points
  3974
12th January, 2004 at 07:31:26 -

Kris you can take comfort in the fact that they also changed my rating! Or you can laugh at me, either way is good.

 
Show me the power child,
I'd like to say,
That I'm down on my knees today,
Gives me the butterflies,
Gives me away,
'Til I'm up on my feet again,
I'm feeling outshined.


"Outshined" - SoundGarden

Kris

Possibly Insane

Registered
  17/05/2002
Points
  2017
12th January, 2004 at 10:31:27 -

we must find confort in eachother in these dark times

 
"Say you're hanging from a huge cliff at the top of mt. everest and a guy comes along and says he'll save you, and proceeds to throw religious pamphlets at you while simultaniously giving a sermon." - Dustin G

Airflow

imafirinmahlazr

Registered
  24/09/2003
Points
  -197

VIP MemberSonic SpeedSnow Cloud!Computer
13th January, 2004 at 03:44:10 -

Karnage, Having only one sensor at the end of a road will
lead to many car crashes.

Kaboom!!
| /
-oo-
|
|
Turning

Unless your not planning on doing a high way, That is useless.

eg. The squirrle - password: part2

Get up to highway part(if possible), and you will find a useless car crashing
engin.(Really useless)


 
n/a

cake



Registered
  13/12/2002
Points
  1173
16th January, 2004 at 05:52:16 -

NO NO NO!! PLEASE do not use detectors, I beg you. The engine will crash and burn gloriously.

Detectors are pointless. Since the game has a level editor, you can also store all the corners and intersections in a database.

Then for your traffic, parse the database for each car, and find if the cars position matches the location stored in the database, turn the car.

This system would be very complex to program, and would probably be around 30-50 events, but I think it would definately be worth it, because the system is dynamic and people making maps wouldnt have to bugger around putting waypoints in for their levels.

 
n/a

Smeggy

The Smegster

Registered
  08/01/2003
Points
  1062

VIP Member
16th January, 2004 at 06:44:24 -

Nice idea cakey

 
http://www.klik-union.com

Mr Coffee



Registered
  04/09/2003
Points
  440
16th January, 2004 at 13:23:41 -

How are the cars going to detect other cars if they don't have detectors? It's like putting a robot in an environment without any sensors. It's not hard to link detectors to cars using fastloop, and it should never cause any problems.

 
99 percent chance that the above post is 100 percent correct.

Kris

Possibly Insane

Registered
  17/05/2002
Points
  2017
17th January, 2004 at 03:17:21 -

Biax = right.

using arrays you wouldn't need any detectors. you just match the position of the car (or whatever) to the tile that's stored in the array in the same location, then do whatever.

 
"Say you're hanging from a huge cliff at the top of mt. everest and a guy comes along and says he'll save you, and proceeds to throw religious pamphlets at you while simultaniously giving a sermon." - Dustin G

Mr Coffee



Registered
  04/09/2003
Points
  440
17th January, 2004 at 09:43:31 -

No, he is not "right". The method you are talking about with arrays would be extremely complicated to implement.

 
99 percent chance that the above post is 100 percent correct.

Keatonian



Registered
  15/07/2002
Points
  571
17th January, 2004 at 10:16:26 -

Not to mension there would be way to many
crahes or cars would go through each other.

 
-Above post is ancient and probably irrelevant-

An old account of mine, recently cleared out. It's a blast to the past, the age was marked as 14 when I found it. If you know where to look, you can track me. Au revoir.

Kris

Possibly Insane

Registered
  17/05/2002
Points
  2017
17th January, 2004 at 11:06:37 -

"The method you are talking about with arrays would be extremely complicated to implement."

that doesn't "mean" it can't be "done"

 
"Say you're hanging from a huge cliff at the top of mt. everest and a guy comes along and says he'll save you, and proceeds to throw religious pamphlets at you while simultaniously giving a sermon." - Dustin G

Mr Coffee



Registered
  04/09/2003
Points
  440
17th January, 2004 at 13:09:39 -

It could be done but it would be more complicated than using detectors.

 
99 percent chance that the above post is 100 percent correct.

Lew



Registered
  06/01/2002
Points
  1014
17th January, 2004 at 13:49:27 -

Ok, for newbies who don't like to work, it's bad, for people who are serious about making a game as reliable as possible, it's good. It's how professional games work-every car and corner has an entry in the array, plotted with it's co-ordinates and for corners, possible outcomes. Then when your car overlaps another cars co-ordinates (using a formula with the size of the object) then they crash, if the car is a certain distance away from yours it tries to move out of the way. Then if the player/other car overlaps a corner co-ord it picks a desicion randomly to go that way. Each car also has a variable to say it is turning, and at which corner. If there are two cars turning at the same corner, make one stop.

I've implimented something similar into a game I'm making (not very far into it so no details yet). If you have a big comment at the top describing each item in the array it helps. Also make a subapp with a 'developers console' and code it so if you type 'getpos 2' or whatever it returns the co-ordinates of object 2. It's a LOT less cluttered and less memory hogging than bloody detectors-think about it, a few values stored for each car, or 4-10 detectors all messily places around each car-which ones more efficient?

 
<--intelligent, witty comment here-->

Mr Coffee



Registered
  04/09/2003
Points
  440
17th January, 2004 at 14:04:27 -

I think the most efficient method is the method that takes the least amount of time to code. The player does not care which method you use, since the end result is the same. Using detectors is not "memory hogging". If you create a very small object for the detector and select "info" you will see that it takes up less than 1 kilobyte!

 
99 percent chance that the above post is 100 percent correct.

Lew



Registered
  06/01/2002
Points
  1014
18th January, 2004 at 04:54:14 -

Not that sort of memory, MMF's object memory. With an array you can store virtually unlimited amounts of car values, whereas with detectors you can only store about 5000 (I know it says 10,000 but unless you have 3gb of ram no chance). Arrays are much easier to manage. Players at the other end do care which method, because detectors slow the game down and you can always tell if you're using detectors because it looks messy. I know, as I've said I'm making a similar game (not a GTA clone though) and I started off using detectors.

 
<--intelligent, witty comment here-->

Airflow

imafirinmahlazr

Registered
  24/09/2003
Points
  -197

VIP MemberSonic SpeedSnow Cloud!Computer
18th January, 2004 at 05:23:46 -

Detectors -BAD
Array -GOOD

Even all the original Nes and Snes games use this method on platformers.

PS. I wonder how the makers of GTA flet when making it?

 
n/a

Keatonian



Registered
  15/07/2002
Points
  571
18th January, 2004 at 11:03:34 -

Do this:

Make a whole lot of detectors, all different.
They test for collisions and such.
Now use rotate in the image editor to make all 32 directions.
Now use spreading values and fastloop to set all the detectors
to one car at a time, consult the array, and make all the
decisions. Don't forget the uses of traffic lights as Flags!





Oh, and this has been bugging me.
What is a Smarite? I know what
a Smartie is, but a smarite?

Image Edited by the Author.

 
-Above post is ancient and probably irrelevant-

An old account of mine, recently cleared out. It's a blast to the past, the age was marked as 14 when I found it. If you know where to look, you can track me. Au revoir.

Mr Coffee



Registered
  04/09/2003
Points
  440
18th January, 2004 at 14:09:53 -

First of all, it does not look messy if you make the detectors invisible. Second, having duplicates of the same object does not use up more RAM. And finally third, detectors are only going to slow it down a little more (because you have to use them to detect collisions). Most people today have at least a 1 ghz, so your not going to notice a speed difference between using an array and using detectors except on a slow computer. But if you think arrays are easier to deal with then use them. Everyone should use the method thats easiest for them, especially if the end result is the same.

 
99 percent chance that the above post is 100 percent correct.

cake



Registered
  13/12/2002
Points
  1173
19th January, 2004 at 06:26:05 -

Lew knows what I'm on about and I know what you're on about Lew. I don't think you should bother anymore, right now I'm kind of lost for words as to how incorrect Mr Coffee is "duplicates don't use more RAM", um actually yes they do.
But anyway, the system Lew described is the most efficient, maintainable, managable, debuggable, and powerful system to use.
Detectors = quick fix
Database of cars and intersections = a very powerful system that can be used for many different purposes, manouvering traffic is just one of them.

Theres an important issue this little quarrel has brought up with coding:
make your code as usable as possible. What else can I do with detectors stuck all over the place? Not too much without recoding considerable portions of preexisting code. Make tools with your code, not end products. Make things you can reuse over and over for many purposes.

Image Edited by the Author.

 
n/a

Mr Coffee



Registered
  04/09/2003
Points
  440
19th January, 2004 at 13:49:16 -

Well, I said "duplicates don't use more RAM" and that was incorrect (now I have to change my signature!). I just did some tests and they *do* use more RAM, although the amount is extremely small (50 duplicates of a small object will use up 1 more meg of RAM). Also, I would like to point out that I don't think you should stick detectors all over the road, and I never did. I think thats why you say its "messy". The cars should adapt to the road themselves. However, the easiest way to go about this is to have 4 detectors linked to each car, so it has a 360 degree view of the road and other cars. The car must know whats on all sides of it, so it can react correctly. I am not talking about a "Sim City" style traffic simulation where the cars move on a grid. My idea of a traffic simulation is more down to earth, where the cars have physics and have to react to the road and other cars.

For example, you could have SUV's which take longer to stop, so you simply place the SUV's forward looking detector farther ahead so it applies the breaks sooner when the car in front stops. This would make a great screen saver, and I will probably make it one of these days. The only thing I don't have figured out is how to deal with parking lots.

 
99 percent chance that the above post is 100 percent correct.

cake



Registered
  13/12/2002
Points
  1173
19th January, 2004 at 19:31:26 -

But having a database DOES give the car a 360 degree view. And you can variate the distances that the car checks around it so you can still have your SUV idea.
I think that you are looking at this at a car-to-car level, but I'm looking at the big picture, I'm looking at it at a city level.
There is a possibility that detectors would work ok, but its only an immediate solution, its only the quick fix, it's only solving the immediate problem that Andy is having, whereas the database solves this problem, and many other possible problems down the track.

Just use some simple coordinate comparison, and distance formula and you're laughing all the way to the advanced traffic simulation. Look at it this way: GTA didn't use detectors: GTA used coordinates and mass data. "Detectors" are the baby MMF way of getting around doing proper mathematical coding and referncing. Outside MMF detectors don't exist- they are just way too inefficient and wasteful.

 
n/a

Kris

Possibly Insane

Registered
  17/05/2002
Points
  2017
20th January, 2004 at 04:01:17 -

They're still there in most platform games... but that doesn't matter... this sounds like the start of another debate, we should let Andy decide which method he'd rather use, it's his game after all

 
"Say you're hanging from a huge cliff at the top of mt. everest and a guy comes along and says he'll save you, and proceeds to throw religious pamphlets at you while simultaniously giving a sermon." - Dustin G

cake



Registered
  13/12/2002
Points
  1173
20th January, 2004 at 05:10:54 -

True, its up to Andy. I just really want to see him make it without any troubles

 
n/a

Mr Coffee



Registered
  04/09/2003
Points
  440
23rd January, 2004 at 19:09:46 -

I don't see why using detectors is "less expandable". I have never said the detector method is more efficient, using an array is of course more efficient. But everything is a trade off between how long it takes to program verses how much it effects the game. The user will not be able to tell if you use detectors or not. If you spend to much time coding complex things you won't get anything done. If Andy does not mind using an array then fine. I just would not do it that way, because I actually want to finish something.

 
99 percent chance that the above post is 100 percent correct.

Assault Andy

Administrator
I make other people create vaporware

Registered
  29/07/2002
Points
  5686

Game of the Week WinnerVIP Member360 OwnerGOTM JUNE - 2009 - WINNER!GOTM FEB - 2010 - WINNER!	I donated an open source project
25th January, 2004 at 18:59:58 -

Wow, i go on holidays for a while and everyone posts. Thanx for all the help guys. I see that many of you seem to think that the easiest method would be using detectors at T junctions. But that is not the case because you have to remember that a road has two sides, and two directions.

Biax had a great idea, that was the method that I was going to use on the pedestrians to test if they were overlapping the road or not, but I didn't really think about it for the cars so maybe I can do that. Sadly Yuyu is leaving in a few days and we won't see any great click games by him for a while. But I will continue this project at a steady pace and maybe you will hear from it in a few months.

If you are interested in this project or would like to contribute any feedback, please don't hesitate to email me at andy_likes_chicken@hotmail.com

 
Creator of Faerie Solitaire:
http://www.create-games.com/download.asp?id=7792
Also creator of ZDay20 and Dungeon Dash.
http://www.Jigxor.com
http://twitter.com/JigxorAndy
   

Post Reply



 



Advertisement

Worth A Click