コード例 #1
0
        public DraughtsSummary(DraughtsState draughtsState)
        {
            foreach (System.Drawing.Point place in draughtsState.Board.PlacesAndNeighbors.Keys)
            {
                if (draughtsState.Board[place] != null)
                {
                    Results[draughtsState.Board[place].Value]++;
                }
            }
            byte max = Results.Values.Max();

            if (!Results.All(a => a.Value == max))
            {
                Winner = Results.First(a => a.Value == max).Key;
            }
        }
コード例 #2
0
 public override void Execute(DraughtsState state)
 {
     state.Board[Point]            = default;
     state.Board[PointTargetToHit] = default;
     state.Board[PointTarget]      = PlayerType;
 }
コード例 #3
0
        public DraughtsActionHit(DraughtsPlayerType playerType, Point point, Vector vector, DraughtsState state) : base(playerType, point, vector)
        {
            Vector[] neighbors = state.Board.PlacesAndNeighbors[point];
            PointTargetToHit = new Point(point.X + vector.X, point.Y + vector.Y);
            PointTarget      = new Point(point.X + vector.X * 2, point.Y + vector.Y * 2);
            DraughtsPlayerType enemy = PlayerType == DraughtsPlayerType.Black ? DraughtsPlayerType.White : DraughtsPlayerType.Black;

            if (!neighbors.Contains(vector) ||
                !state.Board.PlacesAndNeighbors[PointTargetToHit].Contains(vector) ||
                playerType != state.Board[point] ||
                state.Board[PointTargetToHit] != enemy ||
                state.Board[PointTarget] != default)
            {
                IsAllowed = false;
            }
            else
            {
                IsAllowed = true;
            }
        }
コード例 #4
0
        public DraughtsActionMove(DraughtsPlayerType playerType, Point point, Vector vector, DraughtsState state) : base(playerType, point, vector)
        {
            IsEnd       = true;
            PointTarget = new Point(point.X + vector.X, point.Y + vector.Y);
            Vector[] neighbors = state.Board.PlacesAndNeighbors[point];

            if (!neighbors.Contains(vector) ||
                playerType != state.Board[point] ||
                state.Board[PointTarget] != default ||
                PlayerType == DraughtsPlayerType.Black && vector.X == -1 ||
                PlayerType == DraughtsPlayerType.White && vector.X == 1)
            {
                IsAllowed = false;
            }
            else
            {
                IsAllowed = true;
            }
        }
コード例 #5
0
 public abstract void Execute(DraughtsState state);
コード例 #6
0
ファイル: DraughtsPlayer.cs プロジェクト: TomekDex/Inz
 public override async Task <DraughtsMove> NextMove(DraughtsState state, List <DraughtsMove> allowedMoves)
 {
     return(allowedMoves[random.Next(allowedMoves.Count)]);
 }
コード例 #7
0
 private DraughtsState(DraughtsState state)
 {
     CurentPlayer = state.CurentPlayer;
     Players      = state.Players;
     Board        = (DraughtsBoard)state.Board.Clone();
 }