How to do it...

The section provide steps for how to set up Q-learning:

  1. Define 16 states:
states <- c("s1", "s2", "s3", "s4", "s5", "s6", "s7", "s8", "s9", "s10", "s11", "s12", "s13", "s14", "s15", "s16") 
  1. Define four actions:
actions<- c("up", "left", "down", "right") 
  1. Define the transitionStateAction function, which can simulate the transitions from one state s to another state s' using an action a. The function takes in the current state s and selected action a, and it returns the next state s' and corresponding reward r'. In case of constrained action, the next state returned is the current state s and the existing reward r:
 transitionStateAction<- function(state, action) { # The default state is the existing state in case of ...

Get R Deep Learning Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.