Merge branch 'master' of gitlab.isima.fr:audorival/gomoku

This commit is contained in:
Aubin DORIVAL
2025-03-31 11:03:47 +02:00
9 changed files with 254 additions and 27 deletions

View File

@@ -1,4 +1,6 @@
import java.util.EnumMap;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ExecutionException;
import java.util.List;
import java.util.ArrayList;
@@ -41,12 +43,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;
}