Merge branch 'master' of gitlab.isima.fr:audorival/gomoku
This commit is contained in:
@@ -1,5 +1,4 @@
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.EnumMap;
|
import java.util.EnumMap;
|
||||||
@@ -235,20 +234,7 @@ public class GomokuBoard {
|
|||||||
* @param cell A cell.
|
* @param cell A cell.
|
||||||
* @return Map of number aligned cells.
|
* @return Map of number aligned cells.
|
||||||
*/
|
*/
|
||||||
public Map<Cardinal, Integer> countAlignedCells(GomokuCell cell) {
|
public EnumMap<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;
|
|
||||||
}
|
|
||||||
|
|
||||||
public EnumMap<Cardinal, Integer> countAlignedCellsv2(GomokuCell cell) {
|
|
||||||
|
|
||||||
EnumMap<Cardinal, Integer> map = new EnumMap<>(Cardinal.class);
|
EnumMap<Cardinal, Integer> map = new EnumMap<>(Cardinal.class);
|
||||||
|
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ public class Human extends Player {
|
|||||||
|
|
||||||
int x = 0, y = 0;
|
int x = 0, y = 0;
|
||||||
boolean pass = false;
|
boolean pass = false;
|
||||||
|
GomokuCell cell = null;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
|
|
||||||
@@ -61,7 +62,8 @@ public class Human extends Player {
|
|||||||
}
|
}
|
||||||
} while (!pass);
|
} while (!pass);
|
||||||
|
|
||||||
pass = board.get(x, y).isPlayable();
|
cell = board.get(y, x);
|
||||||
|
pass = cell == null ? false : cell.isPlayable();
|
||||||
if (!pass) {
|
if (!pass) {
|
||||||
System.out.println("Cette case n'est pas jouable !");
|
System.out.println("Cette case n'est pas jouable !");
|
||||||
}
|
}
|
||||||
@@ -69,6 +71,6 @@ public class Human extends Player {
|
|||||||
|
|
||||||
System.out.println("Vous avez saisi : " + x + ", " + y);
|
System.out.println("Vous avez saisi : " + x + ", " + y);
|
||||||
|
|
||||||
return board.get(x, y);
|
return cell;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user