Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Fardale
Prog2
Commits
190e45df
Commit
190e45df
authored
May 27, 2015
by
Fardale
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Solveur démineur et correction unrualy
parent
88dfd8af
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
59 additions
and
1 deletion
+59
-1
boum.scala
boum.scala
+55
-0
unruly.scala
unruly.scala
+4
-1
No files found.
boum.scala
View file @
190e45df
...
...
@@ -111,6 +111,16 @@ class Demineur extends Jeu[MonBouton] {
if
(!
boutons
(
x
+
1
)(
y
+
1
).
mines
)
{
boutons
(
x
+
1
)(
y
+
1
).
incrContenu
}
}
}
var
perdu
=
clique_action_gauche
(
0
,
0
)
var
found
=
true
def
f
(
x
:
MonBouton
)
=
{
println
(
"prout"
)
var
plop
=
SuperNoob
(
x
.
getTheX
,
x
.
getTheY
)
perdu
=
plop
.
_1
;
found
=
found
||
plop
.
_2
}
while
(!
perdu
&&
!
victoire
&&
found
){
map_apply
(
f
,
boutons
)
}
if
(!
found
){
println
(
"plop"
)}
}
// Même fonction, mais avec la composante "random seed" en paramètre.
...
...
@@ -256,4 +266,49 @@ class Demineur extends Jeu[MonBouton] {
}
victoire
()
}
//solveur facile
def
SuperNoob
(
x
:
Int
,
y
:
Int
)={
var
result
=
false
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
})}
}
(
result
,
found
)
}
//vérifie si des nouvelles sol sont possible
def
checkmodif
(
x
:
Int
,
y
:
Int
)
:
Unit
=
{
var
voisin
=
voisinEtendu
(
x
,
y
)
if
(
noobitude
==
0
){
voisin
.
map
(
x
=>
if
(
boutons
(
x
.
_1
)(
x
.
_2
).
estLibre
&&
!
boutons
(
x
.
_1
)(
x
.
_2
).
possedeDrapeau
){
if
(
SuperNoob
(
x
.
_1
,
x
.
_2
).
_1
){
checkmodif
(
x
.
_1
,
x
.
_2
)}})
}
// if(noobitude == 1){
// voisin.map(x=>if(boutons(x._1)(x._2).estLibre && ! boutons(x._1)(x._2).possedeDrapeau){
// if(MiddleNoob(i,j)){checkmodif(i,j)}})
//
// }
// if(noobitude == 2){
// voisin.map((i,j)=>if(boutons(i)(j).estLibre() && ! boutons(i)(j).possedeDrapeau()){
// if(Noob(i,j)){checkmodif(i,j)}})}
}
}
unruly.scala
View file @
190e45df
...
...
@@ -170,6 +170,7 @@ class Unruly extends Jeu[MonBouton] {
// Code de base d'une action
def
theAction
(
i
:
Int
,
j
:
Int
,
c
:
Color
)
=
{
if
(
boutons
(
i
)(
j
).
enabled
){
if
(
boutons
(
i
)(
j
).
estColore
)
{
boutons
(
i
)(
j
).
desactive_couleur
()
nb_non_occupes
+=
1
...
...
@@ -179,18 +180,20 @@ class Unruly extends Jeu[MonBouton] {
boutons
(
i
)(
j
).
active_couleur
()
nb_non_occupes
-=
1
}
}
}
}
}
// Définition des conséquences d'un clic gauche de souris
def
clique_action_gauche
(
i
:
Int
,
j
:
Int
)
=
{
theAction
(
i
,
j
,
Color
.
black
)
println
(
nb_non_occupes
)
victoire
()
}
// Définiton des conséquences d'un clic droit de souris
def
clique_action_droit
(
i
:
Int
,
j
:
Int
)
=
{
theAction
(
i
,
j
,
Color
.
white
)
println
(
nb_non_occupes
)
victoire
()
}
...
...
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