Ejemplo n.º 1
0
    void checkForHashClones(int layers)
    {
        int clonecount = 0;
        Dictionary <int, roomData> hash = new Dictionary <int, roomData>();

        for (int i = 0; i <= layers; i++)
        {
            for (int p = 0; p <= Mathf.Pow(3, i); p++)
            {
                roomData room = new roomData((uint)i, (uint)p);
                int      num  = room.GetHashCode();
                if (hash.ContainsKey(num))
                {
                    print("1# " + hash[num].layerNumber + ", " + hash[num].roomNumber + ": " + hash[num].GetHashCode());
                    print("2# " + room.layerNumber + ", " + room.roomNumber + ": " + room.GetHashCode());
                    clonecount++;
                }
                else
                {
                    hash.Add(num, room);
                }
            }
        }
        print("clone count: " + clonecount);
    }
Ejemplo n.º 2
0
    void buildScene(roomData room)
    {
        Random.InitState(room.GetHashCode() + 1);

        currentWidth  = Random.Range(minWidth, maxWidth + 1);
        currentHeight = Random.Range(minHeight, maxHeight + 1);

        clearMap();
        randomWalkTiles(0.2f, 0.02f, 5);

        setPlayer();
        removeSoloBlocks();
        buildDoors();
        populate();

        setTiles();
    }
Ejemplo n.º 3
0
    void checkForClonesGames(int games, int layers)
    {
        int clonecount = 0;
        Dictionary <int, roomData> hash = new Dictionary <int, roomData>();

        for (int g = 0; g < games; g++)
        {
            print("game " + g);
            roomData currentRoom = new roomData(0, 0);
            for (int r = 0; r <= layers; r++)
            {
                Random.InitState((int)System.DateTime.Now.Ticks);
                int rand = Random.Range(0, 3);
                if (rand == 0)
                {
                    currentRoom = currentRoom.goLeft(currentRoom);
                }
                if (rand == 1)
                {
                    currentRoom = currentRoom.goMiddle(currentRoom);
                }
                if (rand == 2)
                {
                    currentRoom = currentRoom.goRight(currentRoom);
                }
                int chash = currentRoom.GetHashCode();

                if (hash.ContainsKey(chash) && hash[chash].layerNumber != currentRoom.layerNumber)
                {
                    print("1# " + hash[chash].layerNumber + ", " + hash[chash].roomNumber + ": " + hash[chash].GetHashCode());
                    print("2# " + currentRoom.layerNumber + ", " + currentRoom.roomNumber + ": " + currentRoom.GetHashCode());
                    clonecount++;
                }
                else
                {
                    if (!hash.ContainsKey(chash))
                    {
                        hash.Add(chash, currentRoom);
                    }
                }
            }
        }
        print("clone count: " + clonecount);
    }