Skip to content

Commit

Permalink
Cleanup the IA package sources.
Browse files Browse the repository at this point in the history
- Action
- Etat
- Noeud
- Probleme
  • Loading branch information
Prometheos2 committed Dec 9, 2019
1 parent bb03191 commit d5f8e6d
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 107 deletions.
20 changes: 2 additions & 18 deletions src/model/Ia/Action.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 08/12/2019
* Copyright (c) 09/12/2019
*
* Auteurs :
* - Behm Guillaume
Expand All @@ -18,22 +18,6 @@
public class Action {
private String val;


/**
* Constructeur
*/
public Action() {
}

/**
* Constructeur
*
* @param act
*/
public Action(String act) {
val = act;
}

// getteurs et setteurs

/**
Expand All @@ -50,7 +34,7 @@ public String getAction() {
*
* @param s
*/
public void setAction(String s) {
void setAction(String s) {
val = s;
}

Expand Down
87 changes: 19 additions & 68 deletions src/model/Ia/Etat.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

package model.Ia;

import model.Grid;
import model.Grids;
import model.Parameters;

Expand All @@ -23,7 +24,6 @@ public class Etat {
private Grids ensemble;
private String deplacement; // lettre entree en ligne de commande
private int scoreMax;
private int scoreGrid;

/**
* Constructeur
Expand All @@ -41,19 +41,17 @@ public Etat(Grids ensemble, String deplacement) {
this.ensemble = new Grids(ensemble.getGrids());
this.deplacement = deplacement;
this.scoreMax = ensemble.best();
this.scoreGrid = ensemble.scoreTotalGrille();
}

/**
* Fait une copie d'un etat existant
*
* @param ee
*/
public Etat(Etat ee) {
Etat(Etat ee) {
this.ensemble = new Grids(ee.getGrids().getGrids());
this.deplacement = ee.getDeplacement();
this.scoreMax = this.ensemble.best();
this.scoreGrid = this.ensemble.scoreTotalGrille();
}

/**
Expand All @@ -70,7 +68,7 @@ public Grids getGrids() {
*
* @return
*/
public String getDeplacement() {
String getDeplacement() {
return this.deplacement;
}

Expand All @@ -84,43 +82,6 @@ public int getScoreMax() {
return this.scoreMax;
}

/**
* Getter
*
* @return
*/
public int getScoreGrid() {
this.scoreGrid = ensemble.scoreTotalGrille();
return this.scoreGrid;
}

/**
* Setter
*
* @param ensemble
*/
public void setEnsembleGrile(Grids ensemble) {
this.ensemble = ensemble;
}

/**
* Setter
*
* @param dep
*/
public void setDeplacement(String dep) {
this.deplacement = dep;
}

/**
* Setter
*
* @param _scoreMax
*/
public void setScoreMax(int _scoreMax) {
this.scoreMax = _scoreMax;
}

/// --- METHODES --- ///

/**
Expand All @@ -134,17 +95,6 @@ public boolean estbut(Probleme pb) { //teste si l'état est égal à l'état but
return (pb.getGrids().best() == Parameters.GOAL);
}

/**
* Retourne vrai si l'etat passe en parametre est egal a celui qui appelle la methode
*
* @param e
*
* @return
*/
public boolean estegal(Etat e) {
return this.ensemble == e.getGrids() && this.deplacement.equals(e.getDeplacement());
}

/**
* Applique l'action passe en parametre
*
Expand Down Expand Up @@ -221,45 +171,46 @@ public Etat AppliqueAction(Action a, Grids grids) {
*
* @return
*/
public boolean valide(String direction) {
private boolean valide(String direction) {
boolean valide = false;
int indice = 0;
Grid[] grids = this.ensemble.getGrids();
switch (direction) {
case "d":
while (!valide && indice < this.ensemble.getGrids().length) {
valide = this.ensemble.right(this.ensemble.getGrids()[indice]);
while (!valide && indice < grids.length) {
valide = this.ensemble.right(grids[indice]);
indice++;
}
break;
case "q":
while (!valide && indice < this.ensemble.getGrids().length) {
valide = this.ensemble.left(this.ensemble.getGrids()[indice]);
while (!valide && indice < grids.length) {
valide = this.ensemble.left(grids[indice]);
indice++;
}
break;
case "z":
while (!valide && indice < this.ensemble.getGrids().length) {
valide = this.ensemble.up(this.ensemble.getGrids()[indice]);
while (!valide && indice < grids.length) {
valide = this.ensemble.up(grids[indice]);
indice++;
}
break;
case "s":
while (!valide && indice < this.ensemble.getGrids().length) {
valide = this.ensemble.down(this.ensemble.getGrids()[indice]);
while (!valide && indice < grids.length) {
valide = this.ensemble.down(grids[indice]);
indice++;
}
break;
case "r":
this.ensemble = new Grids(this.ensemble.reorganization(this.ensemble.getGrids()));
while (!valide && indice < this.ensemble.getGrids().length) {
valide = this.ensemble.down(this.ensemble.getGrids()[indice]);
this.ensemble = new Grids(this.ensemble.reorganization(grids));
while (!valide && indice < grids.length) {
valide = this.ensemble.down(grids[indice]);
indice++;
}
break;
default:
this.ensemble = new Grids(this.ensemble.reorganization(this.ensemble.getGrids()));
while (!valide && indice < this.ensemble.getGrids().length) {
valide = this.ensemble.up(this.ensemble.getGrids()[indice]);
this.ensemble = new Grids(this.ensemble.reorganization(grids));
while (!valide && indice < grids.length) {
valide = this.ensemble.up(grids[indice]);
indice++;
}
break;
Expand Down
20 changes: 1 addition & 19 deletions src/model/Ia/Noeud.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 08/12/2019
* Copyright (c) 09/12/2019
*
* Auteurs :
* - Behm Guillaume
Expand All @@ -23,14 +23,6 @@ public class Noeud {
private ArrayList<Action> sol;


/**
* Constructeur
*/
public Noeud() {
this.e = new Etat();
this.sol = null;
}

/**
* Fait une copie d'un noeud deja existant
*
Expand All @@ -51,7 +43,6 @@ public Noeud(Etat ee, ArrayList<Action> aa) {
*
* @return
*/

public Etat getetat() {
return (this.e);
}
Expand All @@ -65,15 +56,6 @@ public ArrayList<Action> getlisteaction() {
return (this.sol);
}

/**
* Setter
*
* @param ee
*/
public void setetat(Etat ee) {
this.e = ee;
}


/**
* Ajoute une action dans les solutions
Expand Down
4 changes: 2 additions & 2 deletions src/model/Ia/Probleme.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 08/12/2019
* Copyright (c) 09/12/2019
*
* Auteurs :
* - Behm Guillaume
Expand Down Expand Up @@ -59,7 +59,7 @@ public ArrayList<Action> getlisteactions() {
*
* @return
*/
public ArrayList<Action> setactions() {
private ArrayList<Action> setactions() {
ArrayList<Action> la = new ArrayList<>();
Action aa;
aa = new Action();
Expand Down

0 comments on commit d5f8e6d

Please sign in to comment.