Example #1
0
        public static Situation evaluateSituation(Image tableImage, Table table, List <TableControl> controls, double bigblind)
        {
            // street
            StreetTypes street = getStreetType(table);

            // hand
            HandAnalysis analysis = HandEvaluator.evalHandSmart(table.Hand, table.Community);

            // opponents
            int opponents = (street == StreetTypes.Preflop ?
                             getPreflopNumberOfOpponents(table) :
                             getPostflopNumberOfOpponents(table));

            // action
            OpponentActionTypes action = (street == StreetTypes.Preflop ?
                                          getPreflopOpponentAction(tableImage, table, controls, bigblind) :
                                          getPostflopOpponentAction(tableImage, table, controls, bigblind));

            // position
            PositionTypes position = (street == StreetTypes.Preflop ?
                                      getPreflopPosition(table) :
                                      getPostflopPosition(table));

            return(new Situation(street, analysis.HandSmart, analysis.Chance, opponents, action, position));
        }
Example #2
0
		public CommandInfo (string command, PositionTypes min_position, CommandHandler pointer, int min_level, SubCommands subcmd)
		{
			Command = command;
			MinimumPosition = min_position;
			CommandPointer = pointer;
			MinimumLevel = min_level;
			SubCommand = subcmd;
		}
Example #3
0
            public Position(PositionTypes type)
            {
                for (int i = 0; i < 6; i++)
                {
                    Add(0);
                }

                Type = type;
            }
Example #4
0
        public PositionType AddPositionType(string name)
        {
            PositionType positionType = new PositionType()
            {
                PropertyName = name
            };

            PositionTypes.Add(positionType);
            return(positionType);
        }
Example #5
0
        public static List <Rule> readRules()
        {
            Log.Info("Reading spreadsheet '" + RULES_XLS + "'");
            Workbook    workbook  = Workbook.Load(RULES_XLS);
            Worksheet   worksheet = workbook.Worksheets[0];
            List <Rule> rules     = new List <Rule>();
            int         row       = 1;

            while (true)
            {
                // check
                if (isEmptyRow(worksheet, row))
                {
                    break;
                }
                Log.DebugIf(row % 100 == 0, "Reading row '" + (row + 1) + "'");

                // columns
                string hand     = worksheet.Cells[row, 2].StringValue;
                string street   = worksheet.Cells[row, 3].StringValue;
                string pot      = worksheet.Cells[row, 4].StringValue;
                string board    = worksheet.Cells[row, 5].StringValue;
                string opps     = worksheet.Cells[row, 6].StringValue;
                string action   = worksheet.Cells[row, 7].StringValue;
                string position = worksheet.Cells[row, 8].StringValue;
                string maxbet   = worksheet.Cells[row, 9].StringValue;
                string potsize  = worksheet.Cells[row, 10].StringValue;
                string decision = worksheet.Cells[row, 11].StringValue;

                // map
                StreetTypes         streetType   = mapStreetType(street);
                HandTypes           handType     = mapHandType(hand);
                ChanceTypes         chanceType   = mapChanceType(board);
                int                 minOpponents = mapMinOpponents(opps);
                int                 maxOpponents = mapMaxOpponents(opps);
                OpponentActionTypes actionType   = mapActionType(action);
                PositionTypes       positionType = mapPositionType(position);
                double              minMaxBet    = mapMinInterval(maxbet);
                double              maxMaxBet    = mapMaxInterval(maxbet);
                double              minPotSize   = mapMinInterval(potsize);
                double              maxPotSize   = mapMaxInterval(potsize);

                // rule
                Rule rule = new Rule(streetType, handType, chanceType, minOpponents,
                                     maxOpponents, actionType, positionType, minMaxBet, maxMaxBet,
                                     minPotSize, maxPotSize, decision);
                rules.Add(rule);

                // next
                row++;
            }
            Log.Info("Done reading spreadsheet");
            return(rules);
        }
Example #6
0
 public Situation(StreetTypes street, HandTypes hand,
                  ChanceTypes chance, int opponents,
                  OpponentActionTypes action, PositionTypes position)
 {
     this.street    = street;
     this.hand      = hand;
     this.chance    = chance;
     this.opponents = opponents;
     this.action    = action;
     this.position  = position;
 }
