Dan Gavin's AI Project
BMX: Bike Messenger Express

Contents
Domain
Illustration
Methods
Conclusions
Sample Session

Domain

BMX (Bike Messenger EXpress), exists in the city of New Brunswick. More specifically on the Rutgers University College Avenue Campus and it's immediate surrounding streets. These surroundings include the geographical landmarks in addition to everything that they enclose; such as cars, buses, pedestrians, pot holes, and many other obstacles that can prevent this agent from arriving to it's destination. The idea of the environment is that it's not the ideal place for this agent to survive in with all these things that can prevent it reaching it's destination, however this agent must be able to adapt to the conditions it's placed in.

By this agent being a bike messenger, the agent exists for the reason of making deliveries from one destination to another in a fairly short amount of time (most faster than the traditional postal service). In order for this agent to achieve it's goal in this domain, it must know the streets and the fastest way to get from where it picked up the package to where it's going to drop off the package, and also be quick in reacting to anything that comes in it's way so that BMX won't be deterred in arriving to it's destination.

Now, if one were to simply look at a map of area, it would be fairly easy to trace a route with one's finger of how to get the package that this messenger is delivering from the starting destination to the ending destination. However, once taken off the map and placed into the actual streets of New Brunswick, BMX

BMX's path will be filled with obstacles such as mentioned earlier. Here is when BMX must decide just how to avoid the obstacles it encounters. To avoid obstacles, BMX must go into it's knowledge base, quickly analyze the situation, and find away to avoid hitting the object if it is possible in the given situation to avoid hitting the obstacle.


Illustration

The program that is used for this project handles BMX in it's reasoning of what to do in situations in addition to simulating the environment that it exists in. It was a necessity for this project to have an environment that would simulate what this agent would encounter if it were actually placed in New Brunswick, or any city that that the agent has a map of in it's knowledge base.

Here's an example of how this BMX will behave. The user that is using BMX would type in a query such as the one below.(the output of the query can be found in sample session).

| ?- deliver(eastonSomerset, georgeBishop).

What the user is asking BMX to do is to deliver the item that is on the corner of Easton Ave. and Somerset St. to the corner of George St. and Bishop St. Like most bike messengers, odds are the agent is not waiting at the start point to pick up the item that is on the corner of Easton Ave. and Somerset St. The agent is out and about doing other things. So once the agent is called, the first thing that the agent will do is find it's way to the place that it is to pick up the item that is to be delivered.

In the example, when BMX is on the corner of College Ave. and Senior St., so it now has to find it's way Easton Ave. and Somerset St. to pick up the item to be delivered. While the on it's way to Easton Ave. and Somerset St., on the corner of Sicard St. and Senior St. BMX encounters a large pot hole. BMX looks to it's right, sees that something is in it's way, looks to it's left sees that nothing is there so it goes around the pot hole to the left.

Now BMX keeps on riding along, and it notices a small pot hole. It looks it's right and left respectively, notices that it's not safe. The next thing that BMX does is it realizes that this pot hole is fairly small and odds are in the agent's favor that if it was to jump over the small pot hole that it will not fall over. So the agent jumps over the obstacle and succeeds.

Next BMX approaches Wyckoff St. and Ray St. and notices an on coming car. Similar to how it did before, the agent swerved around the car to the right. However as the agent approaches Wyckoff and Morrell St., the agent isn't successful in avoiding an oncoming obstacle. As the agent gets to the intersection, it notices another small pot hole; from there the agent realizes that it's not safe to go around the pot hole, and is to late to jump or just run over the pot hole and hope for the best. Unfortunately, the agent got knocked off the bicycle, but quickly gets back on to reach the destination.

After the previous onslaught of obstacles, BMX now proceeds to pick up the package without encountering any other obstacles until it reaches Easton Ave. and Hamilton St. The agent runs into an unruly pedestrian, who BMX has to show who's boss. First the agent tries to avoid the agent to the right and left, with no success. The pedestrian is to tall to jump over, so what the agent does as a last resort to avoid the pedestrian is yells at them to move out of the way and points with it's right hand. Again, the agent was designed to be an efficient bike messenger, not demonstrate proper manners or obey street laws.

From this point on, the agent proceeds to complete the necessary path to deliver the item to the corner of George St. and Bishop St. Once the item is delivered, the agent will then proceed to randomly ride around until it is called on again.


Methods

From reading the illustration, in order for BMX to function correctly it must posses able to do the following.

  • a knowledge base of the area that it functions in.
  • the ability to recognize obstacles as they are encountered..
  • Be able to how to avoid a particular obstacle when it is encountered.

How the Agent Gets Around

In order for the agent to find it's way around, a similar algorithm that was used for the class assignment (homework 3). BMX requires an algorithm such as this in order to find the fastest way to get to it's destination for obvious reasons. This algorithm can be altered with the appropriate information of any location that one would like this agent to act in.

How the Agent Recognizes Obstacles

In order for BMX to determine what type of obstacle that it is encountering, BMX associates these obstacles with different types. Obstacle types are categorized by what alternatives are in avoiding them. The different types of obstacles that the agent can encounter are listed below.

  • Obstacles that can be jumped over.
  • Obstacles that can NOT be jumped over.
  • Obstacles that have no height (or a negative height) and can be jumped over.
  • Obstacles that have no height (or a negative height) and can NOT be jumped over.
  • Obstacles that can NOT be swerved around and ONLY jumped over.
  • Obstacles that are moving toward the agent in an unpredictable pattern.
  • Objects that the agent can run over (if the elects to run the obstacle, the agent can get knocked off the bicycle)..

