Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Roux Antoine
AI_2048
Commits
3c57dc64
Commit
3c57dc64
authored
Jan 01, 2018
by
Antoine Roux
Browse files
changed my fitness, now achieves 4096 :)
parent
0394a073
Changes
1
Hide whitespace changes
Inline
Side-by-side
2048_ma_fitness.py
View file @
3c57dc64
...
...
@@ -160,10 +160,16 @@ class Grid (object) :
"""
fitnessArray
=
np
.
array
([[
8
,
4
,
2
,
1
],
[
16
,
8
,
4
,
2
],
[
32
,
16
,
8
,
4
],
[
64
,
32
,
16
,
8
]])
# fitnessArray = np.array([[8, 4, 2, 1],
# [16, 8, 4, 2],
# [32, 16, 8, 4],
# [64, 32, 16, 8]])
fitnessArray
=
np
.
array
([[
13
,
12
,
5
,
4
],
[
14
,
11
,
6
,
3
],
[
15
,
10
,
7
,
2
],
[
16
,
9
,
8
,
1
]])
# fitnessArray = np.array([[3, 5, 6, 2], #celui du test 2
# [1, 2, 7, 5],
...
...
@@ -192,21 +198,21 @@ arrayGrid1 = [[0, 0, 0, 0],
[
0
,
0
,
0
,
0
],
[
0
,
0
,
0
,
0
]]
arrayGrid2
=
[[
2
,
8
,
2
,
2
],
[
2
,
2
,
2
,
0
],
[
4
,
2
,
4
,
0
],
[
2
,
2
,
2
,
2
]]
# arrayGrid2 = [[2, 8, 2, 2],
# [2, 2, 2, 0],
# [4, 2, 4, 0],
# [2, 2, 2, 2]]
#
# arrayGrid3 = [[4, 0, 0, 0],
# [16, 4, 2, 0],
# [32, 2, 8, 0],
# [128, 32, 2, 0]]
arrayGrid3
=
[[
4
,
0
,
0
,
0
],
[
16
,
4
,
2
,
0
],
[
32
,
2
,
8
,
0
],
[
128
,
32
,
2
,
0
]]
MODE
=
"PLAY"
# MODE = "PLAY"
# MODE = "TEST"
MODE
=
"AI"
#
MODE = "MULTI_AI"
#
MODE = "AI"
MODE
=
"MULTI_AI"
##############################################
def
evaluateGrid
(
givenGrid
)
:
...
...
@@ -275,11 +281,11 @@ def single_AI() :
elif
direction2
==
3
:
direction2
=
0
##useful for debugging and seeing what is happening:
#
#
#useful for debugging and seeing what is happening:
# print(myGrid)
# print(fitnessArray)
# print(maxArray)
# print(direction2)
#
#
print(fitnessArray)
#
#
print(maxArray)
#
#
print(direction2)
# user_input = input()
myGrid
.
swipe
(
direction2
)
#mettre direction pour swiper sans avoir reverse l'array
...
...
@@ -330,14 +336,14 @@ if MODE == "AI" :
[
finishedGrid
,
rawScore
]
=
single_AI
()
endTime
=
time
.
time
()
print
(
"
\n
----- Partie finie -----"
)
print
(
"Temps écoulé :"
,
int
((
endTime
-
startTime
)
*
1000
),
"ms"
)
print
(
"Temps écoulé :"
,
int
((
endTime
-
startTime
)
*
1000
),
"ms
\n
"
)
# print("Valeur max :", evaluateGrid(finishedGrid))
print
(
Grid
(
finishedGrid
))
print
(
"------------------------"
)
if
MODE
==
"MULTI_AI"
:
startTime
=
time
.
time
()
nbrGames
=
2
00
nbrGames
=
10
00
listScores
=
[[],[]]
sumRawScores
=
0
for
k
in
range
(
nbrGames
)
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment