Пример #1
0
 internal static void Create(List<Move> moves, Field node, Move move, Direction direction)
 {
     Field near = node[direction];
     if (near == null) return;
     Field far = near[direction];
     if (far == null) return;
     if (node.CanUse() && near.CanFree() && far.CanFree())
     {
         Append(moves, move, move.Create(node, near, far));
     }
 }
Пример #2
0
 internal bool Exists(Move move, Field near, Field far)
 {
     bool result = false;
     if (move.Hash == 0)
     {
         if (!CanMove(near, far))
             throw new InvalidOperationException();
         {
             Use();
             near.Free();
             far.Free();
         }
         result = move.Update(board);
         {
             Free();
             near.Use();
             far.Use();
         }
         return result;
     }
     return board.Exists(move.Hash);
 }
Пример #3
0
 internal bool DoMove(Move move, Field near, Field far)
 {
     if (!CanMove(near, far)) return false;
     if (Use() && near.Free() && far.Free())
     {
         board.DoMove(this, near, far, move);
         return true;
     }
     return false;
 }
Пример #4
0
 internal bool CanUndoMove(Field near, Field far)
 {
     return CanFree() && near.CanUse() && far.CanUse();
 }
Пример #5
0
 private static IEnumerable<Move> Create(Field node, Move move)
 {
     List<Move> moves = new List<Move>();
     Create(moves, node, move, Direction.Left);
     Create(moves, node, move, Direction.Top);
     Create(moves, node, move, Direction.Right);
     Create(moves, node, move, Direction.Bottom);
     return moves;
 }
Пример #6
0
 internal void UndoMove(Field node, Field near, Field far, Move move)
 {
     //data.Remove(hash);
     empty.Add(node);
     empty.Remove(near);
     empty.Remove(far);
     history.UndoMove(move);
 }
Пример #7
0
 internal void DoMove(Field node, Field near, Field far, Move move)
 {
     hashSet.Add(hash);
     empty.Remove(node);
     empty.Add(near);
     empty.Add(far);
     history.DoMove(move);
 }