Example #7
0
        public void IsInFightingPosition(PositionTypes position, bool expectedValue)
        {
            var actor = new CharacterInstance(1, "TestNpc")
            {
                CurrentPosition = position
            };

            var list = new List <object> {
                actor
            };

            Assert.That(HelperFunctions.IsInFightingPosition(list), Is.EqualTo(expectedValue));
        }
Example #8
0
        /// <summary>
        /// Ensure that the database has the seeded values
        /// </summary>
        public void EnsureSeedData()
        {
            foreach (var type in Enum.GetValues(typeof(TeamType)).Cast <TeamType>())
            {
                var entry = TeamTypes.SingleOrDefault(t => t.Type == type);
                if (entry != null)
                {
                    // Database entry for enum value mismatch
                    if (entry.Name != Enum.GetName(typeof(TeamType), type))
                    {
                        throw new Exception("Database mapping to enum is incorrect");
                    }
                }
                else
                {
                    TeamTypes.Add(
                        new TeamTypeEntry
                    {
                        Type = type,
                        Name = Enum.GetName(typeof(TeamType), type)
                    });
                }
            }

            foreach (var type in Enum.GetValues(typeof(PositionType)).Cast <PositionType>())
            {
                var entry = PositionTypes.SingleOrDefault(t => t.Type == type);
                if (entry != null)
                {
                    // Database entry for enum value mismatch
                    if (entry.Name != Enum.GetName(typeof(PositionType), type))
                    {
                        throw new Exception("Database mapping to enum is incorrect");
                    }
                }
                else
                {
                    PositionTypes.Add(
                        new PositionTypeEntry
                    {
                        Type = type,
                        Name = Enum.GetName(typeof(PositionType), type)
                    });
                }
            }

            SaveChanges();
        }
Example #9
0
        private void GetPositionTypes()
        {
            PositionTypes.Add(new PositionTypeComboVm
            {
                Id      = "Regular",
                Title   = "Regular",
                Details = "Regular positions that requires one winner."
            });

            PositionTypes.Add(new PositionTypeComboVm
            {
                Id      = "Representative",
                Title   = "Representative",
                Details = "Positions in which the required number of winner is based on the grade level population."
            });
        }
Example #10
0
        public NewJobViewModel()
        {
            JobData jobData = JobData.GetInstance();

            foreach (Employer field in jobData.Employers.ToList())
            {
                Employers.Add(new SelectListItem {
                    Value = field.ID.ToString(),
                    Text  = field.Value
                });
            }

            // TODO #4 - populate the other List<SelectListItem>
            // collections needed in the view

            // emplorer info is above

            foreach (Location field  in jobData.Locations.ToList())
            {
                Locations.Add(new SelectListItem
                {
                    Value = field.ID.ToString(),
                    Text  = field.Value
                });
            }
            foreach (CoreCompetency field in jobData.CoreCompetencies.ToList())
            {
                CoreCompetencies.Add(new SelectListItem
                {
                    Value = field.ID.ToString(),
                    Text  = field.Value
                });
            }
            foreach (PositionType field in jobData.PositionTypes.ToList())
            {
                PositionTypes.Add(new SelectListItem
                {
                    Value = field.ID.ToString(),
                    Text  = field.Value
                });
            }
        }
