Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
HURE GABRIELLE
qui-est-ce
Commits
3fc83c50
Commit
3fc83c50
authored
May 13, 2020
by
Gabrielle Huré
Browse files
code fonctionne pour mode jeu 1 et 2 (et 3)? avec arbre terminé
parent
c2388b7f
Changes
2
Hide whitespace changes
Inline
Side-by-side
main.py
View file @
3fc83c50
...
...
@@ -16,9 +16,9 @@ Creation liste de capteurs et tags lu pour un exemple
tag_ok
=
[
"0001q"
,
"0002q"
,
"0003q"
,
"0004q"
,
"0005q"
,
"0006q"
,
"0007q"
,
"0001p"
,
"0002p"
,
"0003p"
,
"0004p"
,
"0005p"
,
"0006p"
,
"0007p"
,
"0008p"
]
tag_faux
=
[
"0001q"
,
""
,
"0001p"
,
"0003q"
,
""
,
"0004q"
,
"0003p"
,
"000
5q
"
,
"000
4p
"
,
"
0006q"
,
"0005p
"
,
"0007q"
,
"0006p"
,
"0008q"
,
"0007p"
]
"
0002q
"
,
"0001p"
,
"0003q"
,
"
0002p
"
,
"0004q"
,
"0003p"
,
"000
4p
"
,
"000
5q
"
,
"
"
,
"
"
,
"0007q"
,
"0006p"
,
"0008q"
,
"0007p"
]
capteurs
=
[]
for
i
in
range
(
1
,
16
):
capteurs
.
append
(
Capteur
(
i
,
tag_faux
[
i
-
1
]))
...
...
verification_mode_jeu_1.py
View file @
3fc83c50
...
...
@@ -92,9 +92,10 @@ class VerificationModeJeu1:
if
index
<
index_personnage
:
if
validite_branche
[
index
]
==
0
:
return
{},
False
if
self
.
liste_objects_lus
[
index
]
is
None
:
verification_question_personnage
[
index
]
=
-
1
return
verification_question_personnage
,
False
# if self.liste_objects_lus[index] is None:
# verification_question_personnage[index] = -1
# return verification_question_personnage, False
tag_question
=
self
.
liste_objects_lus
[
index
].
tag
if
(
personnage
.
dict_questions_reponse
[
tag_question
]
==
0
and
not
impaire_precedent
)
\
...
...
@@ -122,29 +123,34 @@ class VerificationModeJeu1:
for
index
in
validite_branche
:
if
0
<
index
<
index_personnage
:
self
.
resultat_leds
[
index
-
1
]
=
1
if
index
>
index_personnage
:
if
index
>
index_personnage
and
validite_branche
[
index
]
!=
-
1
:
self
.
resultat_leds
[
index
-
1
]
=
0
else
:
if
len
(
verification_question_personnage
)
==
0
:
# si branche comporte des élements qui ne doivent pas être de ce type
dernier_index_de_branche
=
list
(
validite_branche
.
keys
())[
-
1
]
dernier_index_de_branche
=
list
(
validite_branche
.
keys
())[
-
1
]
# pourquoi cette ligne ?
self
.
resultat_leds
[
index_personnage
-
1
]
=
0
for
index
in
validite_branche
:
if
index
!=
dernier_index_de_branche
:
self
.
resultat_leds
[
index
-
1
]
=
0
elif
-
1
in
verification_question_personnage
.
values
():
self
.
resultat_leds
[
index_personnage
-
1
]
=
-
1
for
index
in
validite_branche
:
if
0
<
index
<
index_personnage
:
self
.
resultat_leds
[
index
-
1
]
=
-
1
if
index
>
index_personnage
:
self
.
resultat_leds
[
index
-
1
]
=
0
# elif -1 in verification_question_personnage.values():
# self.resultat_leds[index_personnage - 1] = -1
# for index in validite_branche:
# if 0 < index < index_personnage:
# if validite_branche[index] == -1:
# self.resultat_leds[index - 1] = -1
# self.resultat_leds[index * 2] = -1
# self.resultat_leds[index * 2 + 1] = -1
#
# if index > index_personnage:
# self.resultat_leds[index - 1] = 0
else
:
# si branche comporte des élements qui sont du bon type mais qu'il y a des erreurs par rapport aux réponses aux questions
self
.
resultat_leds
[
index_personnage
-
1
]
=
0
for
index
in
validite_branche
:
if
0
<
index
<
index_personnage
:
self
.
resultat_leds
[
index
-
1
]
=
1
if
index
>
index_personnage
:
if
index
>
index_personnage
and
validite_branche
[
index
]
!=
-
1
:
self
.
resultat_leds
[
index
-
1
]
=
0
for
index_led
in
[
i
for
i
,
j
in
enumerate
(
self
.
resultat_leds
)
if
j
==
-
1
]:
# pour tous les index où les led == -1:
...
...
@@ -157,23 +163,3 @@ class VerificationModeJeu1:
if
(
index_led
+
1
)
in
range
(
debut
,
fin
):
# si (index led + 1) sur la dernière ligne
print
(
"est sur dernière ligne"
)
self
.
resultat_leds
[
index_led
]
=
0
# mettre led à index_led = 0
# else:
# print("n est pas sur dernière ligne")
# self.resultat_leds[index_led] = 1 # mettre led à index_led = 1
# cas où rien est posé a milieu de l'arbre !!!! alors toute la branche est à -1
if
__name__
==
'__main__'
:
capteurs
=
[]
for
i
in
range
(
1
,
16
):
tag
=
[
"000{}p"
.
format
(
i
),
"000{}q"
.
format
(
i
)][
i
<
8
]
capteurs
.
append
(
Capteur
(
i
,
tag
))
verif
=
VerificationModeJeu1
(
None
,
None
,
capteurs
)
print
(
"nb étage = {}"
.
format
(
verif
.
nb_etage
))
print
(
verif
.
calcul_nb_questions_nb_personnages
()[
0
],
verif
.
calcul_nb_questions_nb_personnages
()[
1
])
Write
Preview
Supports
Markdown
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