get la somme des gomoku cell aligned
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
import java.util.EnumMap;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
/**
|
||||
@@ -39,12 +41,42 @@ public class GomokuCell{
|
||||
public EnumMap<Cardinal, GomokuCell> getAllNeighbour(){
|
||||
return neighbour;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the number of same colored neighbours in all direction.
|
||||
* @return The Map of neighbours.
|
||||
*/
|
||||
public Map<Cardinal, Integer> getSameColorNeighbour(){
|
||||
|
||||
Map<Cardinal, Integer> map = new HashMap<>();
|
||||
map.put(Cardinal.N, 0);
|
||||
map.put(Cardinal.W,0);
|
||||
map.put(Cardinal.NW, 0);
|
||||
map.put(Cardinal.SW, 0);
|
||||
map.put(Cardinal.S, 0);
|
||||
map.put(Cardinal.SE, 0);
|
||||
map.put(Cardinal.E, 0);
|
||||
map.put(Cardinal.NE, 0);
|
||||
|
||||
Color color = this.getState();
|
||||
|
||||
for (Map.Entry<Cardinal, Integer> entry : map.entrySet()) {
|
||||
|
||||
GomokuCell actualcell = this;
|
||||
while(this.getState() == actualcell.getNeighbour(entry.getKey()).getState())
|
||||
{
|
||||
entry.setValue(entry.getValue()+1);
|
||||
actualcell=actualcell.getNeighbour(entry.getKey());
|
||||
}
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the state.
|
||||
* @return The state of the current cell with one Color.
|
||||
*/
|
||||
public Color getSate(){
|
||||
public Color getState(){
|
||||
return this.state;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user