Try   HackMD

CAGE Dev Log - Day 5

Image Not Showing Possible Reasons
  • The image was uploaded to a note which you don't have access to
  • The note which the image was originally uploaded to has been deleted
Learn More →

Today I implemented the path locking system allowing car merging into one lane without crashing into each other.

Each car needs to propose its intent, and a god (temporarily called schedule_intents) will review each intent, and approve, trim, or reject them.

This implementation is a little bit naive and only scheduling by priorities.

Here's the simplied psuedocode for those systems:

schedule_intents

pub fn schedule_intents( mut intents: Vec<PathLocks> ) { for intent in intents.iter_mut() { // for each segments for lock in intent.locks { for other_lock in other_already_locks { if collision(lock, other_lock) { // try to trim lock if trim_lock(&mut lock) { intent.path_locks.truncate(j + 1); } else { // lock with `lock_together` cannot be trim // since some path needs to be lock together // e.g. paths in the junction. intent.path_locks.truncate(j); pop_locks_until_no_group(&mut intent.path_locks); } break; } } } for other_lock in other_new_locks { // trim lock or other_lock which has lower priority. } } }

We should create a index to speedup the collision query later.