Example #1
0
        // make result value by frequency of each symbols
        public List <int> GetDeck()
        {
            List <int> result = new List <int>();

            //BEChoice class is a utility class to choose a symbol from many symbols with various frequency.
            for (int x = 0; x < Reels.Count; ++x)
            {
                for (int y = 0; y < RowCount; ++y)
                {
                    //get random value from RNG
                    int RandomValue = -1;
                    if (rngType == RNGType.UnityRandom)
                    {
                        RandomValue = UnityEngine.Random.Range(0, choice[x].ValueTotal);
                    }
                    else if (rngType == RNGType.DotNetRandom)
                    {
                        RandomValue = randomDotNet.Next(0, choice[x].ValueTotal);
                    }
                    else if (rngType == RNGType.MersenneTwister)
                    {
                        RandomValue = randomMersenneTwister.RandomRange(0, choice[x].ValueTotal - 1);
                    }
                    else
                    {
                    }

                    //get selected symbol and add to result list
                    int SymbolIdx = choice[x].Choice(RandomValue);
                    result.Add(SymbolIdx);
                }
            }

            //Debug.Log ("GetDeck");
            //Debug.Log (GetSymbol(result[2]).prfab.name+","+GetSymbol(result[5]).prfab.name+","+GetSymbol(result[8]).prfab.name+","+GetSymbol(result[11]).prfab.name+","+GetSymbol(result[14]).prfab.name);
            //Debug.Log (GetSymbol(result[1]).prfab.name+","+GetSymbol(result[4]).prfab.name+","+GetSymbol(result[7]).prfab.name+","+GetSymbol(result[10]).prfab.name+","+GetSymbol(result[13]).prfab.name);
            //Debug.Log (GetSymbol(result[0]).prfab.name+","+GetSymbol(result[3]).prfab.name+","+GetSymbol(result[6]).prfab.name+","+GetSymbol(result[ 9]).prfab.name+","+GetSymbol(result[12]).prfab.name);

            return(result);
        }
Example #2
0
        public string Logout()
        {
            if (Org.Reddragonit.FreeSwitchConfig.DataCore.DB.Users.User.Current != null)
            {
                Log.Trace("Logging out user " + Org.Reddragonit.FreeSwitchConfig.DataCore.DB.Users.User.Current.FirstName);
            }
            else
            {
                EventController.TriggerEvent(new ErrorOccuredEvent("There is no user logged in to be logged out"));
                Log.Error("There is no user logged in to be logged out");
            }
            Request.Session.Abandon();
            string uname = "ABCDEFGH";

            while (User.LoadByUsername(uname) != null)
            {
                for (int x = 0; x < uname.Length; x++)
                {
                    uname = (x == 0 ? "" : uname.Substring(0, x)) + _USERNAME_CHARS[_rand.RandomRange(0, _USERNAME_CHARS.Length - 1)].ToString() + (x + 1 == uname.Length ? "" : uname.Substring(x + 1));
                }
            }
            return((Request.IsSSL ? "https://" : "http://") + uname + "@" + Request.URL.Host + ":" + Request.URL.Port.ToString() + "/");
        }
Example #3
0
        public void CompareDistributionOfMersennes()
        {
            Random rnd      = new Random();
            int    baseSeed = rnd.Next();

            var m1 = new MT19937();

            m1.init_genrand((ulong)baseSeed);
            var m2         = new RandomMT((ulong)baseSeed);
            var m3         = new SharpDevs.Randomization.MersenneTwister(baseSeed);
            var m4         = new Random(baseSeed);
            var maxRange   = 1000;
            var iterations = 10000000;

            var dist1 = this.CalculateDistribution(() => m1.RandomRange(0, maxRange - 1), maxRange, iterations);
            var dist2 = this.CalculateDistribution(() => m2.RandomRange(0, maxRange - 1), maxRange, iterations);
            var dist3 = this.CalculateDistribution(() => m3.GetNext(0, maxRange), maxRange, iterations);
            var dist4 = this.CalculateDistribution(() => m4.Next(0, maxRange), maxRange, iterations);

            var distribution1 = this.AnalyzeDistribution(dist1, iterations);
            var distribution2 = this.AnalyzeDistribution(dist2, iterations);
            var distribution3 = this.AnalyzeDistribution(dist3, iterations);
            var distribution4 = this.AnalyzeDistribution(dist4, iterations);

            Console.WriteLine("{0}\t{1}\t{2}\t{3}",
                              distribution1, distribution2, distribution3, distribution4);
            var expectedFill = (decimal)iterations / maxRange;

            Console.WriteLine("Przy oczekiwanym napełnieniu: " + expectedFill);
            Console.WriteLine("Co daje procentowo:");
            Console.WriteLine("{0}\t{1}\t{2}\t{3}",
                              distribution1 / expectedFill * 100,
                              distribution2 / expectedFill * 100,
                              distribution3 / expectedFill * 100,
                              distribution4 / expectedFill * 100);
        }
