public bool[] GetShotsAroundPlayer(Player player) { bool[] result = new bool[Globals.numShotOptions]; Coord start = player.location; Coord checkLocation; int idx = 0; bool count; foreach (Coord t in Coord.shotTransforms) { checkLocation = start.Clone(); checkLocation = Coord.Add(checkLocation, t); count = IsOnBoard(checkLocation) ? true : false; result[idx] = count; idx++; } return(result); }
public Player Clone() { Player cloned = new Player(number, strategy); cloned.score = score; cloned.health = health; if (location != null) { cloned.location = location.Clone(); } if (program != null) { Move[] moves = new Move[Globals.numMoves]; for (int i = 0; i < Globals.numMoves; i++) { if (program[i] != null) { moves[i] = program[i].Clone(); } } } return(cloned); }
public int[] GetSpaceAroundPlayer(Player player) { int[] result = new int[Globals.numMoveOptions]; Coord start = player.location; Coord checkLocation; int idx = 0; int count; foreach (Coord transform in Coord.moveTransforms) { count = 0; checkLocation = start.Clone(); checkLocation = Coord.Add(checkLocation, transform); while (IsOnBoard(checkLocation) && !IsHoleLocation(checkLocation) && !IsPlayerLocation(checkLocation)) { checkLocation = Coord.Add(checkLocation, transform); count++; } result[idx] = count; idx++; } return(result); }