Merge branch 'master' of gitlab.isima.fr:audorival/gomoku
This commit is contained in:
@@ -1,7 +1,10 @@
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class GomokuBoard {
|
||||
|
||||
public class GomokuBoard{
|
||||
/** The firstcell in the board, at the top left of the board. */
|
||||
private GomokuCell firstCell;
|
||||
/** The width of the GomokuBoard.*/
|
||||
@@ -131,6 +134,41 @@ public class GomokuBoard {
|
||||
return output;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* This method return a Map of number aligned cells.
|
||||
* @param cell A cell.
|
||||
* @return Map of number aligned cells.
|
||||
*/
|
||||
public Map<Cardinal, Integer> countAlignedCells(GomokuCell cell){
|
||||
|
||||
Map<Cardinal, Integer> map = new HashMap<>();
|
||||
Map<Cardinal, Integer> mapColor = cell.getSameColorNeighbour();
|
||||
|
||||
map.put(Cardinal.N, mapColor.get(Cardinal.N)+mapColor.get(Cardinal.S)+1);
|
||||
map.put(Cardinal.W,mapColor.get(Cardinal.W)+mapColor.get(Cardinal.E)+1);
|
||||
map.put(Cardinal.NW, mapColor.get(Cardinal.NW)+mapColor.get(Cardinal.SE)+1);
|
||||
map.put(Cardinal.SW, mapColor.get(Cardinal.SW)+mapColor.get(Cardinal.NE)+1);
|
||||
|
||||
return map;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method return the number max of the aligned Cells.
|
||||
* @param mapColor A map of number aligned cells.
|
||||
* @return int, the number max of the aligned Cells.
|
||||
*/
|
||||
public int countMax(Map<Cardinal, Integer> mapColor){
|
||||
|
||||
Map<Cardinal, Integer> map = new HashMap<>();
|
||||
int max = 0;
|
||||
for (Map.Entry<Cardinal, Integer> entry : map.entrySet()) {
|
||||
if(entry.getValue() > max){
|
||||
max = entry.getValue();
|
||||
}
|
||||
}
|
||||
return max;
|
||||
}
|
||||
|
||||
//------------------Overides--------------------------
|
||||
|
||||
|
||||
Reference in New Issue
Block a user