# Agent Moves

## Introduction

Get your agent to move. In this tutorial you give your Agent some turns and moves to really dance!

## Teleport your Agent

Bring your Agent near you so you can watch it dance. Teleport the Agent to your position but move it forward by `3`.

Run the program and look to see that your Agent comes close to your position.

``````agent.teleport_to_player()
agent.move(FORWARD, 3)``````

## Make a dance move

To make the first dance move, add in an if else. When the condition in the if is true, have the Agent move forward by `1`. Otherwise, for else, have the Agent move back by `1`.

``````agent.teleport_to_player()
agent.move(FORWARD, 3)
if True:
agent.move(FORWARD, 1)
else:
agent.move(BACK, 1)``````

## Add the dance logic

Add another if else below the previous one. For the case when condition in the if is true, have the Agent turn right. For the else, have the Agent turn to the left.

``````agent.teleport_to_player()
agent.move(FORWARD, 3)
if True:
agent.move(FORWARD, 1)
else:
agent.move(BACK, 1)
if True:
agent.turn(TurnDirection.RIGHT)
else:
agent.turn(TurnDirection.LEFT)``````

## Randomize the moves

Well, these moves are fairly predicable. Add some randomness to the Agent’s moves. Replace the true in both of the if conditions with a random logic value. Set the condition as a comparison of a random number between `0` and `1`. Make the comparison a check to see that the random number is greater than `0`.

``````agent.teleport_to_player()
agent.move(FORWARD, 3)
if randint(0, 1) > 0:
agent.move(FORWARD, 1)
else:
agent.move(BACK, 1)
if randint(0, 1) > 0:
agent.turn(TurnDirection.RIGHT)
else:
agent.turn(TurnDirection.LEFT)``````

## Add a loop

The Agent can now make one random dance move. Make the Agent really get the moves going by repeating them in a loop. Put the two if else portions of the program in a for loop. Have the loop repeat `25` times.

``````agent.teleport_to_player()
agent.move(FORWARD, 3)
for index in range(25):
if randint(0, 1) > 0:
agent.move(FORWARD, 1)
else:
agent.move(BACK, 1)
if randint(0, 1) > 0:
agent.turn(TurnDirection.RIGHT)
else:
agent.turn(TurnDirection.LEFT)``````

## Slow down the dance!

Wow, that was a fast dance! The Agent can really bust a move. Add a pause to slow the Agent down. Set the pause time to `250` milliseconds.

``````agent.teleport_to_player()
agent.move(FORWARD, 3)
for index in range(25):
if randint(0, 1) > 0:
agent.move(FORWARD, 1)
else:
agent.move(BACK, 1)
if randint(0, 1) > 0:
agent.turn(TurnDirection.RIGHT)
else:
agent.turn(TurnDirection.LEFT)
loops.pause(250)``````