Exemple #1
0
        private bool ValidateItems()
        {
            List <Item> items = m.getItems();

            for (int i = 0; i < items.Count; i++)
            {
                if (!PointInMaze(items[i].GetLocation()))
                {
                    Console.WriteLine("Item must be in maze");
                    return(false);
                }
            }


            List <Coord> l = new List <Coord>();

            foreach (Item i in items)
            {
                l.Add(i.GetLocation());
            }

            //no two items can have the same coordinate
            if (!PointsDistinct(l))
            {
                Console.WriteLine("Items points must be distinct");
                return(false);
            }
            //item must be reachable
            foreach (var c in l)
            {
                if (!mg.IsConnected(m.getStart(), c))
                {
                    Console.WriteLine("Items must be reachable");
                    return(false);
                }
            }
            return(true);
        }