diff --git a/src/Characters/Robot.java b/src/Characters/Robot.java index 598e215..6d09776 100644 --- a/src/Characters/Robot.java +++ b/src/Characters/Robot.java @@ -1,9 +1,124 @@ package Characters; +import java.util.ArrayList; +//import java.util.Random; + +import javax.swing.JOptionPane; + +import Environnement.*; +import Objects.Effects; + public class Robot extends Personnage { - protected Robot(String name, int[] coordinate) { + public Robot(String name, int[] coordinate) { super(name, coordinate); } + + public Mouvements jouer(Map m){ + Mouvements move=this.compare(this.getCoordinate().get(0), this.choix(m).get(0)); + return move; + } + + public boolean estPossible(int x,int y,Map m){ + JOptionPane.showInputDialog((m.getGrid().length+" "+ m.getGrid()[0].length).toString()); + Object [][] grille=new Object[][] {m.getGrid()}; + if (grille[x][y]==Effects.IMPASSABLE){ + return false; + } + return true; + } + + public int [] creerTab(int x,int y){ + int [] t=new int [] {x,y}; + return t; + } + + public ArrayList coupsPossibles(int [] co,Map m) { + ArrayList coupsValables=new ArrayList (); + if (this.estPossible(co[0]+1,co[1], m)){ + coupsValables.add(creerTab(co[0]+1, co[1])); + }else if (this.estPossible(co[0],co[1]+1, m)){ + coupsValables.add(creerTab(co[0], co[1]+1)); + }else if (this.estPossible(co[0]-1,co[1], m)){ + coupsValables.add(creerTab(co[0]-1, co[1])); + }else if (this.estPossible(co[0],co[1]-1, m)){ + coupsValables.add(creerTab(co[0], co[1]-1)); + } + return coupsValables; + } + + public ArrayList casesAutour(Map m){ + ArrayList t =this.coupsPossibles(this.getCoordinate().get(0),m); + ArrayList t2 = new ArrayList<> (); + for (int i=0;i fusion(ArrayList t, ArrayList t2){ + for (int [] e :t2){ + t.add(e); + } + return t; + } + + public ArrayList choix(Map m){ + ArrayList cases=casesAutour(m); + ArrayList > w=new ArrayList<>(); + for (int i=0;i max=w.get(0); + for (ArrayList e :w){ + if (e.size()>max.size()){ + max=e; + } + } + return max; + } + + public Mouvements compare(int[] t,int[] t2){ + if (t[0]>t2[0]){ + System.out.println("s"); + return Mouvements.BAS; + }else if (t[0]t2[1]){ + System.out.println("d"); + return Mouvements.DROITE; + } + return null; + } + + public ArrayList killDouble(ArrayList t){ + for (int i=0;i