Example #11
0
 public Rule(StreetTypes street, HandTypes hand,
             ChanceTypes chance, int minOpps, int maxOpps,
             OpponentActionTypes action,
             PositionTypes position,
             double minMaxBet, double maxMaxBet,
             double minPotSize, double maxPotSize,
             string decision)
 {
     this.street     = street;
     this.hand       = hand;
     this.chance     = chance;
     this.minOpps    = minOpps;
     this.maxOpps    = maxOpps;
     this.action     = action;
     this.position   = position;
     this.minMaxBet  = minMaxBet;
     this.maxMaxBet  = maxMaxBet;
     this.minPotSize = minPotSize;
     this.maxPotSize = maxPotSize;
     this.decision   = decision;
 }
        public NewJobViewModel()
        {
            JobData jobData = JobData.GetInstance();

            foreach (Employer field in jobData.Employers.ToList())
            {
                Employers.Add(new SelectListItem
                {
                    Value = field.ID.ToString(),
                    Text  = field.Value
                });
            }

            foreach (Location field in jobData.Locations.ToList())
            {
                Locations.Add(new SelectListItem
                {
                    Value = field.ID.ToString(),
                    Text  = field.Value
                });
            }
            foreach (CoreCompetency field in jobData.CoreCompetencies.ToList())
            {
                CoreCompetencies.Add(new SelectListItem
                {
                    Value = field.ID.ToString(),
                    Text  = field.Value
                });
            }

            foreach (PositionType field in jobData.PositionTypes.ToList())
            {
                PositionTypes.Add(new SelectListItem
                {
                    Value = field.ID.ToString(),
                    Text  = field.Value
                });
            }
        }
Example #13
0
        public Rule findRule(StreetTypes street, HandTypes hand,
                             ChanceTypes chance, int opponents,
                             OpponentActionTypes action,
                             PositionTypes position,
                             double maxBet, double potSize)
        {
            // hash
            int hash = getHashCode(street, hand, chance, opponents, action, position);

            if (!rules.ContainsKey(hash))
            {
                Log.Debug("cannot find rule for this constellation -> "
                          + describe(street, hand, chance, opponents, action));
                return(new Rule(street, hand, chance, opponents, opponents, action));
            }

            // intervals
            MaxBetDictionary  maxBetDict  = rules[hash];
            PotSizeDictionary potSizeDict = maxBetDict.getByInterval(maxBet);
            Rule rule = potSizeDict.getByInterval(potSize);

            return(rule);
        }
Example #14
0
        private int getHashCode(StreetTypes street, HandTypes hand,
                                ChanceTypes chance, int opponents,
                                OpponentActionTypes action,
                                PositionTypes position)
        {
            // ints
            int streetNum = (int)street;
            int handNum   = (int)hand;
            int chanceNum = (int)chance;
            int actionNum = (int)action;
            int posNum    = (int)position;

            // bits
            int bits = (streetNum & mask(4));

            bits |= (handNum & mask(6)) << 4;
            bits |= (chanceNum & mask(4)) << 10;
            bits |= (opponents & mask(4)) << 14;
            bits |= (actionNum & mask(4)) << 18;
            bits |= (posNum & mask(2)) << 22;

            // hash
            return(bits);
        }
