Exemplo n.º 1
0
        static void Main(string[] args)
        {
            Kiev       k = new Kiev();
            London     l = new London();
            Washington w = new Washington();

            Console.WriteLine("Write count of people in Kiev: ");
            k.PeopleCount = Int32.Parse(Console.ReadLine());

            Console.WriteLine("Write count of people in London: ");
            l.PeopleCount = Int32.Parse(Console.ReadLine());

            Console.WriteLine("Write count of people in Washington: ");
            w.PeopleCount = Int32.Parse(Console.ReadLine());

            if (k.PeopleCount >= l.PeopleCount)
            {
                if (k.PeopleCount > w.PeopleCount)
                {
                    Console.WriteLine(" In Kiev are more people");
                }
            }
            if (k.PeopleCount <= l.PeopleCount)
            {
                if (l.PeopleCount > w.PeopleCount)
                {
                    Console.WriteLine(" In London are more people");
                }
            }
            if (w.PeopleCount >= l.PeopleCount)
            {
                if (k.PeopleCount < w.PeopleCount)
                {
                    Console.WriteLine(" In washington are more people");
                }
            }

            //Dictionary<string, long> d = new Dictionary<string, long>;
            //d.Add("Kiev",k.PeopleCount);
            //d.Add("London", l.PeopleCount);
            //d.Add("Washington", w.PeopleCount);

            Console.ReadKey();
        }
