Exemple #1
0
        protected HitBoard SaveHit(IEnumerable <HitBoard> boards, Hit hit)
        {
            if (hit.target.Equals(this))
            {
                return(null);
            }

            HitBoard selectedBoard = null;

            if (
                (features.HasFlag(AiFeatures.RememberOwnShots) && hit.attacker.Equals(this)) ||
                (features.HasFlag(AiFeatures.RememberRivalShots) && !hit.attacker.Equals(this))
                )
            {
                selectedBoard = boards.Where(b => b.Owner.Equals(this) && b.Rival.Equals(hit.target)).First();
                selectedBoard.Set(hit.coords, HitValues[(int)hit.effect]);
            }

            return(selectedBoard);
        }
Exemple #2
0
 protected static IEnumerable <int> GetCellIndexes(HitBoard board, params byte[] values)
 {
     return(board.Cells.Select((c, i) => new { val = c, idx = i }).Where(e => values.Contains(e.val)).Select(e => e.idx));
 }
Exemple #3
0
 protected static IEnumerable <int> GetUnknownCellsIdxs(HitBoard board)
 {
     return(board.Cells.Select((c, i) => new { cell = c, idx = i }).Where(e => e.cell == CELL_UNKNOWN).Select(e => e.idx));
 }