Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
ProjetZZ1
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Marc BERET
ProjetZZ1
Commits
3c02b47a
Commit
3c02b47a
authored
Jun 30, 2022
by
maberet
Browse files
Options
Downloads
Patches
Plain Diff
commit d'une ia avec paramètres canon angles
parent
185aca9d
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
travail_de_groupe/jeu_appren_par_renfo/src/main.c
+2
-2
2 additions, 2 deletions
travail_de_groupe/jeu_appren_par_renfo/src/main.c
travail_de_groupe/jeu_appren_par_renfo/src/qlearn.c
+73
-77
73 additions, 77 deletions
travail_de_groupe/jeu_appren_par_renfo/src/qlearn.c
with
75 additions
and
79 deletions
travail_de_groupe/jeu_appren_par_renfo/src/main.c
+
2
−
2
View file @
3c02b47a
...
...
@@ -5,11 +5,11 @@ int game_state;
float
*****
Q
;
int
main
(){
float
*****
Q
=
allocateAndInitiateQ
();
int
i
=
10
;
//
int i= 10;
srand
(
time
(
NULL
));
// while (i>0){
traningAgent
(
10000
0
,
30
,
Q
);
traningAgent
(
10000
,
30
,
Q
);
// i--;}
//printf(" %d \n ", convertIntoZone(agent->x,agent->y));
...
...
This diff is collapsed.
Click to expand it.
travail_de_groupe/jeu_appren_par_renfo/src/qlearn.c
+
73
−
77
View file @
3c02b47a
...
...
@@ -372,12 +372,10 @@ void freeStack(stack_t *stack)
void
traningAgent
(
int
numberRun
,
int
numberStep
,
float
*****
Q
)
{
// pour avoir la bonne taille il faut diviser par block size
int
i
;
int
action
;
//
point_t canon ;
point_t
canon
;
point_t
dropPoint
;
int
canonZone
;
int
dropZone
;
// float angleH;
// float angleF;
int
zoneAngleH
;
int
zoneAngleF
;
int
agentZone
;
...
...
@@ -389,26 +387,27 @@ void traningAgent ( int numberRun, int numberStep, float *****Q) {// pour avoir
int
maxAction
;
stack
=
initStack
(
6000
);
int
j
,
k
,
l
,
m
,
n
;
int
n
,
p
;
n
=
0
;
while
(
n
<
numberRun
){
agent
=
initAgent
();
for
(
j
=
0
;
j
<
4
;
j
++
){
for
(
k
=
0
;
k
<
3
;
k
++
){
for
(
l
=
0
;
l
<
5
;
l
++
){
m
=
100
;
while
(
m
>
0
){
i
=
numberStep
;
agent
=
initAgent
();
zoneAngleF
=
l
;
zoneAngleH
=
k
;
canon
=
initCanon
(
canon
);
canonZone
=
convertIntoZoneCanon
(
canon
.
x
,
canon
.
y
);
dropPoint
=
initDropPoint
(
dropPoint
);
dropZone
=
convertIntoZone
(
dropPoint
.
x
,
dropPoint
.
y
);
canonZone
=
j
;
zoneAngleF
=
converterIntoAngleF
(
defineAngleF
(
canon
.
x
,
canon
.
y
,
dropPoint
.
x
,
dropPoint
.
y
));
zoneAngleH
=
converterIntoAngleH
(
defineAngleH
(
canon
.
x
,
canon
.
y
));
reward
=
0
;
i
=
numberStep
;
p
=
10
;
while
(
p
>
0
){
agent
=
initAgent
();
//printf (" %d \n ", m);
while
(
i
>
0
){
printf
(
"%d %d
\n
"
,
agent
->
x
,
agent
->
y
);
//
printf("%d %d \n ",agent->x ,agent->y );
action
=
takeAction
(
agent
->
x
,
agent
->
y
,
Q
,
canonZone
,
zoneAngleH
,
zoneAngleF
,
greedy
);
agentZone
=
convertIntoZone
(
agent
->
x
,
agent
->
y
);
line
.
receiverZone
=
agentZone
;
...
...
@@ -423,7 +422,7 @@ void traningAgent ( int numberRun, int numberStep, float *****Q) {// pour avoir
if
((
agentZone
==
dropZone
)){
break
;}
i
--
;
}
if
(
(
agentZone
!=
dropZone
)
){
action
=
takeAction
(
agent
->
x
,
agent
->
y
,
Q
,
canonZone
,
zoneAngleH
,
zoneAngleF
,
greedy
);
agentZone
=
convertIntoZone
(
agent
->
x
,
agent
->
y
);
...
...
@@ -459,13 +458,10 @@ void traningAgent ( int numberRun, int numberStep, float *****Q) {// pour avoir
LEARN_RATE
*
Q
[
agentZone
][
canonZone
][
zoneAngleH
][
zoneAngleF
][
maxAction
]
-
Q
[
line
.
receiverZone
][
line
.
shooterZone
][
line
.
angleHZone
][
line
.
angleFZone
][
line
.
action
]);
}
m
--
;
}
}
}
}
writeQ
(
Q
);
writeQ
(
Q
);
if
(
numberRun
%
10000
==
1
){
printf
(
" %d
\n
"
,
numberRun
);}
greedy
=
greedy
-
1
/
(
n
+
1
);
n
++
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment