예제 #1
0
        public void TestBonusBuilder()
        {
            // Arrange
            var bearResult = new BearResult("s");
            var reels      = new List <int[]>
            {
                new[] { 0, 6, 10 },
                new[] { 6, 11, 12 },
                new[] { 6, 11, 13 },
                new[] { 9, 11, 12, },
                new[] { 12, 10, 13 }
            };

            bearResult.Wheel = new BearWheel(1, ArrayModule.OfSeq(reels));

            // action
            var bonus = BonusInspection.inspect(HoneyPot.Mode.Primary, bearResult);

            // assert
            Assert.NotNull(bonus);
            Assert.AreEqual(bonus.Value.At[0].RowPositions, new List <int> {
                0, 2, 2, 2, 0
            });
            Assert.AreEqual(bonus.Value.Item.ClientId, 3);
            Assert.AreEqual(bonus.Value.Item.Count, 15);
        }
예제 #2
0
        public decimal TestNonScatterPayout(string wheelString)
        {
            var wheel  = Encoding(wheelString.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray());
            var result = Payout.payNoneScatter(1, 1, ArrayModule.OfSeq(wheel));

            return(result.Payable);
        }
예제 #3
0
        public decimal TestScatterPayout(string wheelString, string position)
        {
            var wheel  = Encoding(wheelString.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray());
            var result = Payout.payScatter(1, 1, ArrayModule.OfSeq(wheel));

            Assert.AreEqual(result.WinPositions.Any() ? string.Join(",", result.WinPositions.First().RowPositions) : "", position);
            return(result.Payable);
        }
예제 #4
0
 public Ranges(IEnumerable <Tuple <T, T> > ranges, IRangeKeyOperations <T> ops)
 {
     Deedle.Ranges.Ranges <T> ranges1 = this;
     this.ops    = ops;
     this.ranges = (Tuple <T, T>[])ArrayModule.OfSeq <Tuple <T, T> >((IEnumerable <M0>)ranges);
     foreach (Tuple <T, T> tuple in this.ranges)
     {
         if (this.ops.Compare(tuple.Item1, tuple.Item2) > 0)
         {
             throw new ArgumentException("Invalid range (first offset is greater than second)", nameof(ranges));
         }
     }
 }
예제 #5
0
        Tuple <IIndex <g>, VectorConstruction> IIndexBuilder.OrderIndex <g>(Tuple <IIndex <g>, VectorConstruction> _arg2)
        {
            Tuple <IIndex <g>, VectorConstruction> tuple = _arg2;
            VectorConstruction vectorConstruction        = tuple.Item2;
            IIndex <g>         index = tuple.Item1;

            g[] array = ArrayModule.OfSeq <g>((IEnumerable <M0>)index.Keys);
            ArrayModule.SortInPlaceWith <g>((Func <M0, Func <M0, int> >) new LinearIndex.DeedleIndicesIIndexBuilderOrderIndex <g>(index), array);
            IIndex <g> newIndex = (IIndex <g>) new LinearIndex <g>(System.Array.AsReadOnly <g>(array), (IIndexBuilder)this, FSharpOption <bool> .Some(true));
            IEnumerable <Tuple <long, long> > tuples = (IEnumerable <Tuple <long, long> >) new LinearIndex.relocations <g>(index, newIndex, new KeyValuePair <g, long>(), (Tuple <g, long>)null, new long(), default(g), (IEnumerator <KeyValuePair <g, long> >)null, 0, (Tuple <long, long>)null);

            return(new Tuple <IIndex <g>, VectorConstruction>(newIndex, VectorConstruction.NewRelocate(vectorConstruction, newIndex.KeyCount, tuples)));
        }
예제 #6
0
        public static bool Test_Reverse_2(long[] a)
        {
            if (null == a)
            {
                return(true);
            }
            var rr = GetRandom();
            // var c = rr.Next(checked(1 + a.Length));
            // var s = rr.Next(checked(1 + a.Length - c));
            // var t = unchecked(rr.Next() - rr.Next());
            var r0 = a.Clone() as long[];

            Array.Reverse <long>(r0);
            var r1 = a.Clone() as long[];

            ArrayModule.Reverse(r1);
            return(r0.SequenceEqual(r1));
        }
