Пример #1
0
 public static ObservableCollection<Move> AllAbsoluteDefenseMoves(ObservableCollection<Move> moves)
 {
     ObservableCollection<Move> defenseMoves = moves;// AllDefenseMoves(moves);
     ObservableCollection<Move> possible = new ObservableCollection<Move>();
     ObservableCollection<Move> possible2 = new ObservableCollection<Move>();
     int rating = This.Game.CurrentPlayer.PiecesUnderAttack.TotalRating();
     int lowestRating = rating;
     int lowestRating2 = rating;
     foreach (Move move in defenseMoves)
     {
         using (Simulator simulator = new Simulator(move))
         {
             int newRating = This.Game.CurrentPlayer.PiecesUnderAttack.TotalRating();
             if (newRating < lowestRating)
             {
                 lowestRating = newRating;
                 possible.Add(move);
             }
             if (newRating <= lowestRating2)
             {
                 lowestRating2 = newRating;
                 possible2.Add(move);
             }
         }
     }
     if (possible.Count > 0) return possible;
     else return possible2;
 }
Пример #2
0
 public static ObservableCollection<Move> AllWinningOrEqualAttackMoves(ObservableCollection<Move> moves)
 {
     ObservableCollection<Move> possible = new ObservableCollection<Move>();
     ObservableCollection<Move> attackMoves = AllAttackMoves(moves);
     foreach (Move move in attackMoves)
     {
         using (Simulator simulator = new Simulator(move))
         {
             bool add = true;
             foreach (Move returnMove in This.Game.OppositePlayer.AllMovesNoKing())
             {
                 if (returnMove.EndPosition.PieceEquals(move.EndPosition) && !simulator.OldPiece.IsBetterThanOrEqual(returnMove.EndPosition.Piece))
                     add = false;
             }
             if (add) possible.Add(move);
         }
     }
     return possible;
 }
Пример #3
0
 public static ObservableCollection<Move> AllDefenseMoves(ObservableCollection<Move> moves)
 {
     ObservableCollection<Move> possible = new ObservableCollection<Move>();
     foreach (Move move in moves)
     {
         using (Simulator simulator = new Simulator(move))
         {
             bool add = true;
             foreach (Move returnMove in This.Game.OppositePlayer.AllMoves())
             {
                 if (returnMove.EndPosition.PieceEquals(move.EndPosition))
                 {
                     add = false;
                 }
             }
             if (add) possible.Add(move);
         }
     }
     return possible;
 }
Пример #4
0
 public static ObservableCollection<Move> GetMoveRatings(ObservableCollection<Move> moves)
 {
     ObservableCollection<Move> possible = new ObservableCollection<Move>();
     ObservableCollection<Move> possible2 = new ObservableCollection<Move>();
     int rating = This.Game.CurrentPlayer.PiecesUnderAttack.TotalRating();
     int rating2 = rating;
     foreach(Move move in This.Game.CurrentPlayer.AllMoves())
     {
         using(Simulator simulator = new Simulator(move))
         {
             int newRating = This.Game.CurrentPlayer.PiecesUnderAttack.TotalRating();
             if (newRating < rating)
             {
                 //rating = newRating;
                 possible.Add(move);
             }
             if (newRating <= rating2)
             {
                 //rating2 = newRating;
                 possible2.Add(move);
             }
         }
     }
     if (possible.Count > 0) return possible;
     else return possible2;
 }