Reinforcement Learning is the technique of machine learning that train the the models to take the sequence of action. __Realcode4you.com__ expert team has the deep knowledge in all Reinforcement Learning problems.

The main goal is long-term, such as **game-playing, robotics**, etc.

In this the agent continues doing these three things (**take action, change state/remain in the same state, and get feedback**), and by doing these actions, he learns and explores the environment.

**Sample Project Description **

For the fifth and final programming assignment, you will implement a reinforcement learner and apply it to the racetrack problem. The racetrack problem is a popular control problem, often used in reinforcement learning assignments. The goal is to control the movement of a race car along a pre-defined racetrack. You want your race car to get from the starting line to the finish line in a minimum amount of time. In this version of the problem, your agent will be the only racer on the track, so it is more like a time trial than a full competitive race. More formally, at each time step, the state of the agent can be encoded in four variables: xt and yt are the x and y coordinates corresponding to the location of the car at time step t (we treat the racetrack as being laid out on a Cartesian grid). The variables vx = ˙xt and vy = ˙yt represent the x and y components of the car’s velocity at time t (note that x˙ denotes the first derivative of x with respect to time). The control variables for the car are ax = ¨x and ay = ¨y, which represent the x and y components of an acceleration vector to be applied at the current time step (note that x¨ denotes the second derivative of x with respect to time). The system is governed by an approximation of the standard laws of kinematics:

xt ≡ x position

yt ≡ y position

vxt = ˙xt = xt − xt−1 ≡ x speed

vyt = ˙yt = yt − yt−1 ≡ y speed

axt = ¨xt = ˙xt − x˙ t−1 ≡ x acceleration

ayt = ¨yy = ˙yt − y˙t−1 ≡ y acceleration

At any given time step, your car only has active control over the values of ax and ay and must use these control variables to influence the car’s state. This essentially gives you the ability to accelerate, decelerate, and turn. There is a further restriction that the set of values that may be assigned to a control variable is −1, 0, and 1. That is,

The velocity of your car at any given time is limited to (vxt , vyt ) ∈ [±5, ±5]. Any attempt to accelerate or decelerate beyond these limits will be ignored.

As an example, if at time t = 0 your car is at location (2, 2) with velocity (1, 0), it is essentially moving towards the east. If you apply an acceleration of (1, 1), then at timestep t = 1 your position will be (4, 3) and your velocity will be (2, 1). At each time step, your acceleration is applied to your velocity before your position is updated. Strictly speaking, this is not a good model of Newtonian physics, but we’re dealing with integer position and velocity values, so some simplifying abstractions need to be made.

If this were the extent of the problem, it would be quite easy to solve for any given track, so to make things a bit more interesting, we are going add in a small amount of non-determinism. To do this, we assign a probability to each attempted action for each possible outcome. For this assignment, we specify that for any attempt to accelerate, there is a 20% chance that attempt will simply fail, and the velocity will remain unchanged at the next timestep. Thus, at each timestep, the probability of accelerating as specified is 80% and the probability of having no acceleration is 20%.

In this problem, there is an additional requirement that you stay on the track; crashing into the wall is bad. This means that you need to write code capable of detecting the vehicle intersecting with the boundary of the track. One common algorithm that can be used for this comes from computer graphics and is called “Bresenham’s Algorithm.” You can find information on this algorithm at

You will experiment with two different versions of how “bad” it is to crash. The first variant says that, if the car crashes into a wall, it is placed at the nearest position on the track to the place where it crashed, and its velocity is set to (0, 0). The second, harsher variant says that when a car crashes, its position is set back to the original starting position, as well as zeroing its velocity. Essentially, in this latter case if you crash, you have to start over from the beginning. You should implement both variants in your program so that you can experiment with what effects they have on the strategies your car learns. Since you have a limited time to run experiments, however, you are only expected to do a side by side comparison of the two definitions of a “crash” on the R shaped track (in the file R-track.txt). For the other tracks, use the version where crashing stops the car but leaves it in the location it crashed.

The cost function is 1 for each move, except when you reach the finish line. The finish line locations are absorbing states with cost 0. Since you are attempting to minimize cost, this translates to attempting to complete the race in as few time steps as possible. You do not need to stop on a finish state. It is sufficient to cross the finish line, so this means the “wall” behind the finish line really isn’t a wall.

**Project Requirements **

Here are the specific steps that need to be followed.

Implement the racetrack problem as described above, including a racing simulator that takes a track specification (described below).

Implement the Value Iteration algorithm and apply it to the racetrack problem using the model as described above.

Implement both the Q-learning and SARSA algorithms, and apply them to the racetrack problem using the racing simulator but no direct knowledge of the model.

Test your algorithms on the three tracks provided in the data files described below. The files are named L-track.txt, O-track.txt, and R-track.txt and can be found within Canvas.

For the L-track and O-track, test your algorithms under the condition that a crash results in the vehicle being placed at the nearest point to the crash.

For the R-track, test your algorithms under the two crash conditions: 1) a crash results in the vehicle starting at the nearest point to the crash, and 2) a crash results in the vehicle moving back to the starting line. In the latter case, the start state closest to the crash should be chosen.

It is up to you to determine appropriate design parameters such as learning rate, discount factor, exploration strategy, etc.

Use the data files for the tracks provided, represented in ASCII. The first line lists the size of the track as an comma delimited pair hrows, colsi. The rest of the file is a grid of the specified dimensions with one character at each point. The legend for the files is:

– S – This square is on the starting line.

– F – This square is on the finish line.

– . – This square is open racetrack.

– # – This square is off the racetrack (i.e., a wall).

As a simple example: 5,5

FF###

..###

..###

....S

....S

Run experiments, keeping track of the number of training iterations and the number of steps the race car needs to take before finding the finish line. Make sure you run at least 10 experiments for each track (preferably more) to get reasonable statistics. Also generate data so you can plot learning curves.

Write a very brief paper that incorporates the following elements, summarizing the results of your experiments. Your paper is required to be at least 5 pages and no more than 10 pages using the JMLR format You can find templates for this format at http://www.jmlr.org/format/format.html. The format is also available within Overleaf.

1. Title and author name

2. Problem statement, including hypothesis, projecting how you expect each algorithm to perform

3. Brief description of your experimental approach, including any assumptions made with your algorithms

4. Presentation of the results of your experiments

5. A discussion of the behavior of your algorithms, combined with any conclusions you can draw

6. Conclusion

7. References (Only required if you use a resource other than the course content.)

Submit your fully documented code with sample runs, results of the runs of each algorithm, and your paper.

For more details contact Us at:

realcode4you@gmail.com

## Comments