Assault Andy Administrator
I make other people create vaporware
Registered 29/07/2002
Points 5686
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.
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.
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.
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.
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.
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.
hey, that reminded me of this little train simulation i started.
Works a treat, I just got bored of it too soon.
edit: what bastard admin got rid of my amazing signiture?
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.
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
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.
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
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.
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.
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
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.
"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
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?
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.
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.
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?
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.
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.
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.
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.
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.
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
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
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