Smart Car - challenge (avoid other cars while moving) code but in Advanced Bloxter

My professor and I have been having trouble figuring out the code for how to avoid obstacles while moving. We have read other forms about python code ways to do it. We were questioning if there was a way to do it using advanced bloxter.

Not really an answer, but an idea I’ve been thinking about. . .

How about programming a game of “tag”? One car is “it” and has to chase - and bump into - any other non-“it” car. That car now becomes “it”.


  1. IR emitter and detector sensors located on various sides of the car. The emitter can be modulated (in whatever way) to indicate which car is which, and which car is “it”.
  2. A game constraint - perhaps a large circle on the floor - that the cars are not allowed to cross. Any car that goes outside the circle automatically becomes “it”.
  3. Cars can exchange messages - for example: I am now “it” - to coordinate the actions and states of the cars.

I did some very basic code in Dexter OS that did very simple object avoidance:

  1. If the sensor shows an obstacle further away than “X”, move forward.
  2. If the obstacle is closer than “X”, but further than “Y”, stop.
  3. If the obstacle is closer than “Y”, move backwards.

I did some serious head-banging, both in learning how to make Charlie do what I wanted it to, and getting my code and the distance sensor to cooperate. I was pleased as punch when it finally started working. I could chase Charlie all over the flat simply by getting too close.

I was beginning some code that would combine that logic with

  1. If further away than “X”, move forward.
  2. Otherwise:
    a. Randomly pick a direction, left or right.
    b. Randomly pick an angular displacement, from 10 to 120 degrees.
    c. Execute the course change and begin moving forward again, if possible.

I was not able to complete this before getting sent back home to the States. Now that I’m back, I hope to continue work on it.

Later, I want to try some “Carl-esque” object recognition so that Charlie is attracted to some objects and avoids others. @cyclicalobsessive has already done similar things with his 'bot, Carl, where it can find it’s own charging stand, (for example).

Maybe he’ll spill the beans and save us all a lot of coding?

Jim “JR”