By the agent having the types of Obstacles categorized, it can now treat Obstacles in accordance to what they are categorized in. For instance it would not be feasible for the agent to try to jump over an oncoming car. So now if the agent sees an oncoming car, it will classify it into the category of an "obstacle that can NOT be jumped over". Similarly in the event that the agent notices a curb fast approaching, it can not to swerve around to avoid the curb, it would have to jump over it.

How the Agent Knows How to Avoid Obstacles

In order to avoid Obstacles, BMX follows goes through the following sequence to decide how the agent should avoid the obstacle. BMX will go through the sequence by first deciding if the alternatives that have the lowest risk of falling off the bicycle.

First BMX will try to proceed past the obstacle as if it was nothing there. If it realizes that it has an obstacle to avoid, it will then try to go around the obstacle to the right and left in that respective order; often if the agent goes to the left there will be additional oncoming traffic. If BMX cannot go around the object to the right or left, it will then try to kick the object out of the way. As a final resort, the agent will try to run over the obstacle (regardless of what it is) and hope for the best.

Since this project is simulated at a prolog prompt, one the things that had to be done is to create an environment on the computer for BMX to act in. This was accomplished largely through random variables. An example of how this is used in the code of the project would be a predicate such as how part of the avoid call in the function is used.

avoid(X):- random(1, 16, Y), goAround(X, Y).

Number Range What it means to BMX
1 - 5 It is safe for the agent to avoid the obstacle to the right.
6 - 10

It is not safe for the agent to avoid the obstacle to the right, and will rather avoid the obstacle to the left.

10 - 13 It's not safe for BMX to go around the obstacle on either side, and the agent will now decide if the obstacle can be jumped over.
13+ BMX did not notice the obstacle soon enough and gets knocked off bicycle.

I found that by using random variables the type of environment that BMX will have to exist in can be simulated.


Conclusions

This project as a whole can be used as a skeleton for other things both related and unrelated to acting as a bike messenger. Things such as an agent mail carrier and race car driver can be implemented in a similar fashion as BMX. They have in common the need for knowing where there destination is and have the knowledge base to know how to not let things that get in their path prevent them from achieving their goal destination. These types of agents would be able to make use of predicates in a similar fashion.

Other than a way for BMX to communicate, another additional feature that would benefit this agent and others like it is the ability to remember experiences. For instance, if BMX happened to see a clear liquid on the ground and ride through it with no problems, the agent can associate clear liquid as something it can ride through with little risk to fall over. On the other hand if BMX were to ride through a dark "bluish/black" liquid that caused for a great deal of difficulty in balancing, it can associated it with something that can NOT be ridden through.

With regards to the coding of the project, the conditions of the environment that the agent is placed in can easily be changed depending on the time of day or just how busy New Brunswick is at the given moment. One can simply just change how the random events are being generated to have the Obstacles that the agent would encounter during that particular time be the more dominate event that will come up more.

While devising how this agent is to react to Obstacles that it encounters, I never quite realized until then how much thought one makes when making a decision in only a few seconds (if that). BMX is only limited to the part of the bike messenger delivery process where the agent picks up the package and delivers it with no interaction at all. This project can be further expanded with another agent being can interact with people. If the agent were also to have the ability to communicate, interact, have memory, and answer questions about the delivery with the person who's waiting to pick up the package it would be even more "human like".


Sample Session

| ?- deliver(eastonSomerset, georgeBishop).
Agent leaves from starting point collegeSenior to pick up a package at eastonSomerset.

Agent does NOT encounter an obstacle and proceeds.

Agent rides for 12 seconds toward sicardSenior.
Agent goes around the following obstacle to the left: largePotHole

Agent rides for 7 seconds toward sicardRay.
Agent jumps over the following obstacle: smallPotHole

Agent rides for 10 seconds toward wyckoffRay.
Agent goes around the following obstacle to the right: car

Agent rides for 7 seconds toward wyckoffMorrell.
Agent was knocked off bicycle by the following obstacle: smallPotHole
Agent quickly gets back on bicycle to proceed.

Agent rides for 7 seconds toward wyckoffBartlett.
Agent does NOT encounter an obstacle and proceeds.

Agent rides for 7 seconds toward wyckoffStone.
Agent does NOT encounter an obstacle and proceeds.

Agent rides for 5 seconds toward eastonStone.
Agent does NOT encounter an obstacle and proceeds.

Agent rides for 7 seconds toward eastonProspect.
Agent does NOT encounter an obstacle and proceeds.

Agent rides for 10 seconds toward eastonMine.
Agent does NOT encounter an obstacle and proceeds.

Agent rides for 15 seconds toward eastonHamilton.
Agent yells at obstacle and directs them out of the way with right hand: pedestrian

Agent rides for 10 seconds toward eastonSomerset.
Agent gets to where the package is.

Agent picks up package.

Agent does NOT encounter an obstacle and proceeds.

Agent rides for 15 seconds toward collegeSomerset.
Agent does NOT encounter an obstacle and proceeds.

Agent rides for 10 seconds toward collegeHamilton.
Agent does NOT encounter an obstacle and proceeds.

Agent rides for 10 seconds toward georgeHamilton.
Agent goes around the following obstacle to the right: car

Agent rides for 7 seconds toward georgeSeminary.
Agent jumps over the following obstacle: smallPotHole

Agent rides for 15 seconds toward georgeBishop.
Package was delivered.

yes
| ?-