예제 #1
0
        public void printWorld()
        {
            PointInContinent pic = new PointInContinent();

            for (int i = 0; i < N; i++)
            {
                for (int j = 0; j < M; j++)
                {
                    pic.x = i;
                    pic.y = j;
                    if (startingPoints.Contains(pic))
                    {
                        Console.ForegroundColor = ConsoleColor.Red;
                    }
                    else if (map[i, j] < 100)
                    {
                        Console.ForegroundColor = colors[map[i, j]];
                    }
                    else
                    {
                        Console.ForegroundColor = colors[ground];
                    }
                    Console.Write((char)0x2588);
                }
                Console.Write("\n");
            }

            cntPrc();
            Console.ForegroundColor = ConsoleColor.Magenta;
            Console.WriteLine("Stats: Water [" + wproc.ToString("0.00") + "%] Ground [" + gproc.ToString("0.00") + "%] Void [" + eproc.ToString("0.00") + "%] Dumped maps [" + dumped.ToString() + "]");
            Console.WriteLine("Generated in {0} miliseconds, Paths generated in {1} miliseconds", sw.Elapsed.TotalMilliseconds, pathsTime);
            Console.ResetColor();
        }
예제 #2
0
        float cntDistance(PointInContinent a, PointInContinent b)
        {
            double c = 0F;

            c = (a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y);
            c = Math.Sqrt(c);
            return((float)c);
        }
예제 #3
0
        void markAndAddToQueue(int x, int y, int tilenb)
        {
            PointInContinent poi = new PointInContinent();

            poi.x = x;
            poi.y = y;
            kolejeczka.Add(poi);
            map[x, y] = tilenb;
            continentSize++;
        }
예제 #4
0
        void joinWithPaths()
        {
            List <PointInContinent> nonEvaluatedPoints = new List <PointInContinent>();

            for (int i = 0; i < startingPoints.Count; i++)
            {
                nonEvaluatedPoints.Add(startingPoints[i]);
            }
            List <PointInContinent> EvaluatedPoints = new List <PointInContinent>();

            Dictionary <PointInContinent, int> howFar = new Dictionary <PointInContinent, int>();

            PointInContinent root = nonEvaluatedPoints[random.Next(0, startingPoints.Count)];
        }
예제 #5
0
        bool runQueue(int tilenb)
        {
            while (continentSize < maxSize && kolejeczka.Count != 0)
            {
                //kolejeczka = (Stack<PointInContinent>)kolejeczka.OrderBy(a => Guid.NewGuid());
                PointInContinent pic = kolejeczka[random.Next(0, kolejeczka.Count - 1)];
                kolejeczka.Remove(pic);

                processPointNeibours(pic.x, pic.y, tilenb);
                direction.Shuffle();
                //printWorld();
            }
            if ((float)continentSize >= maxSize * standardDiff)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #6
0
        bool landOfOoo()
        {
            int x, y;

            for (int c = 0; c < continents; c++)
            {
                continentSize = 0;
                kolejeczka.Clear();

                int mytilenb = 100 + c;
                x = random.Next(1, N - 1);
                y = random.Next(1, M - 1);
                int i;
                for (i = 0; i < 50 && !checkStartingPoint(x, y); i++)
                {
                    x = random.Next(1, N - 1);
                    y = random.Next(1, M - 1);
                }
                if (i == 49 && !checkStartingPoint(x, y))
                {
                    return(false);
                }

                PointInContinent pic = new PointInContinent();
                pic.x = x;
                pic.y = y;
                startingPoints.Add(pic);

                map[x, y] = mytilenb;
                continentSize++;
                direction.Shuffle();
                foreach (int dir in direction)
                {
                    switch (dir)
                    {
                    case 0:
                    {
                        if (checkIfFree(x - 1, y - 1, mytilenb))
                        {
                            markAndAddToQueue(x - 1, y - 1, mytilenb);
                        }
                        break;
                    }

                    case 1:
                    {
                        if (checkIfFree(x - 1, y, mytilenb))
                        {
                            markAndAddToQueue(x - 1, y, mytilenb);
                        }
                        break;
                    }

                    case 2:
                    {
                        if (checkIfFree(x - 1, y + 1, mytilenb))
                        {
                            markAndAddToQueue(x - 1, y + 1, mytilenb);
                        }
                        break;
                    }

                    case 3:
                    {
                        if (checkIfFree(x, y - 1, mytilenb))
                        {
                            markAndAddToQueue(x, y - 1, mytilenb);
                        }
                        break;
                    }

                    case 4:
                    {
                        if (checkIfFree(x + 1, y - 1, mytilenb))
                        {
                            markAndAddToQueue(x + 1, y - 1, mytilenb);
                        }
                        break;
                    }

                    case 5:
                    {
                        if (checkIfFree(x + 1, y + 1, mytilenb))
                        {
                            markAndAddToQueue(x + 1, y + 1, mytilenb);
                        }
                        break;
                    }

                    case 6:
                    {
                        if (checkIfFree(x, y + 1, mytilenb))
                        {
                            markAndAddToQueue(x, y + 1, mytilenb);
                        }
                        break;
                    }

                    case 7:
                    {
                        if (checkIfFree(x + 1, y, mytilenb))
                        {
                            markAndAddToQueue(x + 1, y, mytilenb);
                        }
                        break;
                    }
                    }
                }

                bool result = runQueue(mytilenb);
                if (result == false)
                {
                    return(result);
                }
            }

            return(true);
        }