예제 #7
0
        public void TestCreateHoneyBonus()
        {
            // Arrange
            var result = new BearResult("s");
            var reels  = new List <int[]>
            {
                new[] { 1, 6, 10 },
                new[] { 6, 9, 12 },
                new[] { 6, 10, 13 },
                new[] { 9, 13, 12, },
                new[] { 12, 10, 13 }
            };

            result.Bonus          = new Stake(Guid.NewGuid(), 4);
            result.Bonus.Count    = HoneyPot.getHoneyPots(HoneyPot.Mode.Primary, 0.75);
            result.Wheel          = new BearWheel(1, ArrayModule.OfSeq(reels));
            result.BonusPositions = new List <BonusPosition> {
                new BonusPosition {
                    Line = 1, Multiplier = 1, RowPositions = new List <int> {
                        3, 0, 2, 0, 2
                    }
                }
            };

            // action
            var bonus = module.CreateBonus(result);
            var state = ((BearBonus)bonus.Value).State;

            // Assert
            Assert.AreEqual(result.Bonus.Guid, bonus.Value.Guid);
            Assert.AreEqual(true, state.IsHoney);
            Assert.AreEqual(false, state.IsFreeSpin);
            Assert.AreEqual(false, state.IsHoneyFreeSpin);
            Assert.AreEqual(4, ((Honey)state).Item.Id);
            Assert.AreEqual(3, ((Honey)state).Item.Pot.Count);
            Assert.AreEqual(3, ((Honey)state).Item.Pot.TotalSpin);

            Assert.AreEqual(1, ((Honey)state).Item.BeeHive.Count);
            Assert.AreEqual(1, ((Honey)state).Item.BeeHive.TotalSpin);
        }
예제 #8
0
        public void TestCreateFreeSpinBonus()
        {
            // Arrange
            var result = new BearResult("s");
            var reels  = new List <int[]>
            {
                new[] { 0, 6, 10 },
                new[] { 6, 11, 12 },
                new[] { 6, 11, 13 },
                new[] { 9, 11, 12, },
                new[] { 12, 10, 13 }
            };

            result.Bonus          = new Stake(Guid.NewGuid(), 3);
            result.Bonus.Count    = 15;
            result.Wheel          = new BearWheel(1, ArrayModule.OfSeq(reels));
            result.BonusPositions = new List <BonusPosition> {
                new BonusPosition {
                    Line = 1, Multiplier = 1, RowPositions = new List <int> {
                        0, 2, 2, 2, 0
                    }
                }
            };

            // action
            var bonus = module.CreateBonus(result);
            var state = ((BearBonus)bonus.Value).State;

            // Assert
            Assert.AreEqual(result.Bonus.Guid, bonus.Value.Guid);
            Assert.AreEqual(true, state.IsFreeSpin);
            Assert.AreEqual(false, state.IsHoney);
            Assert.AreEqual(false, state.IsHoneyFreeSpin);
            Assert.AreEqual(3, ((FreeSpin)state).Item.Id);
            Assert.AreEqual(15, ((FreeSpin)state).Item.Prize.Count);
            Assert.AreEqual(15, ((FreeSpin)state).Item.Prize.TotalSpin);
        }
예제 #9
0
        internal Tuple <LinearIndex <a>, VectorConstruction> asLinearIndex <a>(IIndex <a> index, VectorConstruction vector)
        {
            LinearIndex <a> linearIndex = index as LinearIndex <a>;

            if (linearIndex != null)
            {
                return(new Tuple <LinearIndex <a>, VectorConstruction>(linearIndex, vector));
            }
            IEnumerable <Tuple <long, long> > tuples = (IEnumerable <Tuple <long, long> >)SeqModule.MapIndexed <KeyValuePair <a, long>, Tuple <long, long> >((Func <int, Func <M0, M1> >) new LinearIndex.relocs <a>(), (IEnumerable <M0>)index.Mappings);
            VectorConstruction vectorConstruction    = VectorConstruction.NewRelocate(vector, index.KeyCount, tuples);

            return(new Tuple <LinearIndex <a>, VectorConstruction>(new LinearIndex <a>(System.Array.AsReadOnly <a>(ArrayModule.OfSeq <a>((IEnumerable <a>)SeqModule.Map <KeyValuePair <a, long>, a>((Func <M0, M1>) new LinearIndex.clo <a>(), (IEnumerable <M0>)index.Mappings))), LinearIndexBuilder.Instance, (FSharpOption <bool>)null), vectorConstruction));
        }
예제 #10
0
        Tuple <IIndex <K>, VectorConstruction> IIndexBuilder.DropItem <K>(Tuple <IIndex <K>, VectorConstruction> _arg10, K key)
        {
            Tuple <IIndex <K>, VectorConstruction> tuple1 = _arg10;
            VectorConstruction vectorConstruction1        = tuple1.Item2;
            IIndex <K>         index = tuple1.Item1;
            FSharpChoice <Unit, Tuple <K, long> > fsharpChoice = OptionalValueModule.MissingPresent <Tuple <K, long> >(index.Lookup(key, Lookup.Exact, (Func <long, bool>) new LinearIndex.DeedleIndicesIIndexBuilderDropItem()));

            if (fsharpChoice is FSharpChoice <Unit, Tuple <K, long> > .Choice2Of2)
            {
                Tuple <K, long>        tuple2 = ((FSharpChoice <Unit, Tuple <K, long> > .Choice2Of2)fsharpChoice).get_Item();
                VectorConstruction     vectorConstruction2 = VectorConstruction.NewDropRange(vectorConstruction1, RangeRestriction <long> .NewFixed(tuple2.Item2, tuple2.Item2));
                ReadOnlyCollection <K> keys = index.Keys;
                return(new Tuple <IIndex <K>, VectorConstruction>((IIndex <K>) new LinearIndex <K>(System.Array.AsReadOnly <K>(ArrayModule.OfSeq <K>(SeqModule.Filter <K>((Func <K, bool>) new LinearIndex.newKeys <K>(key), (IEnumerable <M0>)keys))), (IIndexBuilder)this, FSharpOption <bool> .Some(index.IsOrdered)), vectorConstruction2));
            }
            string paramName = nameof(key);

            throw new ArgumentException(((Func <K, string>)ExtraTopLevelOperators.PrintFormatToString <Func <K, string> >((PrintfFormat <M0, Unit, string, string>) new PrintfFormat <Func <K, string>, Unit, string, string, K>("The key '%O' is not present in the index."))).Invoke(key), paramName);
        }
