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
Erwan BOISTEAU-DESDEVISES
projet-asd-3
Commits
55c310b4
Commit
55c310b4
authored
Nov 15, 2021
by
Julien POUILLART
Browse files
Suite règles témeraires
parent
d592e1b2
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/project/Plateau.java
View file @
55c310b4
...
...
@@ -96,29 +96,25 @@ public class Plateau {
}
public
void
colorierCasesBrave
(
Case
c
,
Couleur
couleur
){
public
void
colorierCasesBrave
(
Case
c
,
Joueur
player
){
Case
[]
voisinage
=
this
.
voisins
(
c
);
colorierCase
(
c
,
couleur
);
colorierCase
(
c
,
player
.
couleur
);
for
(
Case
x
:
voisinage
){
if
(
x
.
caseColoriee
()){
colorierCase
(
x
,
couleur
);
colorierCase
(
x
,
player
.
couleur
);
}
}
}
public
void
colorierCasesTemeraire
(
Case
c
,
C
ou
l
eur
couleu
r
){
public
void
colorierCasesTemeraire
(
Case
c
,
J
oueur
playe
r
){
Case
[]
voisinage
=
this
.
voisins
(
c
);
colorierCase
(
c
,
couleur
);
colorierCase
(
c
,
player
.
couleur
);
int
check
=
0
;
PetiteRegion
pregion
=
new
PetiteRegion
(
this
.
matrice
[
c
.
ligne
-
c
.
ligne
][
c
.
colonne
-
c
.
colonne
],
this
.
matrice
[
c
.
ligne
+
(
2
-
c
.
ligne
)][
c
.
colonne
+
(
2
-
c
.
colonne
)],
this
.
matrice
);
//En gros : on veut récuperer la petite région correspondant à c
QuadtreeNode
node
=
this
.
arbrePlateau
.
recherchePetiteRegion
(
c
.
ligne
,
c
.
colonne
);
PetiteRegion
pregion
=
(
PetiteRegion
)
node
.
getRegion
();
Case
[]
reg
=
pregion
.
getCases
();
...
...
@@ -129,18 +125,28 @@ public class Plateau {
}
if
(
check
==
9
){
// si toute la petite région est colorée
for
(
Case
alpha
:
reg
){
colorierCase
(
alpha
,
couleur
);
colorierCase
(
alpha
,
player
.
couleur
);
}
pregion
.
setAcquise
(
true
);
}
for
(
Case
x
:
voisinage
){
if
(
x
.
caseColoriee
()
&&
!(
x
.
estAcquise
())){
colorierCase
(
x
,
couleur
);
colorierCase
(
x
,
player
.
couleur
);
}
}
if
(
pregion
.
estAcquise
())
{
ReglesQuatreEtCinq
(
node
,
player
);
}
}
private
void
ReglesQuatreEtCinq
(
QuadtreeNode
reg
,
Joueur
player
)
{
QuadtreeNode
regsup
=
reg
.
getRegionSuperieure
();
}
public
void
colorierCase
(
Case
c
,
Couleur
couleur
)
{
...
...
src/project/Quadtree.java
View file @
55c310b4
...
...
@@ -27,6 +27,11 @@ public class Quadtree {
}
}
public
QuadtreeNode
recherchePetiteRegion
(
int
i
,
int
j
)
{
return
this
.
root
.
recherchePetiteRegion
(
i
,
j
);
}
public
QuadtreeNode
getRoot
()
{
// TODO Auto-generated method stub
...
...
src/project/QuadtreeNode.java
View file @
55c310b4
...
...
@@ -63,10 +63,38 @@ public class QuadtreeNode {
return
null
;
}
private
Region
rechercheRegion
(
Region
regionRecherchee
)
{
//TODO : recherche d'une region du plateau dans le quadtree
return
null
;
public
QuadtreeNode
recherchePetiteRegion
(
int
iCaseRecherchee
,
int
jCaseRecherchee
)
{
//TODO : recherche d'une case du plateau dans le quadtree
if
(
this
.
estFeuille
())
{
return
this
;
}
else
{
if
(!(
v1
==
null
)){
if
(
v1
.
region
.
contient
(
iCaseRecherchee
,
jCaseRecherchee
))
{
return
v1
.
recherchePetiteRegion
(
iCaseRecherchee
,
jCaseRecherchee
);
}
}
if
(!(
v2
==
null
)){
if
(
v2
.
region
.
contient
(
iCaseRecherchee
,
jCaseRecherchee
))
{
return
v2
.
recherchePetiteRegion
(
iCaseRecherchee
,
jCaseRecherchee
);
}
}
if
(!(
v3
==
null
)){
if
(
v3
.
region
.
contient
(
iCaseRecherchee
,
jCaseRecherchee
))
{
return
v3
.
recherchePetiteRegion
(
iCaseRecherchee
,
jCaseRecherchee
);
}
}
if
(!(
v4
==
null
)){
if
(
v4
.
region
.
contient
(
iCaseRecherchee
,
jCaseRecherchee
))
{
return
v4
.
recherchePetiteRegion
(
iCaseRecherchee
,
jCaseRecherchee
);
}
}
}
//code supposedly unreachable
return
null
;
}
public
void
initialiserDepuisMatrice
(
Case
[][]
cases
,
int
longueur
,
int
iBasGauche
,
int
jBasGauche
)
{
...
...
src/project/Region.java
View file @
55c310b4
...
...
@@ -6,6 +6,7 @@ public class Region {
private
Case
basGauche
;
private
boolean
acquise
;
private
boolean
coloriee
;
public
int
getLongueur
(){
return
(
this
.
getBasGauche
().
colonne
-
this
.
getHautDroite
().
colonne
+
1
);
// rajout de +1 car entre la région entre les colonnes 1 et 3 est de longueur 3, mais 3-1 = 2
...
...
@@ -28,7 +29,7 @@ public class Region {
public
boolean
estAcquise
()
{
// TODO Auto-generated method stub
return
fal
se
;
return
acqui
se
;
}
public
Case
getBasGauche
()
{
...
...
@@ -49,10 +50,6 @@ public class Region {
&&
jCaseRecherchee
<=
this
.
hautDroite
.
ligne
);
}
public
boolean
isAcquise
()
{
return
this
.
acquise
;
}
public
void
setAcquise
(
boolean
acquise
)
{
this
.
acquise
=
acquise
;
}
...
...
@@ -60,5 +57,14 @@ public class Region {
public
void
acquerir
()
{
this
.
acquise
=
true
;
}
public
boolean
estColoriee
()
{
return
coloriee
;
}
public
void
setColoriee
(
boolean
coloriee
)
{
this
.
coloriee
=
coloriee
;
}
}
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