# Approaches to an algorithm for crossing a road

I want to write an algorithm which indicates to a robot the first point in time when it is reasonably safe to cross a road. Assume that the robot's goal is to travel to a location that requires a road crossing and that the robot is ready to cross.

Simple algorithms and decision making will probably not suffice. What features and capabilities must the algorithm have to provide crossing safety? What existing AI methods might be useful to consider for this endeavor?

For the first iteration, we can assume the traffic pattern is normal in that no vehicles are driving over the curb and there are no high speed chases or other safety related abnormalities.

• Welcome to our small brilliant community in small wires of the internet.Can you please go through community guidelines.Computer vision algorithms can be applicable in this case study. – quintumnia Aug 26 '17 at 19:34

Any AI algorithm depends on the environment, and available actuators and sensors. In our case, the environment is a road, street, etc. The primary actuator includes wheels (or legs) of the robot. Sensors include a camera, sonar system, etc.
A simple Model-based reflex algorithm can work in your case:

function MODEL-BASED-REFLEX-AGENT(percept) returns an action
persistent: state, agents' current conception of the world state
model, description of how hte next state depends on current state and action
rules, a set of condition-action rules
action, most recent action, initially none
state <-- UPDATE-STATE(state, action, percept, model)
rule <-- RULE-MATCH(state, rules)
action <-- rule.ACTION
return action


Most of the terms and functions are self-explanatory and I will try to explain the important points. This implementation helps the robot to keep track of the external environment by maintaining internal state that depends on the percept history. Updating the internal state requires how the environment works without our agent in it. For e.g., Cars stop at red light and start moving on the green signal. Another thing that is required is how the actions of our agent will affect the world. Since your robot is only trying to cross the road there are not many cases here. Simple things include, stopping motors will stop the bot and starting them will move it forward.

The algorithm above shows how the current percept combined with the old internal state result in generating the updated description of the world, based on agent's model of how the world works. Thus, agent's model of how the world works is the most important part. UPDATE-STATE is responsible for creating new internal state description. The actual implementation of this will depend on the environment and technology that is being used.

The above algorithm has been taken from the book, Artificial Intelligence: A Modern Approach, for agents working in the partially observable environment. Implementation of many functions also depends on how complex you want your robot to be. For e.g., we haven't considered the case of looking up while crossing the road. This is possible that something might be falling from the sky, highly improbable, but possible. The list like this never stops in real life environments.

You can use Imagination-augmented to predict wrong and fatal actions. Deep mind is working on it and I believe it is a great solution to many problems. You need to predict whether the best solution is to take a few steps forward so you do not get hit or go back a few steps.