y_nnn : change learn_to_drive and add some bash print
This commit is contained in:
@@ -130,6 +130,7 @@ struct print_params * create_print_params(float scale_x, float scale_y, struct
|
||||
pprint->delay = delay;
|
||||
pprint->string_space = malloc(LOG_LENTH+1);
|
||||
pthread_mutex_init(&(pprint->mut_printed), NULL);
|
||||
pprint->go_on = 1;
|
||||
|
||||
int i;
|
||||
for( i=0; i<LOG_LENTH; ++i)
|
||||
@@ -204,6 +205,15 @@ void free_delay_params (struct delay_params *dly_p){
|
||||
free(dly_p);
|
||||
}
|
||||
|
||||
int check_go_on_print_params(struct print_params *pprint){
|
||||
int ret=0;
|
||||
pthread_mutex_lock(&(pprint->mut_printed));
|
||||
ret=pprint->go_on;
|
||||
pthread_mutex_unlock(&(pprint->mut_printed));
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void free_print_params (struct print_params *pprint){
|
||||
free(pprint->string_space);
|
||||
pthread_mutex_destroy(&(pprint->mut_printed));
|
||||
@@ -388,15 +398,15 @@ void learn_to_drive(struct RL_agent * rlAgent){
|
||||
//struct print_params * pprint = rlAgent->pprint;
|
||||
char msg[100];
|
||||
|
||||
pthread_t threadPrint;
|
||||
pthread_create(&threadPrint, NULL, runPrint, (void*)rlAgent);
|
||||
////pthread_t threadPrint;
|
||||
////pthread_create(&threadPrint, NULL, runPrint, (void*)rlAgent);
|
||||
|
||||
// while(true){
|
||||
for(size_t index_episode = 0; index_episode < qlParams->number_episodes; ++index_episode){
|
||||
reset(car);
|
||||
qlStatus->nb_training_after_updated_weight_in_target = 0;
|
||||
qlStatus->index_episode = index_episode;
|
||||
while(true){
|
||||
while(!is_ending(qlStatus) /*true*/){
|
||||
++(qlStatus->nb_episodes);
|
||||
++(qlStatus->nb_training_after_updated_weight_in_target);
|
||||
action = select_action(rlAgent);
|
||||
@@ -435,6 +445,6 @@ void learn_to_drive(struct RL_agent * rlAgent){
|
||||
pthread_mutex_unlock(qlStatus->mut_ending);
|
||||
// }
|
||||
|
||||
pthread_join(threadPrint, NULL);
|
||||
////pthread_join(threadPrint, NULL);
|
||||
}
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
|
||||
//float d_reLU(float x);
|
||||
|
||||
extern char *action_name[8];
|
||||
|
||||
struct qlearning_params {
|
||||
float gamma;
|
||||
@@ -67,8 +68,11 @@ struct print_params {
|
||||
float scale_y;
|
||||
struct delay_params *delay;
|
||||
char *string_space;//[LOG_LENTH];
|
||||
int go_on;
|
||||
};
|
||||
|
||||
int check_go_on_print_params(struct print_params *pprint);
|
||||
|
||||
struct networks_qlearning {
|
||||
config_layers *config;
|
||||
neurons_TYPE_FLOAT *main_net;
|
||||
@@ -136,5 +140,9 @@ void train_qlearning(struct RL_agent * rlAgent,
|
||||
// long reward;
|
||||
|
||||
void learn_to_drive(struct RL_agent * rlAgent);
|
||||
int is_ending(struct status_qlearning *qlStatus);
|
||||
|
||||
///char *fileNameDateScore(char * pre, char* post,size_t score);
|
||||
///int select_action(struct RL_agent * rlAgent);
|
||||
|
||||
#endif /* __LEARNING_VEHICLE__C_H____ */
|
||||
|
||||
@@ -370,7 +370,8 @@ void goto_xy(int x, int y)
|
||||
}
|
||||
|
||||
|
||||
static struct winsize w;
|
||||
//static
|
||||
struct winsize w;
|
||||
|
||||
void init_win(){
|
||||
ioctl(1, TIOCGWINSZ, &w);
|
||||
|
||||
@@ -130,4 +130,8 @@ float distance2_coordinate(coordinate *c0, coordinate *c1);
|
||||
void print2D_blocks(struct blocks *blk, float scale_x, float scale_y, char pad);
|
||||
void print2D_blocks_withPoint(struct blocks *blk, float scale_x, float scale_y, char pad, coordinate *coordPoint);
|
||||
|
||||
extern struct winsize w;
|
||||
void init_win();
|
||||
struct blocks * block_neighbord_Point(coordinate *coord, float *radius );
|
||||
|
||||
#endif /* __VEHICLE__C_H__ */
|
||||
|
||||
Reference in New Issue
Block a user