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
Fardale
Prog2
Commits
cc844eb6
Commit
cc844eb6
authored
May 27, 2015
by
Fardale
Browse files
dernier correctif
parent
190e45df
Changes
3
Hide whitespace changes
Inline
Side-by-side
boum.scala
View file @
cc844eb6
...
...
@@ -63,6 +63,8 @@ class Demineur extends Jeu[MonBouton] {
boutons
(
i
)(
j
).
enabled
=
true
}
}
m_trouvees
=
0
c_restantes
=
tailleX
*
tailleY
-
nb_mines
}
// Réactive la variable de premier coup
...
...
@@ -113,14 +115,20 @@ class Demineur extends Jeu[MonBouton] {
}
var
perdu
=
clique_action_gauche
(
0
,
0
)
var
found
=
true
var
cmpt
=
0
def
f
(
x
:
MonBouton
)
=
{
println
(
"prout"
)
var
plop
=
SuperNoob
(
x
.
getTheX
,
x
.
getTheY
)
var
plop
=
noobitude
match
{
case
0
=>
SuperNoob
(
x
.
getTheX
,
x
.
getTheY
)
case
_
=>
(
true
,
false
)
}
perdu
=
plop
.
_1
;
found
=
found
||
plop
.
_2
}
while
(!
perdu
&&
!
victoire
&&
found
){
while
(!
perdu
&&
!
victoire
&&
found
&&
cmpt
<
10000
){
found
=
false
map_apply
(
f
,
boutons
)
cmpt
+=
1
}
if
(!
found
){
println
(
"plop"
)}
if
((
perdu
||
!
found
)
&&
noobitude
==
0
){
initialise
}
else
(
redemarre
())
}
// Même fonction, mais avec la composante "random seed" en paramètre.
...
...
@@ -139,6 +147,23 @@ class Demineur extends Jeu[MonBouton] {
for
((
vx
,
vy
)
<-
voisin
){
if
(!
boutons
(
vx
)(
vy
).
mines
)
{
boutons
(
vx
)(
vy
).
incrContenu
}}
}
var
perdu
=
clique_action_gauche
(
0
,
0
)
var
found
=
true
var
cmpt
=
0
def
f
(
x
:
MonBouton
)
=
{
var
plop
=
noobitude
match
{
case
0
=>
SuperNoob
(
x
.
getTheX
,
x
.
getTheY
)
case
_
=>
(
true
,
false
)
}
perdu
=
plop
.
_1
;
found
=
found
||
plop
.
_2
}
while
(!
perdu
&&
!
victoire
&&
found
&&
cmpt
<
10000
){
found
=
false
map_apply
(
f
,
boutons
)
cmpt
+=
1
}
if
((
perdu
||
!
found
)
&&
noobitude
==
0
){
initialise
(
n
+
1
)}
else
(
redemarre
())
}
// Propagation du dévoilement des cases vides
...
...
@@ -247,7 +272,7 @@ class Demineur extends Jeu[MonBouton] {
// Affichage des drapeaux
def
clique_action_droit
(
x
:
Int
,
y
:
Int
)
=
{
if
(
boutons
(
x
)(
y
).
enabled
==
true
)
{
if
(
boutons
(
x
)(
y
).
enabled
==
true
&&
boutons
(
x
)(
y
).
estLibre
)
{
boutons
(
x
)(
y
).
icon
=
new
ImageIcon
(
getClass
.
getResource
(
"case_drapeau.png"
))
boutons
(
x
)(
y
).
enabled
=
false
boutons
(
x
)(
y
).
chgLibre
...
...
@@ -273,26 +298,26 @@ class Demineur extends Jeu[MonBouton] {
var
found
=
false
var
voisin
=
voisinEtendu
(
x
,
y
)
var
count
=
0
voisin
.
map
(
x
=>
if
(
boutons
(
x
.
_1
)(
x
.
_2
).
estLibre
||
boutons
(
x
.
_1
)(
x
.
_2
).
possedeDrapeau
){
count
+=
1
})
if
(
count
=
=
boutons
(
x
)(
y
).
getContenu
){
found
=
true
println
(
"mines"
)
voisin
.
map
(
x
=>
if
(
boutons
(
x
.
_1
)(
x
.
_2
)
.
estLibre
){
result
=
clique_action_droit
(
x
.
_1
,
x
.
_2
)
||
result
})}
else
{
count
=
0
voisin
.
map
(
x
=>
if
(!
boutons
(
x
.
_1
)(
x
.
_2
).
possedeDrapeau
){
count
+=
1
})
if
(
count
==
8
-
boutons
(
x
)(
y
).
getContenu
){
found
=
true
println
(
"pasmines"
)
voisin
.
map
(
x
=>
if
(
boutons
(
x
.
_1
)(
x
.
_2
).
estLibre
){
result
=
clique_action_gauche
(
x
.
_1
,
x
.
_2
)
||
result
})
}
if
(!
boutons
(
x
)(
y
).
mines
){
voisin
.
map
(
x
=>
if
(
boutons
(
x
.
_1
)(
x
.
_2
).
estLibre
||
boutons
(
x
.
_1
)(
x
.
_2
).
possedeDrapeau
){
count
+
=
1
})
if
(
count
==
boutons
(
x
)(
y
).
getContenu
){
voisin
.
map
(
x
=>
if
(
boutons
(
x
.
_1
)(
x
.
_2
).
estLibre
){
result
=
clique_action_droit
(
x
.
_1
,
x
.
_2
)
||
result
found
=
true
})}
else
{
count
=
0
voisin
.
map
(
x
=>
if
(!
boutons
(
x
.
_1
)(
x
.
_2
).
possedeDrapeau
){
count
+=
1
})
if
(
count
==
voisin
.
length
-
boutons
(
x
)(
y
).
getContenu
){
voisin
.
map
(
x
=>
if
(
boutons
(
x
.
_1
)(
x
.
_2
).
estLibre
){
result
=
clique_action_gauche
(
x
.
_1
,
x
.
_2
)
||
result
found
=
true
})}
}
}
(
result
,
found
)
(
result
,
found
)
}
//vérifie si des nouvelles sol sont possible
...
...
boutons.scala
View file @
cc844eb6
...
...
@@ -33,9 +33,10 @@ class MonBouton(protected val x : Int, protected val y : Int) extends Button {
def
mines
=
contenu
==
9
def
reset
=
def
reset
=
{
libre
=
true
drapeau
=
false
}
// Gestion de la couleur du bouton
...
...
unruly.scala
View file @
cc844eb6
...
...
@@ -98,7 +98,12 @@ class Unruly extends Jeu[MonBouton] {
boutons
(
i
)(
j
).
desactive_couleur
}
}
var
borne
=
(
tailleX
*
tailleY
)/
3
var
borne
=
0
difficulte
match
{
case
0
=>
borne
=
(
tailleX
*
tailleY
)/
3
case
1
=>
borne
=
(
tailleX
*
tailleY
)/
3
case
2
=>
borne
=
(
tailleX
*
tailleY
)/
3
}
var
x
=
Random
.
nextInt
(
tailleX
)
var
y
=
Random
.
nextInt
(
tailleY
)
var
k
=
Random
.
nextBoolean
...
...
@@ -123,7 +128,6 @@ class Unruly extends Jeu[MonBouton] {
boutons
(
x
)(
y
).
chgIconEtEnable
(
im
,
false
)
nb_non_occupes
=
nb_non_occupes
-
1
}
println
(
"Après construction : "
+
nb_non_occupes
)
if
(!
solveur
())
{
redemarre
();
initialise
}
else
{
nettoyage
()
}
}
...
...
@@ -253,8 +257,8 @@ class Unruly extends Jeu[MonBouton] {
for
(
j
<-
0
to
tailleY
-
1
){
if
(!
boutons
(
i
)(
j
).
estColore
)
{
var
t
=
sol_trivial
(
i
,
j
)
if
(
t
.
_2
)
{
println
(
"Zbraa !"
);
return
false
}
if
(
t
.
_1
)
{
if
(
checkmodif
(
i
,
j
))
{
println
(
"Zbrout !"
);
return
false
}
}
if
(
t
.
_2
)
{
return
false
}
if
(
t
.
_1
)
{
if
(
checkmodif
(
i
,
j
))
{
return
false
}
}
}
}}
if
(
victoire
())
{
return
true
}
...
...
@@ -262,7 +266,7 @@ class Unruly extends Jeu[MonBouton] {
difficulte
match
{
case
0
=>
limite
=
4
case
1
=>
limite
=
(
tailleX
*
tailleY
)/
3
case
2
=>
limite
=
(
tailleX
*
tailleY
)/
2
case
2
=>
limite
=
(
tailleX
*
tailleY
)/
3
}
if
(
nb_non_occupes
>
limite
)
{
println
(
"pas assez : interruption"
);
false
}
else
{
...
...
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