public void Init() { PaytableBuilder builder = new PickPaytableBuilder(); pickEvaluator = new PickEvaluator("Pick Feature"); paytable = new Paytable(); paytable.PickTableGroup = builder.BuildPickTableGroup(); }
public SlotResult Evaluate(Paytable paytable, ReelWindow reelWindow, IRng rng) { if (paytable.ScatterComboGroup == null) { throw new Exception("ScatterEvaluator cannot evalate a paytable without a ScatterComboGroup"); } SlotResult result = new SlotResult(); ScattersComponent component = new ScattersComponent(); List <PayCombo> payCombos = paytable.ScatterComboGroup.Combos; for (int combo = 0; combo < payCombos.Count; ++combo) { PayCombo payCombo = payCombos[combo]; int bestPayAmount = 0; PayCombo bestPayCombo = null; // TODO: This assumes the scatter combo contains one type of symbol only. // In almost all cases, this will be true so leaving it for now. bool match = false; Symbol symbol = payCombo.SymbolsInPayCombo[0]; if (reelWindow.SymbolPositions.ContainsKey(symbol) && reelWindow.SymbolPositions[symbol].Count >= payCombo.SymbolsInPayCombo.Count) { match = true; } if (match && (payCombo.PayAmount >= bestPayAmount)) { bestPayCombo = payCombo; bestPayAmount = payCombo.PayAmount; } if (bestPayCombo != null) { // TODO: Might be able to optimize this but making PaylineCoord and SymbolPosition the same thing... Payline payline = new Payline(); foreach (var position in reelWindow.SymbolPositions[symbol]) { payline.AddPaylineCoord(new PaylineCoord { ReelIndex = position.ReelIndex, Offset = position.ReelOffset }); } component.PayResults.Add(new PayResult { PayCombo = bestPayCombo, Payline = payline }); result.TotalWin += bestPayCombo.PayAmount; } } if (component.PayResults.Count > 0) { result.AddComponent <ScattersComponent>(component); } return(result); }
public void Init() { rng = new Rng(); paytable = new Paytable(); PaytableBuilder builder = new GamePaytableBuilder(); paytable.BaseGameReelGroup = builder.BuildBGReelGroup(); paytable.PaylineGroup = builder.BuildPaylineGroup(); paytable.PayComboGroup = builder.BuildPayComboGroup(); paytable.ScatterComboGroup = builder.BuildScatterComboGroup(); }
public SlotResult Evaluate(Paytable paytable, ReelWindow reelWindow, IRng rng) { if (paytable.PayComboGroup == null) { throw new Exception("PaylineEvaluator cannot evalate a paytable without a PayComboGroup"); } SlotResult result = new SlotResult(); PaylinesComponent component = new PaylinesComponent(); // Iterate through each payline defined in the paytable. List <Payline> paylines = paytable.PaylineGroup.Paylines; foreach (Payline payline in paylines) { // Get the list of symbols on the payline. List <Symbol> symbolsInPayline = reelWindow.GetSymbolsInPayline(payline); // Look for the highest pay amount on a given payline. int bestPayAmount = 0; PayCombo bestPayCombo = null; List <PayCombo> payCombos = paytable.PayComboGroup.Combos; foreach (PayCombo payCombo in payCombos) { bool match = payCombo.IsMatch(paytable.PayComboGroup.SymbolComparer, symbolsInPayline); if (match && (payCombo.PayAmount > bestPayAmount)) { // Update the best pay combo so far. bestPayCombo = payCombo; bestPayAmount = payCombo.PayAmount; } } // Add the best pay combo. if (bestPayCombo != null) { component.PayResults.Add(new PayResult { PayCombo = bestPayCombo, Payline = payline }); result.TotalWin += bestPayCombo.PayAmount; } } if (component.PayResults.Count > 0) { result.AddComponent <PaylinesComponent>(component); } return(result); }
/// <summary> /// Given a list of <see cref="PlayingCard"/> s, evaluate the cards then set both the /// <see cref="Evaluation"/> and <see cref="WinningPayline"/> properties. /// </summary> /// <param name="cards">The cards to evaluate- Must be 5 in the list.</param> /// <param name="paytable"> /// The Paytable to use to evaluate the cards for a win amount /// </param> public virtual void Evaluate(IList <PlayingCard> cards, Paytable paytable) { lock (m_lock) { //Log.Debug( $"Evaluating cards: {cards.JoinAsString( " " )}" ); Evaluation = new Evaluation(); WinningPayline = null; AnalyzeCards(cards); WinningPayline = paytable?.Apply(Evaluation); } }
public void Init() { paytable = new Paytable(); scatterEvaluator = new ScatterEvaluator(); rng = new Rng(); PaytableBuilder builder = new ScatterPaytableBuilder(); paytable.BaseGameReelGroup = builder.BuildBGReelGroup(); paytable.PaylineGroup = builder.BuildPaylineGroup(); paytable.PayComboGroup = builder.BuildPayComboGroup(); paytable.ScatterComboGroup = builder.BuildScatterComboGroup(); paytable.PickTableGroup = builder.BuildPickTableGroup(); paytable.PaytableTriggerGroup = builder.BuildPaytableTriggerGroup(); }
public SlotResult Evaluate(Paytable paytable, ReelWindow reelWindow, IRng rng) { //PaylineEvaluator paylineEvaluator = new PaylineEvaluator (); //ScatterEvaluator scatterEvaluator = new ScatterEvaluator (); //SlotResults paylineResults; //SlotResults scatterResults; //paylineResults = paylineEvaluator.Evaluate (paytable, rng); //scatterResults = scatterEvaluator.Evaluate (paytable, rng); // TODO: Get all triggers from the results // TODO: Evaluate those triggers in turn. // Try to keep the SlotResults separate, possibly in a list as this will assist with // the presentation being able to pull apart the results later. //return paylineResults; throw new NotImplementedException(); }
public SlotResult Evaluate(Paytable paytable, ReelWindow reelWindow, IRng rng) { if (paytable.PickTableGroup.PickTable.ContainsKey(PickFeatureId) == false) { // Can't evaluate if it doesn't exist in paytable. return(null); } PickTable pickTable = paytable.PickTableGroup.PickTable [PickFeatureId]; // Make a copy of the list since we will be removing elements from it. List <PickItem> pickItems = new List <PickItem> (pickTable.PickItemList); PickItem item; PickComponent component = new PickComponent(); do { // Continue picking items until a trigger is found. int randomNumber = rng.GetRandomNumber(pickItems.Count); item = pickItems [randomNumber]; pickItems.RemoveAt(randomNumber); component.PickResults.Add(new PickResult { Name = item.Name, Value = item.Value, Trigger = item.Trigger.Name }); } while (string.IsNullOrEmpty(item.Trigger.Name)); // Add the pick component to the slot result. SlotResult slotResult = new SlotResult(); if (component.PickResults.Count > 0) { slotResult.AddComponent <PickComponent>(component); } return(slotResult); }
private void InstallPaytable() { Paytable paytable = new Paytable(); paytable.BaseGameReelGroup = new ReelGroup(); paytable.BaseGameReelGroup.AddReel(new ReelStrip { Symbols = new List <Symbol> { new Symbol(0, "AA"), new Symbol(1, "BB"), new Symbol(2, "CC"), new Symbol(3, "DD"), new Symbol(3, "EE"), new Symbol(4, "FF"), new Symbol(5, "GG"), new Symbol(6, "HH") } }); paytable.BaseGameReelGroup.AddReel(new ReelStrip { Symbols = new List <Symbol> { new Symbol(0, "AA"), new Symbol(1, "BB"), new Symbol(2, "CC"), new Symbol(3, "DD"), new Symbol(3, "EE"), new Symbol(4, "FF"), new Symbol(5, "GG"), new Symbol(6, "HH") } }); paytable.BaseGameReelGroup.AddReel(new ReelStrip { Symbols = new List <Symbol> { new Symbol(0, "AA"), new Symbol(1, "BB"), new Symbol(2, "CC"), new Symbol(3, "DD"), new Symbol(3, "EE"), new Symbol(4, "FF"), new Symbol(5, "GG"), new Symbol(6, "HH") } }); paytable.BaseGameReelGroup.AddReel(new ReelStrip { Symbols = new List <Symbol> { new Symbol(0, "AA"), new Symbol(1, "BB"), new Symbol(2, "CC"), new Symbol(3, "DD"), new Symbol(3, "EE"), new Symbol(4, "FF"), new Symbol(5, "GG"), new Symbol(6, "HH") } }); paytable.BaseGameReelGroup.AddReel(new ReelStrip { Symbols = new List <Symbol> { new Symbol(0, "AA"), new Symbol(1, "BB"), new Symbol(2, "CC"), new Symbol(3, "DD"), new Symbol(3, "EE"), new Symbol(4, "FF"), new Symbol(5, "GG"), new Symbol(6, "HH") } }); Container.Bind <Paytable>().FromInstance(paytable); }
public void Init() { rng = new Rng(); paylineEvaluator = new PaylineEvaluator(); paytable = new Paytable(); // Reels ReelGroup reels = new ReelGroup(); ReelStrip reel = new ReelStrip(); reel.AddSymbol(new Symbol(0, "AA")); reel.AddSymbol(new Symbol(1, "BB")); reel.AddSymbol(new Symbol(2, "CC")); reels.AddReel(reel); reels.AddReel(reel); reels.AddReel(reel); reels.AddReel(reel); reels.AddReel(reel); // Paylines PaylineGroup paylines = new PaylineGroup(); Payline payline1 = new Payline(); payline1.AddPaylineCoord(new PaylineCoord { ReelIndex = 0, Offset = 0 }); payline1.AddPaylineCoord(new PaylineCoord { ReelIndex = 1, Offset = 0 }); payline1.AddPaylineCoord(new PaylineCoord { ReelIndex = 2, Offset = 0 }); payline1.AddPaylineCoord(new PaylineCoord { ReelIndex = 3, Offset = 0 }); payline1.AddPaylineCoord(new PaylineCoord { ReelIndex = 4, Offset = 0 }); Payline payline2 = new Payline(); payline2.AddPaylineCoord(new PaylineCoord { ReelIndex = 0, Offset = 1 }); payline2.AddPaylineCoord(new PaylineCoord { ReelIndex = 1, Offset = 1 }); payline2.AddPaylineCoord(new PaylineCoord { ReelIndex = 2, Offset = 1 }); payline2.AddPaylineCoord(new PaylineCoord { ReelIndex = 3, Offset = 1 }); payline2.AddPaylineCoord(new PaylineCoord { ReelIndex = 4, Offset = 1 }); Payline payline3 = new Payline(); payline3.AddPaylineCoord(new PaylineCoord { ReelIndex = 0, Offset = 2 }); payline3.AddPaylineCoord(new PaylineCoord { ReelIndex = 1, Offset = 2 }); payline3.AddPaylineCoord(new PaylineCoord { ReelIndex = 2, Offset = 2 }); payline3.AddPaylineCoord(new PaylineCoord { ReelIndex = 3, Offset = 2 }); payline3.AddPaylineCoord(new PaylineCoord { ReelIndex = 4, Offset = 2 }); Payline payline4 = new Payline(); payline4.AddPaylineCoord(new PaylineCoord { ReelIndex = 0, Offset = 0 }); payline4.AddPaylineCoord(new PaylineCoord { ReelIndex = 1, Offset = 1 }); payline4.AddPaylineCoord(new PaylineCoord { ReelIndex = 2, Offset = 2 }); payline4.AddPaylineCoord(new PaylineCoord { ReelIndex = 3, Offset = 1 }); payline4.AddPaylineCoord(new PaylineCoord { ReelIndex = 4, Offset = 0 }); Payline payline5 = new Payline(); payline5.AddPaylineCoord(new PaylineCoord { ReelIndex = 0, Offset = 2 }); payline5.AddPaylineCoord(new PaylineCoord { ReelIndex = 1, Offset = 1 }); payline5.AddPaylineCoord(new PaylineCoord { ReelIndex = 2, Offset = 0 }); payline5.AddPaylineCoord(new PaylineCoord { ReelIndex = 3, Offset = 1 }); payline5.AddPaylineCoord(new PaylineCoord { ReelIndex = 4, Offset = 2 }); paylines.AddPayline(payline1); paylines.AddPayline(payline2); paylines.AddPayline(payline3); paylines.AddPayline(payline4); paylines.AddPayline(payline5); // PayCombos PayComboGroup payCombos = new PayComboGroup(new SymbolComparer()); // AA payCombos.AddPayCombo(new PayCombo(new Symbol(0, "AA"), 5, 50)); payCombos.AddPayCombo(new PayCombo(new Symbol(0, "AA"), 4, 25)); payCombos.AddPayCombo(new PayCombo(new Symbol(0, "AA"), 3, 10)); // BB payCombos.AddPayCombo(new PayCombo(new Symbol(1, "BB"), 5, 15)); payCombos.AddPayCombo(new PayCombo(new Symbol(1, "BB"), 4, 10)); payCombos.AddPayCombo(new PayCombo(new Symbol(1, "BB"), 3, 5)); // CC payCombos.AddPayCombo(new PayCombo(new Symbol(2, "CC"), 5, 10)); payCombos.AddPayCombo(new PayCombo(new Symbol(2, "CC"), 4, 5)); payCombos.AddPayCombo(new PayCombo(new Symbol(2, "CC"), 3, 1)); paytable.BaseGameReelGroup = reels; paytable.PaylineGroup = paylines; paytable.PayComboGroup = payCombos; }
public void Init() { rng = new Rng(); paylineEvaluator = new PaylineEvaluator(); paytable = new Paytable(); // Reels ReelGroup reels = new ReelGroup(); ReelStrip reel = new ReelStrip(); reel.AddSymbol(new Symbol(0, "AA")); reel.AddSymbol(new Symbol(1, "BB")); reel.AddSymbol(new Symbol(2, "CC")); reels.AddReel(reel); reels.AddReel(reel); reels.AddReel(reel); reels.AddReel(reel); reels.AddReel(reel); // Paylines PaylineGroup paylines = new PaylineGroup(); Payline payline1 = new Payline(); payline1.AddPaylineCoord(new PaylineCoord { ReelIndex = 0, Offset = 0 }); payline1.AddPaylineCoord(new PaylineCoord { ReelIndex = 1, Offset = 0 }); payline1.AddPaylineCoord(new PaylineCoord { ReelIndex = 2, Offset = 0 }); payline1.AddPaylineCoord(new PaylineCoord { ReelIndex = 3, Offset = 0 }); payline1.AddPaylineCoord(new PaylineCoord { ReelIndex = 4, Offset = 0 }); Payline payline2 = new Payline(); payline2.AddPaylineCoord(new PaylineCoord { ReelIndex = 0, Offset = 1 }); payline2.AddPaylineCoord(new PaylineCoord { ReelIndex = 1, Offset = 1 }); payline2.AddPaylineCoord(new PaylineCoord { ReelIndex = 2, Offset = 1 }); payline2.AddPaylineCoord(new PaylineCoord { ReelIndex = 3, Offset = 1 }); payline2.AddPaylineCoord(new PaylineCoord { ReelIndex = 4, Offset = 1 }); Payline payline3 = new Payline(); payline3.AddPaylineCoord(new PaylineCoord { ReelIndex = 0, Offset = 2 }); payline3.AddPaylineCoord(new PaylineCoord { ReelIndex = 1, Offset = 2 }); payline3.AddPaylineCoord(new PaylineCoord { ReelIndex = 2, Offset = 2 }); payline3.AddPaylineCoord(new PaylineCoord { ReelIndex = 3, Offset = 2 }); payline3.AddPaylineCoord(new PaylineCoord { ReelIndex = 4, Offset = 2 }); Payline payline4 = new Payline(); payline4.AddPaylineCoord(new PaylineCoord { ReelIndex = 0, Offset = 0 }); payline4.AddPaylineCoord(new PaylineCoord { ReelIndex = 1, Offset = 1 }); payline4.AddPaylineCoord(new PaylineCoord { ReelIndex = 2, Offset = 2 }); payline4.AddPaylineCoord(new PaylineCoord { ReelIndex = 3, Offset = 1 }); payline4.AddPaylineCoord(new PaylineCoord { ReelIndex = 4, Offset = 0 }); Payline payline5 = new Payline(); payline5.AddPaylineCoord(new PaylineCoord { ReelIndex = 0, Offset = 2 }); payline5.AddPaylineCoord(new PaylineCoord { ReelIndex = 1, Offset = 1 }); payline5.AddPaylineCoord(new PaylineCoord { ReelIndex = 2, Offset = 0 }); payline5.AddPaylineCoord(new PaylineCoord { ReelIndex = 3, Offset = 1 }); payline5.AddPaylineCoord(new PaylineCoord { ReelIndex = 4, Offset = 2 }); paylines.AddPayline(payline1); paylines.AddPayline(payline2); paylines.AddPayline(payline3); paylines.AddPayline(payline4); paylines.AddPayline(payline5); // PayCombos ISymbolComparer comparer = new SymbolComparer(); comparer.Substitute(new Symbol(0, "AA"), new Symbol(3, "MX")); comparer.Substitute(new Symbol(1, "BB"), new Symbol(3, "MX")); PayComboGroup payCombos = new PayComboGroup(comparer); // AA payCombos.AddPayCombo(new PayCombo(new Symbol(0, "AA"), 5, 200)); payCombos.AddPayCombo(new PayCombo(new Symbol(0, "AA"), 4, 150)); payCombos.AddPayCombo(new PayCombo(new Symbol(0, "AA"), 3, 100)); // BB payCombos.AddPayCombo(new PayCombo(new Symbol(1, "BB"), 5, 175)); payCombos.AddPayCombo(new PayCombo(new Symbol(1, "BB"), 4, 125)); payCombos.AddPayCombo(new PayCombo(new Symbol(1, "BB"), 3, 85)); // CC payCombos.AddPayCombo(new PayCombo(new Symbol(2, "CC"), 5, 130)); payCombos.AddPayCombo(new PayCombo(new Symbol(2, "CC"), 4, 80)); payCombos.AddPayCombo(new PayCombo(new Symbol(2, "CC"), 3, 30)); // MX payCombos.AddPayCombo(new PayCombo(new Symbol(3, "MX"), 5, 44)); payCombos.AddPayCombo(new PayCombo(new Symbol(3, "MX"), 4, 33)); payCombos.AddPayCombo(new PayCombo(new Symbol(3, "MX"), 3, 22)); paytable.BaseGameReelGroup = reels; paytable.PaylineGroup = paylines; paytable.PayComboGroup = payCombos; }
public SlotResult Evaluate(Paytable paytable, ReelWindow reelWindow, IRng rng) { throw new System.NotImplementedException(); }
public void Init() { rng = new Rng(); paylineEvaluator = new PaylineEvaluator(); paytable = new Paytable(); // Reels ReelGroup reels = new ReelGroup(); ReelStrip reel = new ReelStrip(); reel.AddSymbol(new Symbol(0, "AA")); reel.AddSymbol(new Symbol(1, "BB")); reel.AddSymbol(new Symbol(2, "CC")); reel.AddSymbol(new Symbol(3, "WW")); reels.AddReel(reel); reels.AddReel(reel); reels.AddReel(reel); reels.AddReel(reel); reels.AddReel(reel); // Paylines PaylineGroup paylines = new PaylineGroup(); Payline payline1 = new Payline(); payline1.AddPaylineCoord(new PaylineCoord { ReelIndex = 0, Offset = 0 }); payline1.AddPaylineCoord(new PaylineCoord { ReelIndex = 1, Offset = 0 }); payline1.AddPaylineCoord(new PaylineCoord { ReelIndex = 2, Offset = 0 }); payline1.AddPaylineCoord(new PaylineCoord { ReelIndex = 3, Offset = 0 }); payline1.AddPaylineCoord(new PaylineCoord { ReelIndex = 4, Offset = 0 }); paylines.AddPayline(payline1); // PayCombos ISymbolComparer comparer = new SymbolComparer(); comparer.Substitute(new Symbol(3, "WW"), new Symbol(0, "AA")); comparer.Substitute(new Symbol(3, "WW"), new Symbol(0, "BB")); comparer.Substitute(new Symbol(3, "WW"), new Symbol(0, "CC")); PayComboGroup payCombos = new PayComboGroup(comparer); // WW payCombos.AddPayCombo(new PayCombo(new Symbol(3, "WW"), 5, 1000)); payCombos.AddPayCombo(new PayCombo(new Symbol(3, "WW"), 4, 500)); payCombos.AddPayCombo(new PayCombo(new Symbol(3, "WW"), 3, 100)); // AA payCombos.AddPayCombo(new PayCombo(new Symbol(0, "AA"), 5, 50)); payCombos.AddPayCombo(new PayCombo(new Symbol(0, "AA"), 4, 25)); payCombos.AddPayCombo(new PayCombo(new Symbol(0, "AA"), 3, 10)); // BB payCombos.AddPayCombo(new PayCombo(new Symbol(1, "BB"), 5, 15)); payCombos.AddPayCombo(new PayCombo(new Symbol(1, "BB"), 4, 10)); payCombos.AddPayCombo(new PayCombo(new Symbol(1, "BB"), 3, 5)); // CC payCombos.AddPayCombo(new PayCombo(new Symbol(2, "CC"), 5, 10)); payCombos.AddPayCombo(new PayCombo(new Symbol(2, "CC"), 4, 5)); payCombos.AddPayCombo(new PayCombo(new Symbol(2, "CC"), 3, 1)); paytable.BaseGameReelGroup = reels; paytable.PaylineGroup = paylines; paytable.PayComboGroup = payCombos; }
public void TestPaytableStructure() { Paytable paytable = new Paytable(); Strip strip = new Strip(); strip.Name = "Strip1"; strip.BaseStrip = new BaseStrip(); var stop1 = new Stop { Id = "AA", Weight = 1, }; strip.BaseStrip.Stops.Add(stop1); var stop2 = new Stop { Id = "AB", Weight = 1, }; strip.BaseStrip.Stops.Add(stop2); var stop3 = new Stop { Id = "AC", Weight = 1, }; strip.BaseStrip.Stops.Add(stop3); strip.ShootStrip = new PickStrip(); strip.ShootStrip.Stops.Add(new Stop { Id = "AA", Weight = 1, }); paytable.Strips.Add(strip); var prize = new PrizeDefinition(); prize.Symbol = "AA"; prize.RequiredCount = 3; prize.WinAmount = 10; prize.WinLevel = 1; prize.AwardStrategy = "TimesOnBetOnBall"; paytable.Prizes.Add(prize); var serializer = new XmlSerializer(typeof(Paytable)); var settings = new XmlWriterSettings(); settings.NewLineChars = System.Environment.NewLine; settings.Indent = true; var outputStr = new StringBuilder(); using (var writer = XmlWriter.Create(outputStr, settings)) { serializer.Serialize(writer, paytable); } var expectedStr = System.IO.File.ReadAllText("ExpectedTestPaytable.xml"); Assert.Equal <string>(expectedStr, outputStr.ToString()); }