Q-Learning算法(command_line_reinforcement_learning)
算法 learning Command line Reinforcement
2023-09-27 14:26:47 时间
Q-Learning算法
import numpy as np
import pandas as pd
import time
np.random.seed(2) # reproducible
N_STATES = 6 # the length of the 1 dimensional world
ACTIONS = ['left', 'right'] # available actions
EPSILON = 0.9 # greedy police
ALPHA = 0.1 # learning rate
GAMMA = 0.9 # discount factor
MAX_EPISODES = 13 # maximum episodes
FRESH_TIME = 0.3 # fresh time for one move
def build_q_table(n_states, actions):
table = pd.DataFrame(
np.zeros((n_states, len(actions))), # q_table initial values
columns=actions, # actions's name
)
print(table) # show table
return table
def choose_action(state, q_table):
相关文章
- 哈希算法原理【Java实现】
- 测开外传之 数据结构与算法(Java语言描述)
- 哈希函数4:一致性哈希算法:解决大规模集群负载均衡问题
- C#,机器学习的KNN(K Nearest Neighbour)算法与源代码
- spark支持的machine learning 算法汇总及pipelines简介
- 强化学习代码实战-04时序差分算法(Q-learning)
- 分块算法模板
- 代码面试最常用的10大算法(一)
- 【毕业设计_课程设计】基于 K-means 算法的校园微博热点话题发现系统(源码+论文)
- 机器学习中的流形学习算法 Manifold Learning
- 【算法/动态规划/股票问题】题解+详细备注(共6题)
- 华为OD机试 - 选座位(Python) | 机试题+算法思路+考点+代码解析 【2023】
- 关于C/C++中求最大公约数和最小公倍数的算法
- memcache的一致性hash算法使用
- leetcode算法191.位1的个数