예제 #11
0
        Tuple <IIndex <b>, VectorConstruction> IIndexBuilder.LookupLevel <b>(Tuple <IIndex <b>, VectorConstruction> _arg9, ICustomLookup <b> searchKey)
        {
            Tuple <IIndex <b>, VectorConstruction> tuple = _arg9;
            VectorConstruction vectorConstruction        = tuple.Item2;
            IIndex <b>         index = tuple.Item1;

            Tuple <long, b>[] array = (Tuple <long, b>[])SeqModule.ToArray <Tuple <long, b> >((IEnumerable <M0>) new LinearIndex.matching <b>(searchKey, index, new KeyValuePair <b, long>(), (Tuple <b, long>)null, default(b), new long(), (IEnumerator <KeyValuePair <b, long> >)null, 0, (Tuple <long, b>)null));
            long length             = (long)array.Length;

            LinearIndex.relocs relocs5601 = new LinearIndex.relocs();
            long   lo  = 0;
            long   hi  = length - 1L;
            object obj = lo > hi ? (object)new LinearIndex.relocs(lo, hi, 1L, (Func <long, Func <long, bool> >) new LinearIndex.relocs()) : (object)new LinearIndex.relocs(lo, hi, 1L, (Func <long, Func <long, bool> >) new LinearIndex.relocs());
            IEnumerable <Tuple <long, long> > tuples = (IEnumerable <Tuple <long, long> >)SeqModule.Zip <long, long>((IEnumerable <M0>)SeqModule.Map <long, long>((Func <M0, M1>)relocs5601, (IEnumerable <M0>)obj), SeqModule.Map <Tuple <long, b>, long>((Func <M0, M1>) new LinearIndex.relocs <b>(), (IEnumerable <M0>)array));

            return(new Tuple <IIndex <b>, VectorConstruction>((IIndex <b>) new LinearIndex <b>(System.Array.AsReadOnly <b>(ArrayModule.OfSeq <b>((IEnumerable <b>)SeqModule.Map <Tuple <long, b>, b>((Func <M0, M1>) new LinearIndex.newIndex <b>(), (IEnumerable <M0>)array))), (IIndexBuilder)this, FSharpOption <bool> .Some(index.IsOrdered)), VectorConstruction.NewRelocate(vectorConstruction, length, tuples)));
        }
예제 #12
0
        Tuple <IIndex <c>, VectorConstruction> IIndexBuilder.Search <c, d>(Tuple <IIndex <c>, VectorConstruction> _arg8, IVector <d> searchVector, d searchValue)
        {
            Tuple <IIndex <c>, VectorConstruction> tuple = _arg8;
            VectorConstruction vectorConstruction        = tuple.Item2;
            IIndex <c>         index1   = tuple.Item1;
            List <c>           cList    = new List <c>();
            List <long>        longList = new List <long>();
            int index2 = 0;
            int count  = index1.Keys.Count;
            int length = (int)searchVector.Length;
            int num    = (count >= length ? length : count) - 1;

            if (num >= index2)
            {
                do
                {
                    d optionalValue = searchVector.GetValue((long)index2);
                    if ((!optionalValue.HasValue ? 0 : (LanguagePrimitives.HashCompare.GenericEqualityIntrinsic <d>((M0)optionalValue.Value, (M0)searchValue) ? 1 : 0)) != 0)
                    {
                        cList.Add(index1.Keys[index2]);
                        longList.Add((long)index2);
                    }
                    ++index2;
                }while (index2 != num + 1);
            }
            LinearIndex <c>         linearIndex      = new LinearIndex <c>(System.Array.AsReadOnly <c>(ArrayModule.OfSeq <c>((IEnumerable <c>)cList)), (IIndexBuilder)this, (FSharpOption <bool>)null);
            IEnumerable <long>      indices          = (IEnumerable <long>)SeqModule.Map <long, long>((Func <M0, M1>) new LinearIndex.range(), (IEnumerable <M0>)longList);
            RangeRestriction <long> rangeRestriction = VectorHelpers.RangeRestriction.ofSeq((long)longList.Count, indices);

            return(new Tuple <IIndex <c>, VectorConstruction>((IIndex <c>)linearIndex, VectorConstruction.NewGetRange(vectorConstruction, rangeRestriction)));
        }