Example #15
0
        private void AddModel(Model3D originalModel3D, Point3D position, PositionTypes positionType, Size3D size, bool preserveAspectRatio = true)
        {
            // Create a new Model3DGroup that will hold the originalModel3D.
            // This allows us to have different transformation for each originalModel3D (transformation is on Model3DGroup)
            var model3DGroup = new Model3DGroup();

            model3DGroup.Children.Add(originalModel3D);

            Ab3d.Utilities.ModelUtils.PositionAndScaleModel3D(model3DGroup, position, positionType, size, preserveAspectRatio);

            // Add the model
            var modelVisual3D = new ModelVisual3D()
            {
                Content = model3DGroup
            };

            SolidObjectsVisual3D.Children.Add(modelVisual3D);



            // Now add red WireCrossVisual3D at the specified position
            var wireCrossVisual3D = new Ab3d.Visuals.WireCrossVisual3D()
            {
                Position    = position,
                LinesLength = 30,
                LineColor   = Colors.Red
            };

            SolidObjectsVisual3D.Children.Add(wireCrossVisual3D);


            // Now show a WireBoxVisual3D (box from 3D lines) that would represent the position, positionType and size.

            // To get the correct CenterPosition of the WireBoxVisual3D,
            // we start with creating a bounding box (Rect3D) that would be used when CenterPosition would be set to (0, 0, 0):
            var wireboxInitialBounds = new Point3D(-size.X * 0.5, -size.Y * 0.5, -size.Z * 0.5);

            // Then we use that bounding box and call GetModelTranslationVector3D method
            // that will tell us how much we need to move the bounding box so that it will be positioned at position and for positionType:
            var wireboxCenterOffset = Ab3d.Utilities.ModelUtils.GetModelTranslationVector3D(new Rect3D(wireboxInitialBounds, size), position, positionType);

            // Now we can use the result wireboxCenterOffset as a CenterPosition or a WireBoxVisual3D

            var wireBoxVisual3D = new WireBoxVisual3D()
            {
                CenterPosition = new Point3D(wireboxCenterOffset.X, wireboxCenterOffset.Y, wireboxCenterOffset.Z),
                Size           = size,
                LineColor      = Colors.Green,
                LineThickness  = 1
            };

            SolidObjectsVisual3D.Children.Add(wireBoxVisual3D);


            // Finally we add TextBlockVisual3D to show position and size information for this model
            // Note that the TextBlockVisual3D is added to the TransparentObjectsVisual3D.
            // The reason for this is that TextBlockVisual3D uses semi-transparent background.
            // To correctly show other object through semi-transparent, the semi-transparent must be added to the scene after solid objects.
            var infoText = string.Format("Position: {0:0}\r\nPositionType: {1}\r\nSize: {2:0}", position, positionType, size);

            if (!preserveAspectRatio)
            {
                infoText += "\r\npreserveAspectRatio: false";
            }

            var textBlockVisual3D = new TextBlockVisual3D()
            {
                Position      = new Point3D(model3DGroup.Bounds.GetCenterPosition().X, -15, 55), // Show so that X center position is the same as model center position
                PositionType  = PositionTypes.Center,
                TextDirection = new Vector3D(1, 0, 0),
                UpDirection   = new Vector3D(0, 1, -1), // angled at 45 degrees
                Size          = new Size(80, 0),        // y size will be calculated automatically based on x size (80) and size of the text

                Text            = infoText,
                BorderBrush     = Brushes.DimGray,
                BorderThickness = new Thickness(1, 1, 1, 1),
                Background      = new SolidColorBrush(Color.FromArgb(180, 200, 200, 200)),
                TextPadding     = new Thickness(5, 2, 5, 2)
            };

            TransparentObjectsVisual3D.Children.Add(textBlockVisual3D);
        }
        private void PopulatePositionTypes()
        {
            var positionTypesData = HttpHelper.Get<PositionTypesData>(serviceBaseUri+"/PositionTypes");

            var positionTypes = new PositionTypes();
            mapper.MapList(positionTypesData, positionTypes, typeof(PositionType));
            ViewData["positionTypes"] = positionTypes;
        }
Example #17
0
 public void IsAwake_Test(PositionTypes position, bool expectedValue)
 {
     _ch.CurrentPosition = position;
     Assert.That(_ch.IsAwake(), Is.EqualTo(expectedValue));
 }
Example #18
0
        private void mnuPositionTypes_Click(object sender, RoutedEventArgs e)
        {
            var win = new PositionTypes();

            win.ShowDialog();
        }
Example #19
0
 public void IsInCombatPosition_Test(PositionTypes currentPos, bool expectedValue)
 {
     _ch.CurrentPosition = currentPos;
     Assert.That(_ch.IsInCombatPosition(), Is.EqualTo(expectedValue));
 }
Example #20
0
        private void SpellDefine(SpellDefinitions def, string name, int maxMana, int minMana, int manaChange, PositionTypes position,
			MagicTargetFlags targets, bool violent, MagicFlags routines, string wearOffMessage)
        {
            SpellData spell = new SpellData ();

            spell.Name = name;
            spell.ManaMaximum = maxMana;
            spell.ManaMinimum = minMana;
            spell.ManaChange = manaChange;
            spell.MinimumPosition = position;
            spell.Targets = targets;
            spell.Violent = violent;
            spell.Routines = routines;
            spell.WearOffMessage = wearOffMessage;

            for (int i = 0; i < (int)ClassTypes.Index; i++)
                spell.MinimumLevel[i] = GlobalConstants.LVL_IMMORT;

            _spells.Add (def, spell);
        }