Building A Soccer Playing Agent

 

Now that you have built a robot and gotten it to move relatively straight (Fred Martin, the creator of the handyboard wrote an article titled, “Real Robots Don’t Drive Straight”) we now want to give it some behaviors that will allow it to play soccer. 

 

Creating a simple reflex agent – Remember that an SRA (simple reflex agent) perceives the world and then performs some action based on its percepts.  This means that now you should be thinking about how your robot will perceive the world.  Since we only have photosensors and touch sensors, your robot will use these to decide where it is on the playing field, where the goal is, an if you have possession of the ball.

 

Where are you on the soccer field?  If you look at the soccer field there are several things you want to use your sensors so that you know something about your position on the field.

 

Are you in the goal area?   The goal area is painted white and is larger than the lines.

 

Are you in a black area? 

 

Are you on a line?

 

Are you at the line intersection?

 

Did you hit a wall? 

 

What other clues are there?

 

For each of the above, think of the action you would like your robot to take.  Remember this is not a goal based agent so you are merely perceiving and reacting.

 

The other big question is: Does the robot have the ball?

 

What sensor(s) do you need to detect the ball?

 

What robot architecture did you use to keep the ball?

 

If you don’t currently possess the ball what seeking actions are you going to perform?

 

Remember your action sequence will depend on your possession of the ball and your position on the field?

 

Make sure you code each action sequence as a function so that you can easily change or add to it when creating the goal based agent.

 

Arrange the “soccer” balls on the field as indicated.

Once you have completed your agent, test your agent by finding out:

a)      How many goals your robot can make in 5 minutes?

b)      What is the shortest time it takes your robot to make a goal?

 

Make sure that for each attempt your robot starts by placing its rear right tire on the designated starting point.

 

Make sure your robot does not move out the opening with the ball!!!!

 

HAVE YOUR INSTRUCTOR INITIALIZE YOUR ROBOT CHECKOFF SHEET

 

Creating a Goal Based Agent – Now things change.  In addition to all your robot could do as a simple reflex agent, it now has a goal (get the ball through the goal opening), and it has knowledge about its previous state.  How can you use this to create a more effective soccer agent?

 

Think in terms of, “If my previous state was white goal area, and I hit a wall, and I have possession of the ball, then I want to move along the wall to find the goal opening.”

 

What should you do if your previous area was white goal and now you are in a black area?

 

Arrange the “soccer” balls on the field as indicated.

Once you have completed your agent, test your agent by finding out:

c)      How many goals your robot can make in 5 minutes?

d)     What is the shortest time it takes your robot to make a goal?

 

Make sure that for each attempt your robot starts by placing its rear right tire on the designated starting point.

 

Make sure your robot does not move out the opening with the ball!!!!

 

HAVE YOUR INSTRUCTOR INITIALIZE YOUR ROBOT CHECKOFF SHEET

 

Creating a Learning Agent - Write a program that implements the back propagation algorithm discussed in class.  Modify the generation5 neural net code to implement a neural network with 2 input nodes, 2 hidden nodes, and 2 output nodes.  You will need this code to program your robots.  Hand in one program per robot team.  The source code and an explanation of back propagation can be found at:   http://www.generation5.org/content/2000/cbpnet.asp  .   The code here will train a neural net to implement a 2 input 1 output function.  The source code is downloadable and will run. 

 

Important consideration

 

These are actual training examples used by a former student:

 

// straight

                        bp.Train(112,107,.025,.025);

                        bp.Train(120,115,.025,.025);

// off to the right

                        bp.Train(107,36,.050,.020);

                        bp.Train(108,36,.050,.020);

// off to the left

                        bp.Train(54,111,.020,.050);

                        bp.Train(63,107,.020,.050);

 

You may have to do things differently.  The robots are very sensitive to the amount of light available.  We also have many different kinds of motors and the respective power requirements will differ.  Notwithstanding, these are good enough to see how your neural network works.  Also, this student multiplied by a scalar of 550 on the outputs from trained neural network, rather than 1000, before he input them to the motor function.  Why did he do this??  Because he needed to slow the robot down more and didn't feel like redoing his training examples!!!

 

 

Use these training examples to train your neural network.

 

Write an Interactive C program that will display readings from both photo sensors.  You will use these readings to create your training examples.  Given the way you position the robot on the road, and  the sensor readings from the robot, estimate the parameters needed  for the left and right motor functions to control the rear wheels.  Therefore, each training example will consist of two inputs (the sensor readings), and two outputs (the values passed to the right wheel's motor function and the left wheel's motor function).  Please try not to step on the road.  Dirt from your shoes may interfere with future sensor readings.  You may have to write some small programs and experiment with the robots in order to get a good set of training examples.

 

Use the modified Generation 5 code you created for this project to program your robot with a neural network.    Take the trained neural network function, and modify it for use in Interactive C.  Remember, the gen5 code produces decimal output.  The IC motor function requires a value between 0 and 100.  The training portion of the program is executed in the desktop environment, with the Microsoft Visual C++ compiler.   Once you have the weight values for the neural network equations, incorporate them into the Interactive C neural network program and try your robot on the road.    You may have to repeat steps 4 and 5 several times before your robot reasonably follows the road.  One important thing to remember is to make your robot move slow enough so that it has time to take readings from the road and act upon these readings.

WHAT YOU NEED TO HAND IN

1. Modified genratin5 code

2. Interactive C program that reads values from photo sensors and displays these on LCD screen

3. An interactive C version of the trained neural network function for the 2 input 2 output neural network

 

 

Replace the hard coded line following portion of your soccer playing agent with the trained neural network. 

 

Arrange the “soccer” balls on the field as indicated.

Once you have completed your agent, test your agent by finding out:

a)      How many goals your robot can make in 5 minutes?

a)      What is the shortest time it takes your robot to make a goal?

 

Make sure that for each attempt your robot starts by placing its rear right tire on the designated starting point.

 

Make sure your robot does not move out the opening with the ball!!!!

 

Compare all your results in an easy to understand chart.  What conclusions can you make about each agent type?

 

HAVE YOUR INSTRUCTOR INITIALIZE YOUR ROBOT CHECKOFF SHEET