예제 #13
0
        Tuple <IIndex <TNewKey>, VectorConstruction> IIndexBuilder.WithIndex <K, TNewKey>(IIndex <K> index1, IVector <TNewKey> indexVector, VectorConstruction vector)
        {
            Tuple <TNewKey, long>[] array       = (Tuple <TNewKey, long>[])SeqModule.ToArray <Tuple <TNewKey, long> >((IEnumerable <M0>) new LinearIndex.newKeys <TNewKey, K>(index1, indexVector, new KeyValuePair <K, long>(), (Tuple <K, long>)null, new long(), default(K), new TNewKey(), (IEnumerator <KeyValuePair <K, long> >)null, 0, (Tuple <TNewKey, long>)null));
            LinearIndex <TNewKey>   linearIndex = new LinearIndex <TNewKey>(System.Array.AsReadOnly <TNewKey>((TNewKey[])ArrayModule.OfSeq <TNewKey>((IEnumerable <M0>)SeqModule.Map <Tuple <TNewKey, long>, TNewKey>((Func <M0, M1>) new LinearIndex.newIndex <TNewKey>(), (IEnumerable <M0>)array))), (IIndexBuilder)this, (FSharpOption <bool>)null);
            long keyCount = ((IIndex <TNewKey>)linearIndex).KeyCount;

            LinearIndex.relocations relocations5178 = new LinearIndex.relocations();
            long   lo  = 0;
            long   hi  = keyCount - 1L;
            object obj = lo > hi ? (object)new LinearIndex.relocations(lo, hi, 1L, (Func <long, Func <long, bool> >) new LinearIndex.relocations()) : (object)new LinearIndex.relocations(lo, hi, 1L, (Func <long, Func <long, bool> >) new LinearIndex.relocations());
            IEnumerable <Tuple <long, long> > tuples = (IEnumerable <Tuple <long, long> >)SeqModule.Zip <long, long>((IEnumerable <M0>)SeqModule.Map <long, long>((Func <M0, M1>)relocations5178, (IEnumerable <M0>)obj), SeqModule.Map <Tuple <TNewKey, long>, long>((Func <M0, M1>) new LinearIndex.relocations <TNewKey>(), (IEnumerable <M0>)array));

            return(new Tuple <IIndex <TNewKey>, VectorConstruction>((IIndex <TNewKey>)linearIndex, VectorConstruction.NewRelocate(vector, (long)array.Length, tuples)));
        }
