Ejemplo n.º 1
0
        public static void Main(string[] args)
        {
            Iterator <Image> screen;

            if (USE_SCREEN)
            {
                // wait
                Log.Info("waiting ...");
                Thread.Sleep(5000);

                // full screen
                Console.WriteLine("## scanning for table ##");
                Image fullScreen = new ScreenImageIterator(new Win32Control()).next();
                Point offset     = PatternLocator.locateTable(fullScreen);
                Console.WriteLine("table found at x=" + offset.X + " y=" + offset.Y);

                // desk
                screen = new ScreenImageIterator(new Win32Control(), new Rectangle(offset.X, offset.Y, new TableLayout9().Size.Width, new TableLayout9().Size.Height));
                screen = new WaitDeltaImageIterator(screen);
            }
            else
            {
                screen = new MockOneImageIterator(toImage(new Bitmap("test/table_highlight.png")));
            }

            // identifier
            TableIdentifier tableIdentifier = new TableIdentifier(new TableLayout9());

            tableIdentifier.RenderImageEvent += delegate(Image image, Point point)
            {
                renderer.renderImage(image, point);
            };

            // loop
            while (screen.hasNext())
            {
                // start
                Console.WriteLine("## iteration -> start ##");
                DateTime start = DateTime.Now;

                // clear
                renderer.clearImages();

                // table
                Console.WriteLine("# next table image #");
                Image tableImage = screen.next();
                renderer.renderImage(tableImage, 0, 0);

                // identify table
                Table table = tableIdentifier.identifyTable(tableImage, TableIdentifier.PlayerInfoEnum.BOTH, -1, 0);

                // render table
                Console.WriteLine("# rendering table");
                renderer.render(table, tableIdentifier.Layout);

                // end
                double time = DateTime.Now.Subtract(start).TotalMilliseconds;
                Console.WriteLine("## iteration -> end -> " + time + " ms ##");
            }
        }
Ejemplo n.º 2
0
        public void ProcessTable(Settings settings,
                                 Image tableImage,
                                 TableRenderer renderer,
                                 Table table,
                                 TableContainer container,
                                 RuleEvaluator evaluator,
                                 RuleInterpreter interpreter,
                                 Controller controller,
                                 Replayer replayer,
                                 RandomClicker clicker,
                                 List <TableControl> controls)
        {
            // hand visible?
            if (table.Hand.Count != 0)
            {
                // identify situation
                Situation situation = SituationEvaluator.evaluateSituation(tableImage, table, controls, settings.BigBlind);

                // wait for blinds activatd or not enough players or money reached
                if (!container.IsWaitingForBlind && situation.Street == StreetTypes.Preflop)
                {
                    // override blinds?
                    if (waitForBlinds)
                    {
                        Log.Info("table " + (container.Number + 1) + " override blinds");
                        WaitForBlind(controller, container);
                    }
                    // out of players?
                    else if (table.IsOutOfPlayers)
                    {
                        Log.Info("table " + (container.Number + 1) + " ran out of players");
                        CloseTable(container, controller);
                        return;
                    }
                    // reached money?
                    else if (settings.CloseTableActivated && table.HasSeat && table.MyPlayer.HasMoney)
                    {
                        if (table.MyPlayer.Money > settings.CloseTableMoneyMax)
                        {
                            Log.Info("table " + (container.Number + 1) + " reached money limit " + table.MyPlayer.Money);
                            CloseTable(container, controller);
                            return;
                        }
                    }
                }

                // evaluate rule
                Rule rule = evaluator.findRule(situation.Street,
                                               situation.Hand,
                                               situation.Chance,
                                               situation.Opponents,
                                               situation.OpponentAction,
                                               situation.Position,
                                               table.MaxBet,
                                               table.Pot);
                // decision
                Decision decision = interpreter.interpret(table, rule.Decision);

                // render table
                Log.Debug("# rendering table");
                if (renderer != null)
                {
                    renderer.render(table, container.Layout, situation, rule, decision, controls);
                }

                // beep
                if (decision.DecisionType == Decision.Types.BET ||
                    decision.DecisionType == Decision.Types.CALL ||
                    decision.DecisionType == Decision.Types.RAISE)
                {
                    if (situation.Hand != HandTypes.None)
                    {
                        Beep(settings);
                        TextToSpeech.SayAsnc(settings, situation.Hand);
                    }
                }

                // random click on table
                if (RandomBool(0.05) && settings.AutoClick)
                {
                    Log.Debug("# auto click on table");
                    clicker.click(container.Layout);
                }

                // sit out
                if (!container.IsSittingOut && sitOutNextHand)
                {
                    SitOut(controller, container);
                }

                // press buttons
                Log.Debug("# press controls");
                Thread.Sleep(RandomInt(100, 500));
                controller.Handle(decision, container.Layout, controls);

                // random mouse moves
                if (RandomBool(0.05) && settings.AutoMoveMouse)
                {
                    Log.Debug("# auto move mouse");
                    Sleep(settings, RandomInt(100, 300));
                    AutoMoveMouse(controller.Mouse);
                }
                if (situation.Opponents > 2 && RandomBool(0.05) && settings.ReplayMouseMoves)
                {
                    Log.Debug("# replay mouse");
                    Sleep(settings, RandomInt(100, 300));
                    replayer.ReplayRandomShort();
                }
            }
            else
            {
                // render table
                Log.Debug("# rendering table");
                renderer.render(table, container.Layout);
            }
        }