STANDARD PICO-8 COPYRIGHT
Details: https://www.lexaloffle.com/bbs/?tid=31927
UPDATED 09-24-18
WHAT'S NEW ??
09-25-18 (final)
- Decrease chance cars will back up when in a jam
09-24-18
- Allow traffic to back up if it gets clogged.
- Traffic level now set default at =3=
09-22-18
- First draft
- Traffic level set default at =1=
Alright, with that out of the way, what does this cart do ?
It is a simulation of automobiles. I was influenced by my Dad on this. For years ago he was interested in writing programs that simulated human life.
He wrote one in Turbo Pascal that had green dots all over it. They moved around slightly, sometimes traveling in a straight line. Sometimes standing still, sometimes wandering a bit. But if one green dot got too crowed by the other green dots it had a chance of going BERZERK.
A BERZERK dot would turn red and start to kill green dots. When enough bodies were found by green dots though, the green dots would clustered together and 3 of them would make a single blue-dot, a policeman, who would kill a red dot - restoring order to the community.
It was all quite fascinating to watch, and the method I'm using here is very similar to the method he used. Where no actual "dot" had its own identity, it was just chosen as a COMPONENT with one invisible number to state its "brain." You can see that I wrote a "component" type of Space Invaders HERE:
https://www.lexaloffle.com/bbs/?pid=55875&tid=31766
Back in QBasic years ago I wrote a program called Traffic to simulate automobile traffic. 4-cars coming from all directions and yet ... few if any pileups would occur. Why ?
HOMEWORK:
-
Easy question. Why are there no head-on collisions ?
Explain. -
Difficult. Why are pileups extremely rare at a traffic setting 1 ? (hold (O) to confirm this)
Explain. - Most difficult. If a pileup does occur, what could be changed in the code so cars would automatically clear it ?
Explain.
very cool man! i like the patterns that emerge when a full screen jam occurs :)
Glad you like it, notb, but drabbit ... that's not supposed to happen. Question, what could do you think can be changed in the code to prevent future pile-ups ?
well it always seems to start from the very rare 4-way collision. in my screen shot, you can see where it happens near the intersection of lanes 3 and 6. all 4 colors meet and the dead lock begins.
if i were coding it, i'd do a check for this special edge case and introduce some kind of novel behavior like moving in reverse or changing lanes. probably it would introduce more edge cases but they would be even more rare I would think. really interesting problem, honestly!
You are partially correct, notb. When I did this back in QBasic, I set it so any "vehicle" that was stopped had a chance of putting it in reverse to back up and clear the road.
Let's make that change and see if it runs any better ... updating above.
New question, without changing the actual amount or flow of traffic, what could be changed in the code to create more pileups and jams but still have the ability to clear it when it occurs ?
I would probably just take some randomness out and spawn cars at precise timings to cause the jams
Simpler than that, notb. Decrease the chance they will back up. Let's see that in action ... updating above.
And that's it ! That concludes the functionality and exploration of this cart (as far as I can tell) :)
[Please log in to post a comment]