예제 #14
0
        Tuple <IIndex <TNewKey>, IVector <R> > IIndexBuilder.Resample <K, TNewKey, R>(IIndexBuilder chunkBuilder, IIndex <K> index, IEnumerable <K> keys, Deedle.Direction dir, VectorConstruction vector, Func <Tuple <K, Tuple <IIndex <K>, VectorConstruction> >, Tuple <TNewKey, R> > selector)
        {
            if (!index.IsOrdered)
            {
                throw new InvalidOperationException("Resampling is only supported on ordered indices");
            }
            IIndexBuilder    indexBuilder = (IIndexBuilder)this;
            IEnumerable <M1> m1s;

            if (dir == Deedle.Direction.Forward)
            {
                IEnumerable <Tuple <K, long> > tuples = (IEnumerable <Tuple <K, long> >)SeqModule.Map <K, Tuple <K, long> >((Func <M0, M1>) new LinearIndex.keyLocations <K>(index), keys);
                m1s = SeqModule.MapIndexed <Tuple <Tuple <K, long>, Tuple <K, long> >, Tuple <K, Tuple <long, long> > >((Func <int, Func <M0, M1> >) new LinearIndex.locations <K>(index), (IEnumerable <M0>)SeqModule.Pairwise <Tuple <K, long> >(SeqModule.Append <Tuple <K, long> >((IEnumerable <M0>)tuples, (IEnumerable <M0>)FSharpList <Tuple <K, long> > .Cons(new Tuple <K, long>(default(K), Addressing.LinearAddress.invalid), FSharpList <Tuple <K, long> > .get_Empty()))));
            }
            else
            {
                int keyLen = SeqModule.Length <K>(keys);
                IEnumerable <Tuple <K, long> > tuples = (IEnumerable <Tuple <K, long> >)SeqModule.Map <K, Tuple <K, long> >((Func <M0, M1>) new LinearIndex.keyLocations <K>(index), keys);
                m1s = SeqModule.MapIndexed <Tuple <Tuple <K, long>, Tuple <K, long> >, Tuple <K, Tuple <long, long> > >((Func <int, Func <M0, M1> >) new LinearIndex.locations <K>(index, keyLen), (IEnumerable <M0>)SeqModule.Pairwise <Tuple <K, long> >(SeqModule.Append <Tuple <K, long> >((IEnumerable <M0>)FSharpList <Tuple <K, long> > .Cons(new Tuple <K, long>(default(K), Addressing.LinearAddress.invalid), FSharpList <Tuple <K, long> > .get_Empty()), (IEnumerable <M0>)tuples)));
            }
            Tuple <K, Tuple <long, long> >[] tupleArray1 = (Tuple <K, Tuple <long, long> >[])ArrayModule.OfSeq <Tuple <K, Tuple <long, long> > >((IEnumerable <M0>)m1s);
            Func <Tuple <K, Tuple <long, long> >, Tuple <K, Tuple <IIndex <K>, VectorConstruction> > > Func1 = (Func <Tuple <K, Tuple <long, long> >, Tuple <K, Tuple <IIndex <K>, VectorConstruction> > >) new LinearIndex.vectorConstructions <K>(chunkBuilder, index);

            Tuple <K, Tuple <long, long> >[] tupleArray2 = tupleArray1;
            if ((object)tupleArray2 == null)
            {
                throw new ArgumentNullException("array");
            }
            Tuple <K, Tuple <IIndex <K>, VectorConstruction> >[] tupleArray3 = new Tuple <K, Tuple <IIndex <K>, VectorConstruction> > [tupleArray2.Length];
            for (int index1 = 0; index1 < tupleArray3.Length; ++index1)
            {
                tupleArray3[index1] = Func1.Invoke(tupleArray2[index1]);
            }
            Tuple <K, Tuple <IIndex <K>, VectorConstruction> >[] tupleArray4 = tupleArray3;
            Func <Tuple <K, Tuple <IIndex <K>, VectorConstruction> >, Tuple <TNewKey, R> > Func2 = selector;

            Tuple <K, Tuple <IIndex <K>, VectorConstruction> >[] tupleArray5 = tupleArray4;
            if ((object)tupleArray5 == null)
            {
                throw new ArgumentNullException("array");
            }
            Tuple <TNewKey, R>[] tupleArray6 = new Tuple <TNewKey, R> [tupleArray5.Length];
            for (int index1 = 0; index1 < tupleArray6.Length; ++index1)
            {
                tupleArray6[index1] = Func2.Invoke(tupleArray5[index1]);
            }
            Tuple <TNewKey, R>[]         tupleArray7    = tupleArray6;
            IIndex <TNewKey>             index2         = indexBuilder.Create <TNewKey>(SeqModule.Map <Tuple <TNewKey, R>, TNewKey>((Func <M0, M1>) new LinearIndex.newIndex <TNewKey, R>(), (IEnumerable <M0>)tupleArray7), (FSharpOption <bool>)null);
            IVectorBuilder               vectorBuilder1 = this.vectorBuilder;
            Func <Tuple <TNewKey, R>, R> Func3          = (Func <Tuple <TNewKey, R>, R>) new LinearIndex.vect <TNewKey, R>();

            Tuple <TNewKey, R>[] tupleArray8 = tupleArray7;
            if ((object)tupleArray8 == null)
            {
                throw new ArgumentNullException("array");
            }
            R[]            optionalValueArray = new R[tupleArray8.Length];
            IVectorBuilder vectorBuilder2     = vectorBuilder1;

            for (int index1 = 0; index1 < optionalValueArray.Length; ++index1)
            {
                optionalValueArray[index1] = Func3.Invoke(tupleArray8[index1]);
            }
            IVector <R> missing = vectorBuilder2.CreateMissing <R>(optionalValueArray);

            return(new Tuple <IIndex <TNewKey>, IVector <R> >(index2, missing));
        }
예제 #15
0
 IIndex <K> IIndexBuilder.Create <K>(IEnumerable <K> keys, FSharpOption <bool> ordered)
 {
     return((IIndex <K>) new LinearIndex <K>(System.Array.AsReadOnly <K>(ArrayModule.OfSeq <K>(keys)), (IIndexBuilder)this, ordered));
 }
예제 #16
0
        public string TestSimpleRolling(int reel, string triggerOns)
        {
            var stripId = 6;
            var strips  = MainGame.strips(stripId).ToList();
            var reel1   = strips[0];
            var reel2   = strips[1];
            var reel3   = strips[2];
            var reel4   = strips[3];
            var reel5   = strips[4];
            var reels   = new List <int[]>();

            reels.Add(Global.takeRolling(1, 3, reel1));
            reels.Add(Global.takeRolling(3, 3, reel2));
            reels.Add(Global.takeRolling(5, 3, reel3));
            reels.Add(Global.takeRolling(7, 3, reel4));
            reels.Add(Global.takeRolling(9, 3, reel5));
            var reelRollings = new [] {
                new Domain.Rolling(1, 3),
                new Domain.Rolling(3, 3),
                new Domain.Rolling(5, 3),
                new Domain.Rolling(7, 3),
                new Domain.Rolling(9, 3)
            };
            var wheel   = new Games.Wolves.Domain.WolvesWheel(1, ListModule.OfSeq(reels), ListModule.OfSeq(new List <int[]>()), ArrayModule.OfSeq(reelRollings));
            var regions = new List <Domain.Region>();

            foreach (var rolling in triggerOns.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries))
            {
                regions.Add(new Domain.Region(reel, rolling.Split(new char[] { ',' }, System.StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray()));
            }
            ;

            // Action
            var wheelRolling = Rolling.breakWinning(regions.ToArray(), wheel);
            var wheelFilled  = Games.Wolves.ParSheet.fillUpForMainGame(stripId, wheelRolling);

            // Assert
            return(string.Concat(string.Join(',', wheelFilled.Reels[reel]), "|", string.Join(',', wheelFilled.Collapsing[reel])));
        }
