From 3f6892516aa4a0841835413f455f9246563a76d6 Mon Sep 17 00:00:00 2001 From: Andrei Ionut Vaduva Date: Sat, 10 Mar 2018 15:23:05 +0100 Subject: [PATCH] A* completo --- Practica 1/bin/aStar/Board$1.class | Bin 1283 -> 1283 bytes Practica 1/bin/aStar/Board$2.class | Bin 805 -> 805 bytes Practica 1/bin/aStar/Board$3.class | Bin 754 -> 1567 bytes Practica 1/bin/aStar/Board.class | Bin 11271 -> 11939 bytes Practica 1/bin/aStar/Star$2.class | Bin 1599 -> 1879 bytes Practica 1/bin/aStar/Star.class | Bin 8452 -> 9575 bytes Practica 1/bin/dataStructures/Cell.class | Bin 2519 -> 2714 bytes Practica 1/bin/dataStructures/Data.class | Bin 831 -> 703 bytes Practica 1/src/aStar/Board.java | 340 +++++++++++++++++++---- Practica 1/src/aStar/Star.java | 311 +++++++++++++-------- Practica 1/src/dataStructures/Cell.java | 38 ++- Practica 1/src/dataStructures/Data.java | 8 +- 12 files changed, 508 insertions(+), 189 deletions(-) diff --git a/Practica 1/bin/aStar/Board$1.class b/Practica 1/bin/aStar/Board$1.class index d253ce3b037437bf88f19f8798f3f86be07e260f..5cd02c101d6d92b3fa9312982ad379b8033d6d2a 100644 GIT binary patch delta 45 zcmZqXYUbJ?#=^w7f3gHil@#M41`)=?3>u6_81xyBG8i!)V=!hs&S1@Wa`GCMZ~z9L B3;F;6 delta 45 zcmZqXYUbJ?#=^w#e6j>fl@!A(1`&qW3>pk?81xz5G8i$uV=!iT&tT2)aq=3LZ~z`N B4Ke@# diff --git a/Practica 1/bin/aStar/Board$2.class b/Practica 1/bin/aStar/Board$2.class index b1db33e5a9d23e6d44e130e781f785fbe4ce89e8..5c9d76aebc2bc93059e6c1ab857d141fcfc5a16d 100644 GIT binary patch delta 29 lcmZ3=wv=tdWF{uYvy-PXxp6UGVBluF$iUBdY4TGh2LOwq2`~Tv delta 29 lcmZ3=wv=tdWF{ttual=Txp6W4VBlu>$-vL>Yw}Yj2LO`B3CsWh diff --git a/Practica 1/bin/aStar/Board$3.class b/Practica 1/bin/aStar/Board$3.class index 0773d003b19a28897013ff4fda62fe9c96887909..d5386ea4b2780a6ad68034644cb3f43ee7944307 100644 GIT binary patch literal 1567 zcmaJ>+j0{}5IrNw7G909Fjz4*cMDj_1Yt}7$6R7Nh8ScZF)PANUIuz(M zH{Gash&)zXT#gHDSW#Zl(Vi#JSFI^Sr(xYO^-xEZDKZnJ^MvcW=9Iu*yY2G2@Y1|M zW-6%ZE(r8UWU+x)noaiMT-Uz}wx+bvGuCA-aH0v^6nzyhGJF?g=kZW-!u@k#U4dpmG zii$@`=k{bvGkkH6#1M*2+%d|m9XG=f1olbnhfTmp8!n*{=(j&27~{(l!;H@o{%oK; z3!kEr#X*71>l8)e5Jm*L+-OpTq00p(Ij@oODqN-_Z~H$9s0WCVb9+|(6syajj!GQE zak{^(&DGdhobKlm&68BxP=*<&*B_uz!m-ASfYwqY8PVM-t5#Td+gHU`VzdK2y&jr zMTtw?ik*I7+#5er`aB5Cc~0Uor?kd-gst-uSK6$HInxC$HF>e-f_muaGcI?r6_4ye z=1omH?K@r&QEs!^+ze_GKkx{1m;9$dp1K{af?~fi3YH3bf*j1ji@n zkL_DAkhr=}ju<;xevFL^4Gd`o*6Z5`R%!|BW&6924T7m{H+f)Pxbm$6<^Trz7O01L>hY`WW(jBs4wR zF-@D94X@&}2F8-*i3U!SB~GA$FIVx^DlRmoD3Cjde~}X}P!KOMAYNg=c-=z6UL#@S zYm!b-B%0(T@?sKsuo?NAX5?=v^3`UrUM`e)gB)=!(8qirm1+qzxE5$I36#b)N-Bj# Td`IsLHQe|3kycECD@MP!>e@@D delta 186 zcmbQw^NE$~)W2Q(7#J8#7_>HWB{5DGViMz*XAogz;LI#`N-QeMOf8yh%cL=RH?x)q zJA)b{19xI@Nn(+{Q+{Gm3J-(EC^M)4X%+@m R26YBaAd3qq#|Wf>000qG8xa5i diff --git a/Practica 1/bin/aStar/Board.class b/Practica 1/bin/aStar/Board.class index 6dfc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yQ9J08^ z0No_pqx_ifNN^iVt`~C@Ou`Y)OfdnE(41II6Z5J;6R6 zyhL&&a;poG4VMU8jSrEcm&lSYkxhRhMK6&R5?Sp+M0$=WQo`phk)tq63-DsyC)QdQ zEa`88_0S(H<;B_{)`Kos(hUUb5j&t$MBlQjNcv@%&}-}lU;OYBdIGQ7tM7kge|(K1 zPo6j@At}?Ks&S_;ZL;~5*pnWz8$Dt}e2f&H9J8P4q-+LTEDQ~0BG78z2)`?xip;we cnUvD{&nE1YMunZwRCb)^o9q;qsWN~2AMH(K%K!iX diff --git a/Practica 1/bin/dataStructures/Data.class b/Practica 1/bin/dataStructures/Data.class index 36b3957b52c6df57a8ba7250d037116be346c645..b6a244defb2f16aa9ab5d8cebde12dc6148c90b4 100644 GIT binary patch literal 703 zcmZuuOHaZ;7@RGI3RVzM@cp;}8hi1k@uJ~G^q?WpTPdrS)RL6eU*$m)iHQe)fIrGO zyP#3hG}(Ty`DSMK^XvTsz#+CR7y{M48@rcrlz4Fx$&qu$)PgCnIB*|bCvd|%=b|@| zUM!Hk9VTI4K->tJo(uwk<<1QLl;tCV+_4|}@rl4{<0f^a+2xMYVP6)I!GeuEiUOHN zvzrIGZDf&CQN@OZIe}8g59N9C(38=X+Y2N+ouTIjT{rSoJ}sK@y+2A(rCd>!bthvb zP@vvurpn@sKWa~GQVoq-qaVylBNd{Y6fTEJthD{W0YSspvtpC00=Y*Qm`UnORVfnU|2?t85d|8p(90P zkf4s0DUHLw>SbH6C_ghWpqA%!v8Wf?lY!|%z8}_DQ5ye(OHVW4N-B6A8&mKJsSHKc d+WY6LpsO{iuIml8$<(i(oO*ul5ZKg=Ti*pNa+d%A literal 831 zcmZuv%Wl(96r5{2c9WVmC69)-p_GD@7(_PgK;0BoiWI@3D2whK=Tcm`j^x;gk75B5 z5fTeNfR94VxegCS-uOIxX3os9fByRZ1Hf}U_FyTr=3yRQ=2;QtMW&adS1dg^3eB7F zLpVyp^m_DWcB7+Qp%$le{ZT=UnZH{U>74nMf)nW^QRqxIxX#&rq2RuZ(>OmlAJH*x&a%zKDNvx^de=G^tqS{tVWmRO#LJ7)F?G@N7BS=U9Bl9)-trGg zZ&1l0CL5QFB8&7zEK=*T{+XN^C-h|VtJtu_7&A*un@G!yHBM~9=kpG$gzp{3cJK{5 z!Ql#f!P6C5L4SqL7lYd8vr80sGKUOxqIZaI5#M7sDDk+516E`*`;^IKqh&JDVsqyq zj@Fw;j51XVzM}P+i3M5Znr72bi%1b%QY-XvpB<6?KX~uc2Dn`bKE{IzaAy path) { @@ -315,7 +554,6 @@ public void pathPaint(ArrayList path) { int y = c.getY(); if(x == startX && y == startY) { markSpecialCell(startX, startY, new Color(0,0,153)); - } else if (x == goalX && y == goalY) { markSpecialCell(goalX, goalY, new Color(128,255,0)); @@ -331,8 +569,8 @@ public void repaintDefaultMatrix(Cell matrix[][]) { for(int i = 1; i<= N_ROWS; i++) { for(int j = 1; j <= N_COLS; j++) { Cell c = matrix[i][j]; - if(!c.getCell().getText().equals("")) { - this.matrix[i][j].isBarrier(); + if(c.isBarrier()) { + this.matrix[i][j].setBarrier(); } } } @@ -355,11 +593,11 @@ public JButton getStart() { } public JTextField getStartXtxt() { - return startXtxt; + return txtStartX; } public JTextField getStartYtxt() { - return startYtxt; + return txtStartY; } public int getN_COLS() { @@ -371,11 +609,11 @@ public int getN_ROWS() { } public JTextField getxGoal() { - return xGoal; + return txtGoalX; } public JTextField getyGoal() { - return yGoal; + return txtGoalY; } public void setXs(int startX) { diff --git a/Practica 1/src/aStar/Star.java b/Practica 1/src/aStar/Star.java index 4f73182..0b3d7b4 100644 --- a/Practica 1/src/aStar/Star.java +++ b/Practica 1/src/aStar/Star.java @@ -53,10 +53,8 @@ public int compare(Cell c1, Cell c2) { }); } - - public ArrayList play() { + public void play() { boolean fail = false; - boolean hijoMejor = false; //Celda de inicio Cell c = matrix[startX][startY]; if(c.getCell().getText().equals("")) {// Si no es un obstaculo @@ -66,9 +64,9 @@ public ArrayList play() { c.setH(stim); c.setG(0); c.setF(stim); + c.setFather(null); add(c); } - //3 3 es el fin while(!fail) { //Si hay en abierta hay elems meto el primero en cerrada y lo borro if(this.open.size() > 0 ) { @@ -82,162 +80,188 @@ public ArrayList play() { //Si en cerrada es meta se acaba el proceso if(this.close.get(this.close.size()-1).getX() == goalX && this.close.get(this.close.size()-1).getY() == goalY) { fail = true; - hijoMejor = false; } //Si no es meta en cerrada se meten sus hijos else { - if(hijoMejor) { - this.close.remove(this.close.size()-1); - } Cell a = this.close.get(this.close.size()-1); - hijoMejor = getChildrens(a.getX(), a.getY()); + getChildrens(a.getX(), a.getY()); } } - return close; } //Mete en abierta todos los nodos hijos de la casilla x y - private boolean getChildrens(int x, int y) { + private void getChildrens(int x, int y) { Cell m = matrix[x][y]; double sTwo = Math.sqrt(2); double mg = m.getG(); - boolean hijoMejor = false; + //down - if(x+1 <= N) { - if(matrix[x+1][y].getCell().getText().equals("")) { - Cell c = new Cell(); - c.setX(x+1); - c.setY(y); - c.setCell(matrix[x+1][y].getCell()); - double g = matrix[x+1][y].getG(); - c.setG(mg + g + 1); - - double a = ((x+1)-goalX); - double b = (y-goalY); - double stim = Math.sqrt((Math.pow(a, 2) + Math.pow(b,2))); - c.setH(stim);//stim es la distancia estimada desde este hijo al objetivo - c.setF(c.getG() + stim); - Data d = existsCell(this.open, x+1, y); - if(d.isFound() && d.getCell().getH() < c.getH()) {//si encuentro en abierta a un hijo nuevo - hijoMejor=true;//borro al padre de cerrada y meto al hijo en cerrada y lo quito de abierta - } - else { - Data d2 = existsCell(this.close, x+1,y); - if(!d2.isFound()) { - add(c); - matrix[x+1][y] = c; - } - } + if(x+1 <= N && !matrix[x+1][y].isBarrier()) { + Cell c = new Cell(); + c.setX(x+1); + c.setY(y); + c.setG(mg + 1); + + double a = ((x+1)-goalX); + double b = (y-goalY); + double stim = Math.sqrt((Math.pow(a, 2) + Math.pow(b,2))); + + c.setH(stim);//stim es la distancia estimada desde este hijo al objetivo + c.setF(c.getG() + stim); + + //si no tenia padre, le pongo padre + if(matrix[x+1][y].getFather() == null) { + c.setFather(m); + } + Data d = existsCell(this.open, x+1, y); + Data d2 = existsCell(this.close, x+1, y); + + if(!d.isFound() && !d2.isFound()) { + add(c); + matrix[x+1][y] = c; + } + + else if (d.isFound() && d.getCell().getG() >= c.getG()) { + d.getCell().setFather(m); + d.getCell().setG(m.getG() + 1); } } //down right - if(x+1 <= N && y+1 <= M && matrix[x+1][y+1].getCell().getText().equals("")) { + if(x+1 <= N && y+1 <= M && !matrix[x+1][y+1].isBarrier()) { + Cell c = new Cell(); c.setX(x+1); c.setY(y+1); - double g = matrix[x+1][y+1].getG(); - c.setG(mg + g + sTwo); - + c.setG(mg + sTwo); + double a = ((x+1) - goalX); double b = ((y+1) - goalY); double stim = Math.sqrt((Math.pow(a, 2) + Math.pow(b, 2))); + c.setH(stim); c.setF(c.getG() + stim); + Data d = existsCell(this.open, x+1, y+1); - if(d.isFound() && d.getCell().getH() < c.getH()) {//Si el nuevo nodo, es decir, c tiene un coste mejor que ini se actualiza, sino se descarta - hijoMejor=true; + Data d2 = existsCell(this.close, x+1, y+1); + + if(matrix[x+1][y+1].getFather() == null) { + c.setFather(m); } - else { - Data d2 = existsCell(this.close, x+1,y+1); - if(!d2.isFound()) { - add(c); - matrix[x+1][y+1] = c; - } + + if(!d.isFound() && !d2.isFound()) { + add(c); + matrix[x+1][y+1] = c; + } + + else if ( d.isFound() && d.getCell().getG() > c.getG()) { + d.getCell().setFather(m); + d.getCell().setG(m.getG() + sTwo); } } //down left - if(x+1 <= N && y-1 > 0 && matrix[x+1][y-1].getCell().getText().equals("")) { + if(x+1 <= N && y-1 > 0 && !matrix[x+1][y-1].isBarrier()) { + Cell c = new Cell(); c.setX(x+1); c.setY(y-1); - double g = matrix[x+1][y-1].getG(); - c.setG(mg + g + sTwo); + c.setG(mg + sTwo); + double a = ((x+1) - goalX); double b = ((y-1) - goalY); double stim = Math.sqrt(Math.pow(a, 2) + Math.pow(b, 2)); + c.setH(stim); c.setF(c.getG() + stim); + Data d = existsCell(this.open, x+1, y-1); - if(d.isFound() && d.getCell().getH() < c.getH()) {//Si el nuevo nodo, es decir, c tiene un coste mejor que ini se actualiza, sino se descarta - hijoMejor=true; + Data d2 = existsCell(this.close, x+1, y-1); + + if(matrix[x+1][y-1].getFather() == null) { + c.setFather(m); + } - else { - Data d2 = existsCell(this.close, x+1,y-1); - if(!d2.isFound()) { - add(c); - matrix[x+1][y-1] = c; - } + + if(!d.isFound() && !d2.isFound()) { + add(c); + matrix[x+1][y-1] = c; + } + + else if ( d.isFound() && d.getCell().getG() > c.getG()) { + d.getCell().setFather(m); + d.getCell().setG(m.getG() + sTwo); } + } //right - if(y+1 <= M && matrix[x][y+1].getCell().getText().equals("")) { + if(y+1 <= M && !matrix[x][y+1].isBarrier()) { Cell c = new Cell(); c.setX(x); c.setY(y+1); - double g = matrix[x][y+1].getG(); + c.setG(mg + 1); - c.setG(mg + g + 1); double a = (x - goalX); double b = ((y+1) - goalY); double stim = Math.sqrt((Math.pow(a, 2) + Math.pow(b, 2))); + c.setH(stim); c.setF(c.getG() + stim); + Data d = existsCell(this.open, x, y+1); - if(d.isFound() && d.getCell().getH() < c.getH()) {//Si el nuevo nodo, es decir, c tiene un coste mejor que ini se actualiza, sino se descarta - hijoMejor=true; + Data d2 = existsCell(this.close, x, y+1); + + if(matrix[x][y+1].getFather() == null) { + c.setFather(m); } - else { - Data d2 = existsCell(this.close, x,y+1); - if(!d2.isFound()) { - add(c); - matrix[x][y+1] = c; - } + + if(!d.isFound() && !d2.isFound()) { + add(c); + matrix[x][y+1] = c; } + + else if ( d.isFound() && d.getCell().getG() > c.getG()) { + d.getCell().setFather(m); + d.getCell().setG(m.getG() + 1); + } + } //left - if(y-1 >0 && matrix[x][y-1].getCell().getText().equals("")) { - + if(y-1 >0 && !matrix[x][y-1].isBarrier()) { + Cell c = new Cell(); c.setX(x); c.setY(y-1); - double g = matrix[x][y-1].getG(); - c.setG(mg + g + 1); - + c.setG(mg +1); + double a = (x - goalX); double b = ((y-1) - goalY); double stim = Math.sqrt((Math.pow(a, 2) + Math.pow(b, 2))); + c.setH(stim); c.setF(c.getG() + stim); + Data d = existsCell(this.open, x, y-1); - if(d.isFound() && d.getCell().getH() < c.getH()) {//Si el nuevo nodo, es decir, c tiene un coste mejor que ini se actualiza, sino se descarta - hijoMejor=true; + Data d2 = existsCell(this.close, x, y-1); + + if(matrix[x][y-1].getFather() == null) { + c.setFather(m); } - else { - - Data d2 = existsCell(this.close, x,y-1); - if(!d2.isFound()) { - add(c); - matrix[x][y-1] = c; - } + + if(!d.isFound() && !d2.isFound()) { + add(c); + matrix[x][y-1] = c; + } + + else if ( d.isFound() && d.getCell().getG() > c.getG()) { + d.getCell().setFather(m); + d.getCell().setG(m.getG() + 1); } } //up - if(x-1 >0 && matrix[x-1][y].getCell().getText().equals("")) { + if(x-1 >0 && !matrix[x-1][y].isBarrier()) { Cell c = new Cell(); c.setX(x-1); c.setY(y); - double g = matrix[x-1][y].getG(); - c.setG(mg + g + 1); + c.setG(mg + 1); double a = ((x-1) - goalX); double b = (y - goalY); @@ -245,85 +269,97 @@ private boolean getChildrens(int x, int y) { c.setH(stim); c.setF(c.getG() + stim); Data d = existsCell(this.open, x-1, y); - if(d.isFound() && d.getCell().getH() < c.getH()) {//Si el nuevo nodo, es decir, c tiene un coste mejor que ini se actualiza, sino se descarta - hijoMejor=true; + Data d2 = existsCell(this.close, x-1, y); + + if(matrix[x-1][y].getFather() == null) { + c.setFather(m); } - else { - Data d2 = existsCell(this.close, x-1,y); - if(!d2.isFound()) { - add(c); - matrix[x-1][y] = c; - } + + if(!d.isFound() && !d2.isFound()) { + add(c); + matrix[x-1][y] = c; + } + + else if ( d.isFound() && d.getCell().getG() > c.getG()) { + d.getCell().setFather(m); + d.getCell().setG(m.getG() + 1); } } //up right - if(x-1 >0 && y+1 <= M && matrix[x-1][y+1].getCell().getText().equals("")) { + if(x-1 >0 && y+1 <= M && !matrix[x-1][y+1].isBarrier()) { Cell c = new Cell(); c.setX(x-1); c.setY(y+1); - double g = matrix[x-1][y+1].getG(); - c.setG(mg + g + sTwo); + c.setG(mg + sTwo); double a = ((x-1) - goalX); double b = ((y+1) - goalY); double stim = Math.sqrt((Math.pow(a, 2) + Math.pow(b, 2))); c.setH(stim); c.setF(c.getG() + stim); + Data d = existsCell(this.open, x-1, y+1); - if(d.isFound() && d.getCell().getH() < c.getH()){//Si el nuevo nodo, es decir, c tiene un coste mejor que ini se actualiza, sino se descarta - hijoMejor=true; + Data d2 = existsCell(this.close, x-1, y+1); + + if(matrix[x-1][y+1].getFather() == null) { + c.setFather(m); } - else { - Data d2 = existsCell(this.close, x-1,y+1); - if(!d2.isFound()) { - add(c); - matrix[x-1][y+1] = c; - } + + if(!d.isFound() && !d2.isFound()) { + add(c); + matrix[x-1][y+1] = c; + } + + else if ( d.isFound() && d.getCell().getG() > c.getG()) { + d.getCell().setFather(m); + d.getCell().setG(m.getG() + sTwo); } } //up left - if(x-1>0 && y-1>0 && matrix[x-1][y-1].getCell().getText().equals("")) { + if(x-1>0 && y-1>0 && !matrix[x-1][y-1].isBarrier()) { Cell c = new Cell(); c.setX(x-1); c.setY(y-1); - double g = matrix[x-1][y-1].getG(); - c.setG(mg + g + sTwo); + c.setG(mg + sTwo); + double a = ((x-1) - goalX); double b = ((y-1) - goalY); double stim = Math.sqrt((Math.pow(a, 2) + Math.pow(b, 2))); c.setH(stim); c.setF(c.getG() + stim); + Data d = existsCell(this.open, x-1, y-1); - if(d.isFound() && d.getCell().getH() < c.getH()) {//Si el nuevo nodo, es decir, c tiene un coste mejor que ini se actualiza, sino se descarta - hijoMejor=true; + Data d2 = existsCell(this.close, x-1, y-1); + + if(matrix[x-1][y-1].getFather() == null) { + c.setFather(m); } - else { - Data d2 = existsCell(this.close, x-1,y-1); - if(!d2.isFound()) { - add(c); - matrix[x-1][y-1] = c; - } + + if(!d.isFound() && !d2.isFound()) { + add(c); + matrix[x-1][y-1] = c; } + else if ( d.isFound() && d.getCell().getG() > c.getG()) { + d.getCell().setFather(m); + d.getCell().setG(m.getG() + sTwo); + } } - return hijoMejor; } private Data existsCell(ArrayList list, int x, int y){ boolean ok = false; Cell found = null; - int index = -1; int i = 0; while(i path = play(); + play(); + ArrayList path = new ArrayList(); + getPath(close.get(close.size()-1), path); board.pathPaint(path); + //board.pathPaint(posibleCamino); } catch(NumberFormatException ex) { JOptionPane.showMessageDialog(new JFrame(),err,"Error, formato incorrecto",JOptionPane.ERROR_MESSAGE); @@ -374,6 +413,32 @@ public void actionPerformed(ActionEvent e) { JOptionPane.showMessageDialog(new JFrame(),err,excep.getMessage(),JOptionPane.ERROR_MESSAGE); } } + + }); } + + private void getPath(Cell c, ArrayList path) { + if(c != null) { + path.add(c); + getPath(c.getFather(), path); + } + } + + public void ready2() { + String err = "Los datos introducidos son incorrectos!"; + try{ + play(); + ArrayList path = new ArrayList(); + getPath(close.get(close.size()-1), path); + board.pathPaint(path); + //board.pathPaint(posibleCamino); + } + catch(NumberFormatException ex) { + JOptionPane.showMessageDialog(new JFrame(),err,"Error, formato incorrecto",JOptionPane.ERROR_MESSAGE); + } + catch(Exception excep) { + JOptionPane.showMessageDialog(new JFrame(),err,excep.getMessage(),JOptionPane.ERROR_MESSAGE); + } + } } diff --git a/Practica 1/src/dataStructures/Cell.java b/Practica 1/src/dataStructures/Cell.java index e04bc82..7ba7ecd 100644 --- a/Practica 1/src/dataStructures/Cell.java +++ b/Practica 1/src/dataStructures/Cell.java @@ -12,10 +12,13 @@ public class Cell { private double g; private double h; private double f; + private Cell father; + private boolean isBarrier; public Cell() { this.cell = new JButton(); this.cell.setBackground(new Color(255,255,204)); + isBarrier = false; } public Cell(int x, int y) { @@ -23,6 +26,7 @@ public Cell(int x, int y) { this.y = y; this.cell = new JButton(); this.cell.setBackground(new Color(255,255,204)); + isBarrier = false; } public void mark(Color c) { @@ -41,15 +45,11 @@ public JButton getCell() { return cell; } - public void isBarrier() { + public void setBarrier() { this.cell.setBackground(new java.awt.Color(0, 0, 0)); - this.cell.setFont(new java.awt.Font("Verdana", 0, 16)); - this.cell.setForeground(new java.awt.Color(255, 0, 0)); - this.cell.setText("X"); - } - - public void setCell(JButton cell) { - this.cell = cell; + isBarrier = true; + //this.cell.setFont(new java.awt.Font("Verdana", 0, 16)); + //this.cell.setForeground(new java.awt.Color(255, 0, 0)); } public double getG() { @@ -99,4 +99,26 @@ else if (this.h == c2.getH()) { public void setDefaultColor() { this.cell.setBackground(new Color(255,255,204)); } + + public void setFather(Cell father) { + this.father = father; + } + + public Cell getFather() { + return this.father; + } + + public boolean isBarrier() { + return this.isBarrier; + } + + public void setStart() { + // TODO Auto-generated method stub + this.cell.setBackground(new Color(0,0,153)); + } + + public void setGoal() { + // TODO Auto-generated method stub + this.cell.setBackground(new Color(128,255,0)); + } } diff --git a/Practica 1/src/dataStructures/Data.java b/Practica 1/src/dataStructures/Data.java index 256a741..82226a2 100644 --- a/Practica 1/src/dataStructures/Data.java +++ b/Practica 1/src/dataStructures/Data.java @@ -2,14 +2,12 @@ public class Data { - private int index; private boolean found; private Cell cell; - public Data(boolean found, Cell cell, int index) { + public Data(boolean found, Cell cell) { this.found = found; this.cell = cell; - this.index = index; } public Cell getCell() { @@ -20,10 +18,6 @@ public boolean isFound() { return found; } - public int getIndex() { - return index; - } - public void setCell(Cell cell) { this.cell = cell; }