clickaction name and clickaction changed to work with agents
This commit is contained in:
parent
d3efcf8140
commit
70bbd4fdc3
|
|
@ -27,7 +27,7 @@ public class Simulator extends Thread {
|
|||
private boolean stopFlag;
|
||||
private boolean pauseFlag;
|
||||
private boolean loopingBorder;
|
||||
private boolean clickActionFlag;
|
||||
private int clickActionFlag;
|
||||
private int loopDelay = 150;
|
||||
private ArrayList<Integer> ruleSurviveCriteria= new ArrayList<Integer>();
|
||||
|
||||
|
|
@ -40,7 +40,7 @@ public class Simulator extends Thread {
|
|||
stopFlag=false;
|
||||
pauseFlag=false;
|
||||
loopingBorder=false;
|
||||
clickActionFlag=false;
|
||||
clickActionFlag=0;
|
||||
cells = new ArrayList<ArrayList<Cell>>();
|
||||
newCells = new ArrayList<ArrayList<Cell>>();
|
||||
|
||||
|
|
@ -277,16 +277,29 @@ public class Simulator extends Thread {
|
|||
//TODO : complete method
|
||||
//if clickActionFlag = true then create an agent
|
||||
//else if flag = false then change value of cell
|
||||
if(clickActionFlag) {
|
||||
switch (clickActionFlag) {
|
||||
case 0 :
|
||||
System.out.print(x );
|
||||
System.out.println(y);
|
||||
}else {
|
||||
System.out.println(getAliveNeighbors(x, y, LIFE_AREA_RADIUS)); //print nb of neighbours
|
||||
break;
|
||||
case 1 :
|
||||
if(getCell(x, y)==0) {
|
||||
setCell(x, y, 1);
|
||||
}else {setCell(x, y, 0);}
|
||||
break;
|
||||
case 2 :
|
||||
if(getCell(x, y)==0) {
|
||||
setCell(x, y, 1);
|
||||
}else {setCell(x, y, 0);}
|
||||
break;
|
||||
case 3 :
|
||||
if(getCell(x, y)==0) {
|
||||
setCell(x, y, 1);
|
||||
}else {setCell(x, y, 0);}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -463,7 +476,23 @@ public class Simulator extends Thread {
|
|||
|
||||
public void toggleClickAction() {
|
||||
//TODO : complete method
|
||||
clickActionFlag = !clickActionFlag;
|
||||
switch (clickActionFlag) {
|
||||
case 0:
|
||||
clickActionFlag++;
|
||||
break;
|
||||
case 1:
|
||||
clickActionFlag++;
|
||||
break;
|
||||
case 2:
|
||||
clickActionFlag++;
|
||||
break;
|
||||
case 3:
|
||||
clickActionFlag=0;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -539,7 +568,18 @@ public class Simulator extends Thread {
|
|||
public String clickActionName() {
|
||||
// TODO : initially return "sheep" or "cell"
|
||||
// depending on clickActionFlag
|
||||
return "";
|
||||
switch (clickActionFlag) {
|
||||
case 0:
|
||||
return "position";
|
||||
case 1:
|
||||
return "cell";
|
||||
case 2:
|
||||
return "sheep";
|
||||
case 3:
|
||||
return "wolf";
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue