Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions Main.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@

public class Main {

public static void main (String[] args) {
Plateau jeu = new Plateau();
//System.out.println(jeu.toString());
Coordonne start = new Coordonne(0,0);
Coordonne goal = new Coordonne(14,9);
PathFinding p = new PathFinding(start,goal);
p.setTab(jeu.getTab());
System.out.println(p);
p.findPath();
System.out.println("\n" + p.getPath());
}

}
66 changes: 66 additions & 0 deletions Plateau.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@

public class Plateau {
private Base B = new Base("B");
private Base b = new Base("b");
private Object[][] tab;

public Plateau () {
this.tab= new Object[10][15];
for(int i=0; i<tab.length; i++)
for (int j=0; j<tab[0].length; j++)
this.tab[i][j]= new Character(' ');
this.tab[0][0] = B;
this.tab[this.tab.length-1][this.tab[0].length-1]= b;
this.tab[4][6] = new Obstacle(4,6);
this.tab[4][5] = new Obstacle(4,5);
this.tab[4][7] = new Obstacle(4,7);
this.tab[4][8] = new Obstacle(4,8);
this.tab[4][9] = new Obstacle(4,9);
this.tab[4][10] = new Obstacle(4,10);
this.tab[5][5] = new Obstacle(5,5);
this.tab[6][5] = new Obstacle(6,5);
this.tab[4][11] = new Obstacle(4,11);
this.tab[7][5] = new Obstacle(6,5);
this.tab[8][5] = new Obstacle(6,5);
this.tab[9][5] = new Obstacle(6,5);
this.tab[4][12] = new Obstacle(4,12);
this.tab[4][12] = new Obstacle(4,13);
this.tab[4][14] = new Obstacle(4,14);
}

public Object[][] getTab() {
return this.tab;
}

public String toString () {
String ligne = "+";
for (int j=0; j<tab[0].length; j++) {
ligne+="---+";
}
String msg = ligne + "\n";
for(int i=0; i<tab.length; i++) {
for (int j=0; j<tab[0].length; j++) {
msg+="| "+tab[i][j].toString()+" ";
if (j+1 == tab[0].length) {
msg+= "|";
}
}
msg+="\n"+ligne+"\n";
}
return msg;
}

public void add(Robots r, int idx) {
if (idx<0) B.add(r);
else b.add(r);
this.tab[0][0] = B;
this.tab[this.tab.length-1][this.tab[0].length-1]= b;
}

public void moove(int idxY, int idxX , int mooveToX, int mooveToY) {
if (this.tab[mooveToX][mooveToY].toString().equals(" ") && java.lang.Math.abs(mooveToX-idxX) == 1 && java.lang.Math.abs(mooveToY-idxY) == 1) {
this.tab[mooveToX][mooveToY] = this.tab[idxX][idxY];
this.tab[idxX][idxY] = new Character(' ');
}
}
}
48 changes: 48 additions & 0 deletions Robots.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
public class Robots {
protected String affichage;
protected int portee, deplacement, energie, regeneration, degat, coutAttaque, coutDeplacement;

public Robots (String affich, int po, int dep, int energie, int degat, int coutAtt, int coutDep) {
this.affichage=affich;
this.portee = po;
this.regeneration = 2;
this.deplacement =dep;
this.energie=energie;
this.degat=degat;
this.coutAttaque=coutAtt;
this.coutDeplacement=coutDep;
}

String getAffich() {
return this.affichage;
}

int getEnergie() {
return this.energie;
}

int getPortee() {
return this.portee;
}

int getDeplacement(){
return this.deplacement;
}

int getRegeneration(){
return this.regeneration;
}

int getDegat() {
return this.degat;
}

int getCoutAttaque() {
return this.coutAttaque;
}

int getCoutDeplacement(){
return this.coutDeplacement;
}

}
7 changes: 7 additions & 0 deletions Tireur.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

public class Tireur extends Robots {

public Tireur(String affich, int po, int dep, int energie, int degat, int coutAtt, int coutDep) {
super(affich, po, dep, energie, degat, coutAtt, coutDep);
}
}
1 change: 1 addition & 0 deletions test
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
public