description: a small example for reinforcement learning in python
import packages and set seed
1 | import numpy as np |
initial parameters
1 | NUMBER_OF_STATES = 6 # the length of the 1 dimensional world |
build q-table for actions
1 | def build_q_table(number_of_states, actions): |
method to take action
1 | def choose_action(state, q_table): |
define the change of environment
1 | def get_env_feedback(Current_State, Current_Action): |
update environment
1 | def update_env(state, episode, step_counter): |
main part of RL loop
1 | def rl(): |
run the application
1 | if __name__ == "__main__": |