Пример #1
0
        public static void WorldDataTest(int tyles = 256, int treeChaining = 2)
        {
            MySqlConnection connection = new MySqlConnection("Database=cubeworld;DataSource=localhost;UserId=root;Password=root");
            Models.TilesModel model = new Models.TilesModel(connection, tyles);
            Map.Map map = new Map.Map(model, tyles, treeChaining);

            Map.Rectangle coord = new Map.Rectangle(0, 0, 1), coords = new Map.Rectangle(0, 0, 1);
            Map.Block blockA, blockB;
            Trees.QuadTree.QuadTree<Map.Block> tree;

            int totalBlocks = (int)Math.Pow(tyles, treeChaining + 1);

            int window = 8, tests = 0, errors = 0;

            Map.Rectangle positionA = new Map.Rectangle(19, 8, 0);
            Map.Rectangle positionB = new Map.Rectangle(25, 8, 0);

            Map.Rectangle spaceA = new Map.Rectangle(positionA.x - window, positionA.y - window, 2 * window);
            Map.Rectangle spaceB = new Map.Rectangle(positionB.x - window, positionB.y - window, 2 * window);

            List<Map.Block> partsA = map.getIntersect(spaceA);
            List<Map.Block> partsB = map.getIntersect(spaceB);

            foreach (Map.Block pA in partsA)
            {
                foreach (Map.Block pB in partsB)
                {
                    if (pA.location.x == pB.location.x
                        && pA.location.y == pB.location.y)
                    {
                        tests++;

                        if (pA.val != pB.val)
                        {
                            //Console.Write("| Chyba: x={0}, y={1}", pA.location.x, pB.location.y);
                            errors++;
                        }
                    }
                }
            }

            Console.WriteLine("Testování světa o šířce {0} dlaždic.", totalBlocks);

            if (tests != 0)
                Console.WriteLine("Výsledek testu: {0}% ({1} ok, {2} bad)", (100 * (tests - errors)) / tests, tests - errors, errors);
            else
                Console.WriteLine("Neproběhl žádný test!");
        }
Пример #2
0
        public static void WorldTestBlock(int tyles = 16, int treeChaining = 2)
        {
            MySqlConnection connection = new MySqlConnection("Database=cubeworld;DataSource=localhost;UserId=root;Password=root");
            Models.TilesModel model = new Models.TilesModel(connection, tyles);
            Map.Map map = new Map.Map(model, tyles, treeChaining);

            Map.Rectangle coord = new Map.Rectangle(0, 0, 1), coords = new Map.Rectangle(0, 0, 1);
            Map.Block blockA, blockB;
            Trees.QuadTree.QuadTree<Map.Block> tree;

            int totalBlocks = (int)Math.Pow(tyles, treeChaining + 1) * (int)Math.Pow(tyles, treeChaining + 1);

            List<Map.Block> list, list2;
            int errors = 0, tests = 0;

            tree = map.getTree(new Map.Rectangle(0, 0, 16));

            return;

            for (int i = 1; i < 15; i++)
            {
                list = map.getIntersect(new Map.Rectangle(8, 0, 16));
                list2 = map.getIntersect(new Map.Rectangle(i, 0, 16));

                foreach (Map.Block b in list)
                {
                    foreach (Map.Block b2 in list2)
                    {
                        if (b.location.x == b2.location.x)
                        {
                            if (b.location.y == b2.location.y)
                            {
                                tests++;
                                if (b.val != b2.val)
                                {
                                    errors++;
                                }
                            }
                        }
                    }
                }

                //System.Threading.Thread.Sleep(1000);
            }

            Console.WriteLine("Hodnoceni počtu dlaždic: {0}% ({1} ok, {2} bad)", (100 * (tests - errors)) / tests, tests - errors, errors);
        }