예제 #17
0
        public decimal TestFullcycleRollingFreeGameParsheetRtp(int stripId)
        {
            var strips          = FreeGame.Strips(stripId).ToList();
            var totalBet        = 0.0m;
            var totalWin        = 0.0m;
            var totalRollingWin = 0.0m;
            var rollingHits     = 0;
            var totalSpin       = 0m;
            var reel1           = strips[0];
            var reel2           = strips[1];
            var reel3           = strips[2];
            var reel4           = strips[3];
            var reel5           = strips[4];
            var profile         = new Dictionary <int, int>();
            var totalRolling    = 0;

            for (int i1 = 0; i1 < reel1.Length; i1++)
            {
                for (int i2 = 0; i2 < reel2.Length; i2++)
                {
                    for (int i3 = 0; i3 < reel3.Length; i3++)
                    {
                        for (int i4 = 0; i4 < reel4.Length; i4++)
                        {
                            for (int i5 = 0; i5 < reel5.Length; i5++)
                            {
                                totalSpin++;
                                totalBet += 25m;
                                var reels = new List <int[]>();
                                reels.Add(Global.takeRolling(i1, 3, reel1));
                                reels.Add(Global.takeRolling(i2, 3, reel2));
                                reels.Add(Global.takeRolling(i3, 3, reel3));
                                reels.Add(Global.takeRolling(i4, 3, reel4));
                                reels.Add(Global.takeRolling(i5, 3, reel5));
                                var result = Payout.calculate(1, 1, ListModule.OfSeq(reels));
                                totalWin += result.Payable;

                                if (result.Payable > 0)
                                {
                                    rollingHits++;
                                    totalRolling = 1;
                                    var multiplier   = 1;
                                    var reelRollings = new []
                                    {
                                        new Domain.Rolling(i1, 3),
                                        new Domain.Rolling(i2, 3),
                                        new Domain.Rolling(i3, 3),
                                        new Domain.Rolling(i4, 3),
                                        new Domain.Rolling(i5, 3)
                                    };
                                    var wheel        = new Games.Wolves.Domain.WolvesWheel(1, ListModule.OfSeq(reels), ListModule.OfSeq(new List <int[]>()), ArrayModule.OfSeq(reelRollings));
                                    var regions      = result.WinPositions.Select(item => new Domain.Region(1, item.RowPositions.ToArray())).ToArray();
                                    var wheelRolling = Games.Wolves.Rolling.breakWinning(regions.ToArray(), wheel);
                                    var wheelFilled  = Games.Wolves.ParSheet.fillUpForFreeGame(stripId, wheelRolling);
                                    do
                                    {
                                        if (multiplier < 5)
                                        {
                                            multiplier++;
                                        }
                                        else
                                        {
                                            multiplier = 10;
                                        }
                                        var rollingResult = Payout.calculate(1, multiplier, wheelFilled.Reels);
                                        if (rollingResult.Payable == 0)
                                        {
                                            break;
                                        }
                                        totalRolling++;
                                        totalRollingWin += rollingResult.Payable;
                                        regions          = rollingResult.WinPositions.Select(item => new Domain.Region(1, item.RowPositions.ToArray())).ToArray();
                                        wheel            = Games.Wolves.Rolling.breakWinning(regions.ToArray(), wheelFilled);
                                        wheelFilled      = Games.Wolves.ParSheet.fillUpForFreeGame(stripId, wheel);
                                    } while (true);
                                    if (!profile.ContainsKey(totalRolling))
                                    {
                                        profile[totalRolling] = 0;
                                    }
                                    profile[totalRolling]++;
                                }
                            }
                        }
                    }
                }
            }
            foreach (var item in profile.OrderBy(item => item.Key))
            {
                Console.WriteLine(String.Format("Tumble Hit  {0}: {1}", item.Key, item.Value));
            }
            Console.WriteLine(String.Format("Rolling Hit Rate    : {0,12:0.0000000000}", rollingHits == 0 ? 0 : totalSpin / rollingHits));
            Console.WriteLine(String.Format("RTP.Main            : {0,12:0.0000000000}", 100 * totalWin / totalBet));
            Console.WriteLine(String.Format("RTP.Rolling         : {0,12:0.0000000000}", 100 * totalRollingWin / totalBet));
            return(Math.Round(100 * totalRollingWin / totalBet, 4));
        }
