[ARDUINO]Q-TABLE作り。
5312 ワード
I think the Q-Table is a important part of Reinforcement Learning or Q-Learning.
Row is States, Column is Action.
Code
int Q_table[3][4] = {};
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
rand_input();
view_table();
}
void view_table(){
Serial.println("Q-table");
for(int i = 0; i < 3; i++){
for(int j = 0; j < 4 ; j++){
Serial.print(Q_table[i][j]);
Serial.print("\t");
}
Serial.println();
}
}
void rand_input(){
Serial.println("input random number");
for(int i = 0; i < 3; i++){
for(int j = 0; j < 4 ; j++){
Q_table[i][j] = random(10,20);
Serial.print(Q_table[i][j]);
Serial.print("\t");
}
Serial.println();
}
delay(1000);
}
Result
int Q_table[3][4] = {};
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
rand_input();
view_table();
}
void view_table(){
Serial.println("Q-table");
for(int i = 0; i < 3; i++){
for(int j = 0; j < 4 ; j++){
Serial.print(Q_table[i][j]);
Serial.print("\t");
}
Serial.println();
}
}
void rand_input(){
Serial.println("input random number");
for(int i = 0; i < 3; i++){
for(int j = 0; j < 4 ; j++){
Q_table[i][j] = random(10,20);
Serial.print(Q_table[i][j]);
Serial.print("\t");
}
Serial.println();
}
delay(1000);
}
If you have any other nice code,
pls, do leave a comment below.
Dreamwalker
Author And Source
この問題について([ARDUINO]Q-TABLE作り。), 我々は、より多くの情報をここで見つけました https://qiita.com/Dreamwalker/items/2470750cd34bc51004c9著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .