Пример #1
0
        public knightsState WhatIfMove(Vector2 m, int ki)
        {
            knightsState ks = new knightsState(knights);

            ks.knights[ki] = new Knight(m.x, m.y);
            return(ks);
        }
Пример #2
0
 public static void Main(string[] args)
 {
     choices = new List <Vector2>();
     f       = new DFS_Fringe();
     GetInput();
     do
     {
         currentState = f.Pop();
         Successor();
     } while (!GoalTest());
     Console.WriteLine("done");
 }
Пример #3
0
        private static void GetInput()
        {
            string l = Console.ReadLine();
            int    m = Convert.ToInt32(l[0] + ""), n = Convert.ToInt32(l[1] + "");

            xBound = m;
            yBound = n;
            List <Knight> knights = new List <Knight>();

            for (int i = 0; i < n; i++)
            {
                l = Console.ReadLine();
                for (int j = 0; j < m; j++)
                {
                    if (l[j] == '#')
                    {
                        knights.Add(
                            new Knight(j, i)
                            );
                    }
                }
            }

            f.Append(
                new knightsState(
                    knights.ToArray()
                    )
                );

            knights = new List <Knight>();

            for (int i = 0; i < n; i++)
            {
                l = Console.ReadLine();
                for (int j = 0; j < m; j++)
                {
                    if (l[j] == '#')
                    {
                        knights.Add(
                            new Knight(j, i)
                            );
                    }
                }
            }

            idealState = new knightsState(knights.ToArray());
        }
Пример #4
0
        public bool Compare(knightsState ks)
        {
            int similars = 0;

            foreach (Knight v1 in knights)
            {
                foreach (Knight v2 in ks.knights)
                {
                    if (v1.pos.x == v2.pos.x && v1.pos.y == v2.pos.y)
                    {
                        similars++;
                    }
                }
            }

            if (similars == knights.Length)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
 public override void Append(knightsState ks)
 {
     stack.Push(ks);
 }
Пример #6
0
 public abstract void Append(knightsState ks);