예제 #18
0
        public void TestExecuteBonus()
        {
            // Arrange
            var spinResult = new BearResult("s");
            var user       = new UserGameKey(-1, 103);
            var reels      = new List <int[]>
            {
                new[] { 0, 6, 10 },
                new[] { 6, 11, 12 },
                new[] { 6, 11, 13 },
                new[] { 9, 11, 12, },
                new[] { 12, 10, 13 }
            };

            spinResult.Bonus          = new Stake(Guid.NewGuid(), 3);
            spinResult.Bonus.Count    = 15;
            spinResult.Wheel          = new BearWheel(1, ArrayModule.OfSeq(reels));
            spinResult.BonusPositions = new List <BonusPosition> {
                new BonusPosition {
                    Line = 1, Multiplier = 1, RowPositions = new List <int> {
                        0, 2, 2, 2, 0
                    }
                }
            };
            spinResult.SpinBet = new SpinBet(user, PlatformType.None)
            {
                Lines   = 25,
                LineBet = 1.0m
            };
            var userSession = new UserSession
            {
                SessionKey = "unittest",
                UserId     = -1
            };
            var requestContext = new RequestContext <SpinArgs>("simulation", "Bonus Bear", PlatformType.None)
            {
                GameSetting = new GameSetting {
                    GameSettingGroupId = 1
                },
                Query = new QueryCollection {
                },
                Game  = new Game {
                    Id = 103
                }
            };
            var requestBonusContext = new RequestContext <BonusArgs>("unittest", "Bonus Bear", PlatformType.None)
            {
                GameSetting = new GameSetting {
                    GameSettingGroupId = 1
                },
                Query = new QueryCollection {
                },
            };

            requestBonusContext.UserSession = userSession;
            requestBonusContext.UserGameKey = user;
            var bonus = module.CreateBonus(spinResult).Value;

            var entity = new BonusEntity
            {
                UserId       = userSession.UserId,
                GameId       = requestContext.Game.Id,
                Guid         = bonus.Guid.ToString("N"),
                Data         = Model.Utility.Extension.ToByteArray(bonus),
                BonusType    = bonus.GetType().Name,
                Version      = 3,
                IsOptional   = bonus.IsOptional,
                IsStarted    = bonus.IsStarted,
                RoundId      = 1,
                BetReference = ""
            };

            // action
            var result = module.ExecuteBonus(1, entity, requestBonusContext).Value as BearSeqFreeSpinResult;

            // assert
            Assert.NotNull(result);
            Assert.AreEqual(true, ((Domain.BearBonus)result.Bonus).State.IsFreeSpin);
            Assert.IsTrue(result.Type == "fs");
        }