Exemplo n.º 2
0
    public Map()
    {
        State currState = new State();

        for (int m = 1; m < 25; m++)
        {
            for (int n = 0; n < 39; n++)
            {
                cells[m, n] = (GameObject)Object.Instantiate(Resources.Load("Cell"));
                cells[m, n].transform.position = new Vector3(n, 0, m);
                getCell(m, n).SetXY(n, m);
            }
        }

        for (int i = 0; i < 19; i++)
        {
            GameObject.Destroy(cells[1, i]);
            cells[1, i] = null;
        }
        for (int i = 0; i < 18; i++)
        {
            GameObject.Destroy(cells[2, i]);
            cells[2, i] = null;
        }
        for (int i = 0; i < 17; i++)
        {
            GameObject.Destroy(cells[3, i]);
            cells[3, i] = null;
        }
        for (int i = 0; i < 14; i++)
        {
            GameObject.Destroy(cells[4, i]);
            cells[4, i] = null;
        }
        for (int i = 0; i < 13; i++)
        {
            GameObject.Destroy(cells[5, i]);
            cells[5, i] = null;
        }
        for (int i = 0; i < 10; i++)
        {
            GameObject.Destroy(cells[6, i]);
            cells[6, i] = null;
        }
        for (int i = 0; i < 7; i++)
        {
            GameObject.Destroy(cells[7, i]);
            cells[7, i] = null;
        }
        for (int i = 0; i < 4; i++)
        {
            GameObject.Destroy(cells[8, i]);
            cells[8, i] = null;
        }
        for (int i = 0; i < 3; i++)
        {
            GameObject.Destroy(cells[9, i]);
            cells[9, i] = null;
        }
        for (int i = 0; i < 2; i++)
        {
            GameObject.Destroy(cells[10, i]);
            cells[10, i] = null;
        }
        for (int i = 13; i < 36; i++)
        {
            GameObject.Destroy(cells[24, i]);
            cells[24, i] = null;
        }
        GameObject.Destroy(cells[24, 0]);
        cells[24, 0] = null;
        GameObject.Destroy(cells[24, 38]);
        cells[24, 38] = null;
        GameObject.Destroy(cells[24, 2]);
        cells[24, 2] = null;
        GameObject.Destroy(cells[11, 0]);
        cells[11, 0] = null;
        GameObject.Destroy(cells[22, 0]);
        cells[22, 0] = null;
        GameObject.Destroy(cells[23, 0]);
        cells[23, 0] = null;
        GameObject.Destroy(cells[21, 0]);
        cells[21, 0] = null;
        GameObject.Destroy(cells[22, 38]);
        cells[22, 38] = null;
        GameObject.Destroy(cells[21, 38]);
        cells[21, 38] = null;
        for (int i = 22; i < 36; i++)
        {
            GameObject.Destroy(cells[23, i]);
            cells[23, i] = null;
        }
        for (int i = 24; i < 34; i++)
        {
            GameObject.Destroy(cells[22, i]);
            cells[22, i] = null;
        }
        for (int i = 27; i < 33; i++)
        {
            GameObject.Destroy(cells[21, i]);
            cells[21, i] = null;
        }
        GameObject.Destroy(cells[20, 26]);
        cells[20, 26] = null;
        GameObject.Destroy(cells[20, 29]);
        cells[20, 29] = null;
        GameObject.Destroy(cells[20, 30]);
        cells[20, 30] = null;
        GameObject.Destroy(cells[20, 31]);
        cells[20, 31] = null;
        for (int i = 29; i < 31; i++)
        {
            GameObject.Destroy(cells[19, i]);
            cells[19, i] = null;
        }
        for (int i = 29; i < 30; i++)
        {
            GameObject.Destroy(cells[18, i]);
            cells[18, i] = null;
        }
        GameObject.Destroy(cells[19, 26]);
        cells[19, 26] = null;
        for (int i = 20; i < 33; i++)
        {
            GameObject.Destroy(cells[1, i]);
            cells[1, i] = null;
        }
        for (int i = 35; i < 39; i++)
        {
            GameObject.Destroy(cells[1, i]);
            cells[1, i] = null;
        }
        for (int i = 20; i < 32; i++)
        {
            GameObject.Destroy(cells[2, i]);
            cells[2, i] = null;
        }
        for (int i = 21; i < 32; i++)
        {
            GameObject.Destroy(cells[3, i]);
            cells[3, i] = null;
        }
        GameObject.Destroy(cells[4, 22]);
        cells[4, 22] = null;
        for (int i = 27; i < 30; i++)
        {
            GameObject.Destroy(cells[4, i]);
            cells[4, i] = null;
        }
        GameObject.Destroy(cells[5, 27]);
        cells[5, 27] = null;
        GameObject.Destroy(cells[18, 26]);
        cells[18, 26] = null;
        for (int i = 5; i < 9; i++)
        {
            GameObject.Destroy(cells[i, 33]);
            cells[i, 33] = null;
        }
        for (int i = 3; i < 12; i++)
        {
            GameObject.Destroy(cells[i, 34]);
            cells[i, 34] = null;
        }
        for (int i = 2; i < 19; i++)
        {
            GameObject.Destroy(cells[i, 35]);
            cells[i, 35] = null;
        }
        for (int i = 2; i < 19; i++)
        {
            GameObject.Destroy(cells[i, 36]);
            cells[i, 36] = null;
        }
        for (int i = 2; i < 22; i++)
        {
            GameObject.Destroy(cells[i, 37]);
            cells[i, 37] = null;
        }
        for (int i = 2; i < 21; i++)
        {
            GameObject.Destroy(cells[i, 38]);
            cells[i, 38] = null;
        }


        int choice = Random.Range(0, 2);

        switch (choice)
        {
        case 0:                 //Complete random distrobution
        {
            for (int m = 0; m < 25; m++)
            {
                for (int n = 0; n < 40; n++)
                {
                    if (cells[m, n] != null)
                    {
                        int richness = Random.Range(0, 101);
                        if (richness < 50)
                        {
                            richness = 0;
                        }
                        getCell(m, n).EstablishRichness(richness);
                    }
                }
            }
            break;
        }

        case 1:                 //Associated Distrobution
        {
            bool[,] Visited = new bool [25, 40];
            Queue MapQueue = new Queue();
            for (int m = 0; m < 25; m++)
            {
                for (int n = 0; n < 40; n++)
                {
                    Visited[m, n] = false;
                }
            }

            int first = Random.Range(2, 33);

            Visited[13, first] = true;
            getCell(13, first).EstablishRichness(Random.Range(50, 101));
            MapQueue.Enqueue(getCell(13, first));

            while (MapQueue.Count != 0)
            {
                Cell temp = (Cell)MapQueue.Dequeue();
                if (temp.xPos > 0)
                {
                    if (Visited[temp.yPos, temp.xPos - 1] == false)
                    {
                        if (cells[temp.yPos, temp.xPos - 1] != null)
                        {
                            Cell temp1 = getCell(temp.yPos, temp.xPos - 1);
                            temp1.EstablishRichness(AssociateRichness(temp));
                            MapQueue.Enqueue(temp1);
                        }
                        Visited[temp.yPos, temp.xPos - 1] = true;
                    }
                }
                if (temp.xPos < 39)
                {
                    if (Visited[temp.yPos, temp.xPos + 1] == false)
                    {
                        if (cells[temp.yPos, temp.xPos + 1] != null)
                        {
                            Cell temp1 = getCell(temp.yPos, temp.xPos + 1);
                            temp1.EstablishRichness(AssociateRichness(temp));
                            MapQueue.Enqueue(temp1);
                        }
                        Visited[temp.yPos, temp.xPos + 1] = true;
                    }
                }
                if (temp.yPos < 24)
                {
                    if (Visited[temp.yPos + 1, temp.xPos] == false)
                    {
                        if (cells[temp.yPos + 1, temp.xPos] != null)
                        {
                            Cell temp1 = getCell(temp.yPos + 1, temp.xPos);
                            temp1.EstablishRichness(AssociateRichness(temp));
                            MapQueue.Enqueue(temp1);
                        }
                        Visited[temp.yPos + 1, temp.xPos] = true;
                    }
                }
                if (temp.yPos > 2)
                {
                    if (Visited[temp.yPos - 1, temp.xPos] == false)
                    {
                        if (cells[temp.yPos - 1, temp.xPos] != null)
                        {
                            Cell temp1 = getCell(temp.yPos - 1, temp.xPos);
                            temp1.EstablishRichness(AssociateRichness(temp));
                            MapQueue.Enqueue(temp1);
                        }
                        Visited[temp.yPos - 1, temp.xPos] = true;
                    }
                }
            }
            break;
        }

        case 2:                 //Striped distrobution
        {
            break;
        }
        }
        currState = new California(this);
        currState.setInitialDifficulty();
        currState = new Washington(this);
        currState.setInitialDifficulty();
        currState = new Oregon(this);
        currState.setInitialDifficulty();
        currState = new Nevada(this);
        currState.setInitialDifficulty();
        currState = new Arizona(this);
        currState.setInitialDifficulty();
        currState = new Utah(this);
        currState.setInitialDifficulty();
        currState = new Nevada(this);
        currState.setInitialDifficulty();
        currState = new Colorado(this);
        currState.setInitialDifficulty();
        currState = new Utah(this);
        currState.setInitialDifficulty();
        currState = new Idaho(this);
        currState.setInitialDifficulty();
        currState = new Montana(this);
        currState.setInitialDifficulty();
        currState = new Wyoming(this);
        currState.setInitialDifficulty();
        currState = new Colorado(this);
        currState.setInitialDifficulty();
        currState = new NewMexico(this);
        currState.setInitialDifficulty();
        currState = new Texas(this);
        currState.setInitialDifficulty();
        currState = new Oklahoma(this);
        currState.setInitialDifficulty();
        currState = new Kansas(this);
        currState.setInitialDifficulty();
        currState = new Nebraska(this);
        currState.setInitialDifficulty();
        currState = new SDakota(this);
        currState.setInitialDifficulty();
        currState = new NDakota(this);
        currState.setInitialDifficulty();

        currState = new Wyoming(this);
        currState.setInitialDifficulty();
        currState = new Wyoming(this);
        currState.setInitialDifficulty();
        currState = new Wyoming(this);
        currState.setInitialDifficulty();
    }