Example #4
0
    //This will create a new room from a portal. The other value is used for unique rooms and the spawn room
    private void CreateNewRoom(Portal portalToBuildFrom, GameObject roomToBuild)
    {
        //if the roomToBuild value is null that means that no room was passed in meaning that the Generator doesn't need to make any custom room so we pull a normal room from the list
        GameObject obj = null;

        if (roomToBuild == null)
        {
            //calcaulte a random room from the list of prefabs
            int index = 0;
            if (RoomPrefabs.Count > 1)
            {
                index = m_RandomNumberGenerator.RandomRange(0, RoomPrefabs.Count - 1);
            }

            //set instantiate the room prefab at the given value
            obj = Instantiate(RoomPrefabs[index], m_CurrentRoomToBuildFrom.transform.position, m_CurrentRoomToBuildFrom.transform.rotation);
        }
        else
        {
            //instantiate the specially passed in room
            obj = Instantiate(roomToBuild, m_CurrentRoomToBuildFrom.transform.position, m_CurrentRoomToBuildFrom.transform.rotation);
        }

        //next a random portal will be picked to link the portal that gets passed in
        int    randomNumber    = m_RandomNumberGenerator.RandomRange(0, obj.GetComponent <IslandRoom>().PortalsInRoom.Count - 1);
        Portal portalToConnect = obj.GetComponent <IslandRoom>().PortalsInRoom[randomNumber];

        //orient the newly created room in random space
        bool hasRoomBeenPlaced = false;

        while (hasRoomBeenPlaced == false)
        {
            //Must be done this way because the random number generator doesn't have a random float or random inside unit sphere. Cannot use UnityEngine.Random because of core
            //problem that it is used different times for different people (client and master client) as well as it's the whole reason for having the random number generator
            Vector3 newPosition = new Vector3();
            newPosition.x          = m_RandomNumberGenerator.RandomRange((int)(-SpawnRadius * 1000), (int)(SpawnRadius * 1000)) * 0.001f;
            newPosition.y          = m_RandomNumberGenerator.RandomRange((int)(-SpawnRadius * 1000), (int)(SpawnRadius * 1000)) * 0.001f;
            newPosition.z          = m_RandomNumberGenerator.RandomRange((int)(-SpawnRadius * 1000), (int)(SpawnRadius * 1000)) * 0.001f;
            obj.transform.position = newPosition;

            //TODO: in the future if rotating the rooms becomes a problem it must be fixed in this location before the cast point check is done

            //next we must check to see if that new location is a valid position for this room to be located using the cast point attached to the room
            CastPoints point = obj.GetComponentInChildren <CastPoints>();
            //if this check succeeds it means that the room was placed in a valid location in the world. If this check fails that means the location is invalid and the loop must run again
            if (CanRoomBeBuiltAtLocation(obj, point.transform.TransformPoint(point.center), point.transform.rotation, point.HalfExtents))
            {
                hasRoomBeenPlaced = true;
            }
        }

        //if we have arrived at this location it means that the room was placed in the world without any conflicts. The next thing to do is clean up for things like attaching the portals togeather
        RoomManager.Instance.ConnectedPortalsTogeather(portalToBuildFrom, portalToConnect);

        //if the room that was built is a normal room then things need to be updated in order to reflect the fact that a new room was created and added to the scene
        if (roomToBuild == null)
        {
            m_UniqueName++;                         //since we know the room will exist we can give it a "unique" name. Increment the unique name counter
            obj.name = m_UniqueName.ToString();     //set the newly spawned object's name to be that of the unique name value.

            m_AmountOfRoomsBuilt++;                 //increment the amount of rooms built value
            m_RoomsSinceLastUniqueRoomCreation++;   //increment the amount of rooms built since the last unique room was built value

            //add the newly created room to the list of rooms that can be built from
            m_RoomsToBuildFrom.Add(obj);
        }
        else
        {
            obj.name = roomToBuild.name;            //set the unique rooms name to be that rooms name, just without the (Clone) at the end
        }

        RoomManager.Instance.AddRoomToList(obj.GetComponent <IslandRoom>());
    }