예제 #19
0
        Tuple <IIndex <TNewKey>, IVector <R> > IIndexBuilder.Aggregate <K, TNewKey, R>(IIndex <K> index, Aggregation <K> aggregation, VectorConstruction vector, Func <Tuple <DataSegmentKind, Tuple <IIndex <K>, VectorConstruction> >, Tuple <TNewKey, R> > selector)
        {
            if (!index.IsOrdered)
            {
                throw new InvalidOperationException("Floating window aggregation and chunking is only supported on ordered indices. Consider sorting the series before calling the operation.");
            }
            IIndexBuilder   indexBuilder1 = (IIndexBuilder)this;
            Aggregation <K> aggregation1  = aggregation;
            IEnumerable <Tuple <DataSegmentKind, long, long> > tuples1;

            switch (aggregation1.get_Tag())
            {
            case 0:
                Aggregation <K> .WindowSize windowSize = (Aggregation <K> .WindowSize)aggregation1;
                tuples1 = Seq.windowRangesWithBounds((long)windowSize.item1, windowSize.item2, index.KeyCount);
                break;

            case 2:
                tuples1 = (IEnumerable <Tuple <DataSegmentKind, long, long> >)SeqModule.Map <Tuple <long, long>, Tuple <DataSegmentKind, long, long> >((Func <M0, M1>) new LinearIndex.locations(), (IEnumerable <M0>)Seq.windowRangesWhile <K>(((Aggregation <K> .WindowWhile)aggregation1).item, (IEnumerable <K>)index.Keys));
                break;

            case 3:
                tuples1 = (IEnumerable <Tuple <DataSegmentKind, long, long> >)SeqModule.Map <Tuple <long, long>, Tuple <DataSegmentKind, long, long> >((Func <M0, M1>) new LinearIndex.locations(), (IEnumerable <M0>)Seq.chunkRangesWhile <K>(((Aggregation <K> .ChunkWhile)aggregation1).item, (IEnumerable <K>)index.Keys));
                break;

            default:
                Aggregation <K> .ChunkSize chunkSize = (Aggregation <K> .ChunkSize)aggregation1;
                tuples1 = Seq.chunkRangesWithBounds((long)chunkSize.item1, chunkSize.item2, index.KeyCount);
                break;
            }
            IEnumerable <Tuple <DataSegmentKind, long, long> > tuples2 = tuples1;
            IEnumerable <Tuple <DataSegmentKind, Tuple <IIndex <K>, VectorConstruction> > > tuples3 = (IEnumerable <Tuple <DataSegmentKind, Tuple <IIndex <K>, VectorConstruction> > >)SeqModule.Map <Tuple <DataSegmentKind, long, long>, Tuple <DataSegmentKind, Tuple <IIndex <K>, VectorConstruction> > >((Func <M0, M1>) new LinearIndex.vectorConstructions <K>(index, vector), (IEnumerable <M0>)tuples2);

            Tuple <TNewKey, R>[] tupleArray1         = (Tuple <TNewKey, R>[])ArrayModule.OfSeq <Tuple <TNewKey, R> >((IEnumerable <M0>)SeqModule.Map <Tuple <DataSegmentKind, Tuple <IIndex <K>, VectorConstruction> >, Tuple <TNewKey, R> >((Func <M0, M1>)selector, (IEnumerable <M0>)tuples3));
            IIndexBuilder        indexBuilder2       = indexBuilder1;
            Func <Tuple <TNewKey, R>, TNewKey> Func1 = (Func <Tuple <TNewKey, R>, TNewKey>) new LinearIndex.newIndex <TNewKey, R>();

            Tuple <TNewKey, R>[] tupleArray2 = tupleArray1;
            if ((object)tupleArray2 == null)
            {
                throw new ArgumentNullException("array");
            }
            TNewKey[]     array         = new TNewKey[tupleArray2.Length];
            IIndexBuilder indexBuilder3 = indexBuilder2;

            for (int index1 = 0; index1 < array.Length; ++index1)
            {
                array[index1] = Func1.Invoke(tupleArray2[index1]);
            }
            IIndex <TNewKey>             index2         = indexBuilder3.Create <TNewKey>(System.Array.AsReadOnly <TNewKey>(array), (FSharpOption <bool>)null);
            IVectorBuilder               vectorBuilder1 = this.vectorBuilder;
            Func <Tuple <TNewKey, R>, R> Func2          = (Func <Tuple <TNewKey, R>, R>) new LinearIndex.vect <TNewKey, R>();

            Tuple <TNewKey, R>[] tupleArray3 = tupleArray1;
            if ((object)tupleArray3 == null)
            {
                throw new ArgumentNullException("array");
            }
            R[]            optionalValueArray = new R[tupleArray3.Length];
            IVectorBuilder vectorBuilder2     = vectorBuilder1;

            for (int index1 = 0; index1 < optionalValueArray.Length; ++index1)
            {
                optionalValueArray[index1] = Func2.Invoke(tupleArray3[index1]);
            }
            IVector <R> missing = vectorBuilder2.CreateMissing <R>(optionalValueArray);

            return(new Tuple <IIndex <TNewKey>, IVector <R> >(index2, missing));
        }
예제 #20
0
        ReadOnlyCollection <Tuple <TNewKey, Tuple <IIndex <K>, VectorConstruction> > > IIndexBuilder.GroupBy <K, TNewKey>(IIndex <K> index, Func <K, TNewKey> keySel, VectorConstruction vector)
        {
            IIndexBuilder builder = (IIndexBuilder)this;

            LinearIndex.windows <K, TNewKey>                 windows336 = new LinearIndex.windows <K, TNewKey>();
            ReadOnlyCollection <K>                           keys       = index.Keys;
            IEnumerable <Tuple <M1, IEnumerable <M0> > >     tuples1    = SeqModule.GroupBy <K, TNewKey>((Func <M0, M1>)keySel, (IEnumerable <M0>)keys);
            IEnumerable <Tuple <TNewKey, IEnumerable <K> > > tuples2    = (IEnumerable <Tuple <TNewKey, IEnumerable <K> > >)SeqModule.Choose <Tuple <TNewKey, IEnumerable <K> >, Tuple <TNewKey, IEnumerable <K> > >((Func <M0, FSharpOption <M1> >)windows336, (IEnumerable <M0>)tuples1);

            return(System.Array.AsReadOnly <Tuple <TNewKey, Tuple <IIndex <K>, VectorConstruction> > >((Tuple <TNewKey, Tuple <IIndex <K>, VectorConstruction> >[])ArrayModule.OfSeq <Tuple <TNewKey, Tuple <IIndex <K>, VectorConstruction> > >((IEnumerable <M0>)SeqModule.Map <Tuple <TNewKey, IEnumerable <K> >, Tuple <TNewKey, Tuple <IIndex <K>, VectorConstruction> > >((Func <M0, M1>) new LinearIndex.DeedleIndicesIIndexBuilderGroupBy <K, TNewKey>(index, vector, builder), (IEnumerable <M0>)tuples2))));
        }