qlearn_0: change print_2d : background, delimiter, ...
This commit is contained in:
@@ -217,7 +217,7 @@ void printLine(char c, int l, bool prec) {
|
||||
printf("\033[%d;0%dm", 0, 1); // noir // vide
|
||||
if (prec) printf("%*c\n", 10, ' ');
|
||||
for (int i = 0; i < l; i++) printf("%c", c);
|
||||
printf("%*c\n", 10, ' ');
|
||||
printf("%*c||\n", 10, ' ');
|
||||
}
|
||||
void printLinec(char c, int l) {
|
||||
printLine(c, l, true);
|
||||
@@ -234,10 +234,12 @@ void code2dCoul(dimension *color, enum Content content) {
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
void gotoxy(int x, int y)
|
||||
{
|
||||
printf("%c[%d;%df", 0x1B, y, x);
|
||||
}
|
||||
#endif
|
||||
|
||||
void print_game_dim2(struct game *gm) {
|
||||
struct cell *cells = gm->cells;
|
||||
@@ -248,7 +250,10 @@ void print_game_dim2(struct game *gm) {
|
||||
long int *coord = malloc(2*sizeof(long int));
|
||||
int mult = dim->perm[0] * 14;
|
||||
char sep = '-';
|
||||
gotoxy(0, 10);
|
||||
//gotoxy(0, 10);
|
||||
gotoxy(0, 0);
|
||||
|
||||
printLinec('=',mult);
|
||||
for (long int j = 0; j < dim->perm[1]; j++) {
|
||||
for (long int i = 0; i < dim->perm[0]; i++) {
|
||||
long int cur = i + j * dim->perm[0];
|
||||
@@ -257,6 +262,7 @@ void print_game_dim2(struct game *gm) {
|
||||
//printf("s:%2d,(%d,%d),%2c|", cells[cur].rankPosition, cells[cur].pos.x, cells[cur].pos.y, cont_name[cells[cur].c]);
|
||||
printf("s:%2ld,(%ld,%ld),%2c|", cur, i , j , content_name[cells[cur].content]);
|
||||
}
|
||||
printf("%*c||", 10, ' ');
|
||||
printLinec(sep, mult);
|
||||
for (long int k = 0; k < ACTION_COUNT; k++) {
|
||||
for (long int i = 0; i < dim->perm[0]; i++) {
|
||||
@@ -271,7 +277,7 @@ void print_game_dim2(struct game *gm) {
|
||||
}
|
||||
printf("%2c: %8.4f |", action_name[k], cells[cur].Q[k]);
|
||||
}
|
||||
printf("%*c\n", 10, ' ');
|
||||
printf("%*c||\n", 10, ' ');
|
||||
}
|
||||
printLine(sep, mult, false);
|
||||
}
|
||||
@@ -292,7 +298,7 @@ void mainQlearning_game(struct game *gm){
|
||||
int random;
|
||||
long int NUMBER_EPISODE2 = (params->limit_EPISODES_number) * (params->limit_EPISODES_number);
|
||||
double proba_explor;
|
||||
//srand(time(NULL));
|
||||
srand(time(NULL));
|
||||
|
||||
for(long int k=0 ; k < params->limit_game_number; ++k){
|
||||
generate_game(gm);
|
||||
@@ -324,6 +330,7 @@ void mainQlearning_game(struct game *gm){
|
||||
|
||||
print_game_dim2(gm);
|
||||
|
||||
//getchar();
|
||||
usleep((gm->delay)->delay_between_episodes);
|
||||
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
//#include "tools_t/tools_t.h"
|
||||
#include "tools_t/tools_t.h"
|
||||
#include "dimension_t/dimension_t.h"
|
||||
#include "list_t/list_t.h"
|
||||
|
||||
|
||||
+6
-11
@@ -10,9 +10,10 @@ YTESTDIR=$(PWD)/../../ytest_t
|
||||
YPERMDIR=$(PWD)/../../ypermutation_t
|
||||
DIMDIR=$(PWD)/../../dimension_t
|
||||
LISTDIR=$(PWD)/../../list_t
|
||||
TOOLDIR=$(PWD)/../../ytools_t
|
||||
|
||||
INCLUDE_DIR=$(PWD)/../src
|
||||
CFLAGS=-I$(INCLUDE_DIR) -I$(YTESTDIR)/include_ytest/include -I$(YPERMDIR)/src -I$(DIMDIR)/src -I$(LISTDIR)/src
|
||||
CFLAGS=-I$(INCLUDE_DIR) -I$(YTESTDIR)/include_ytest/include -I$(YPERMDIR)/src -I$(DIMDIR)/src -I$(LISTDIR)/src -I$(TOOLDIR)/include
|
||||
LDFLAGS=-L$(YTESTDIR) -lytest #"-D DEBUG=1"
|
||||
|
||||
#SRC_DIR=$(ROOT_DIR)/src
|
||||
@@ -23,6 +24,7 @@ TEST_DIR=$(PWD)
|
||||
EXECSRC=$(NAME_TEST).c
|
||||
EXEC=launch_$(NAME_TEST)_m
|
||||
LISTSRC_O=$(LISTDIR)/src/list_t/list_t.o
|
||||
TOOLSRC_O=$(TOOLDIR)/src/tools_t/tools_t.o
|
||||
|
||||
FROZENLAKESRC=$(FROZENLAKEDIR)/src/Frozen_Lake.c
|
||||
FROZENLAKESRC_O=$(FROZENLAKESRC:.c=.o)
|
||||
@@ -34,7 +36,7 @@ DIMSRC_O=$(DIMDIR)/src/dimension_t/dimension_t.o
|
||||
|
||||
TOPTARGETS := all clean
|
||||
|
||||
DEPS=$(PERMSRC) $(DIMDIR) $(LISTDIR) $(YTESTDIR)
|
||||
DEPS=$(PERMSRC) $(DIMDIR) $(LISTDIR) $(YTESTDIR) $(TOOLDIR)
|
||||
|
||||
$(TOPTARGETS): $(DEPS)
|
||||
|
||||
@@ -42,14 +44,7 @@ $(DEPS):
|
||||
$(MAKE) -C $@ $(MAKECMDGOALS)
|
||||
|
||||
|
||||
#LISTSRC_O=$(LISTSRC:.c=.o)
|
||||
#SETTSRC_O=$(PWD)/../src/set_theoric_t/set_theoric_t.o
|
||||
#SETTSRC_O=$(SETTSRC:.c=.o)
|
||||
#TOOLSRC=$(TOOLDIR)/src/tools_t/tools_t.c
|
||||
#TOOLSRC_O=$(TOOLSRC:.c=.o)
|
||||
|
||||
#OBJ=$(SRC:.c=.o) $(FROZENLAKESRC_O)
|
||||
OBJ=$(FROZENLAKESRC_O) $(LISTSRC_O) $(PERMSRC_O) $(DIMSRC_O)
|
||||
OBJ=$(FROZENLAKESRC_O) $(LISTSRC_O) $(PERMSRC_O) $(DIMSRC_O) $(TOOLSRC_O)
|
||||
|
||||
LIB_YTEST=$(YTESTDIR)/libytest.so
|
||||
|
||||
@@ -58,7 +53,7 @@ all: $(EXEC) $(LIB_YTEST)
|
||||
$(EXEC): $(EXECSRC) $(OBJ)
|
||||
$(CC) -o $@ $^ $(CFLAGS) $(LDFLAGS)
|
||||
|
||||
$(FROZENLAKESRC_O): $(FROZENLAKESRC) $(LISTSRC_O) $(PERMSRC_O) $(DIMSRC_O)
|
||||
$(FROZENLAKESRC_O): $(FROZENLAKESRC) $(LISTSRC_O) $(PERMSRC_O) $(DIMSRC_O) $(TOOLSRC_O)
|
||||
$(CC) -o $@ -c $^ $(CFLAGS)
|
||||
|
||||
#$(LDFLAGS)
|
||||
|
||||
@@ -6,11 +6,11 @@
|
||||
|
||||
|
||||
TEST(igameRabbit ){
|
||||
size_t array[] = {4,4} ;
|
||||
size_t array[] = {6,6} ;
|
||||
dimension *dim = init_copy_dim(array,2);
|
||||
struct game_params * params = create_game_params(1,dim,3,3,1,200,200);
|
||||
struct game_params * params = create_game_params(4,dim,3,3,1,200,200);
|
||||
struct qlearning_params * qlearnParams = create_qlearning_params(0.85,0.99,1);
|
||||
struct delay_params * delay_game = create_delay_params(1000000, 200000);
|
||||
struct delay_params * delay_game = create_delay_params(100000, 20000);
|
||||
struct game * gm = create_game(params, qlearnParams, delay_game);
|
||||
|
||||
printDebug_dimension(gm->params->dim,"dimension game");
|
||||
|
||||
Reference in New Issue
Block a user