Ejemplo n.º 1
0
        public override Activity Process(NonEmptySeat seat)
        {
            if (seat.Table.Street == Street.PREFLOP)
            {
                var subtable = this.GetSubtable(seat.Hand);

                if (subtable == null)
                {
                    return(new Activity(Decision.FOLD));
                }

                var previousDecision = this.GetPreviousDecision(seat);
                var position         = this.GetPosition(seat);

                var decision = subtable[((int)previousDecision) - 4][(int)position - 1];

                return(new Activity((Decision)decision));
            }
            return(null);
        }
Ejemplo n.º 2
0
        private Position GetPosition(NonEmptySeat seat)
        {
            var dealer = seat.Table.Seats[seat.Table.Dealer];

            if (seat.RightActive == dealer || seat.RightActive.RightActive == dealer)
            {
                return(Position.BLIND);
            }

            var positions = this.CalcPositions(seat);

            var checkingSeat = (dealer as NonEmptySeat);

            if (checkingSeat == seat)
            {
                return(Position.LATE);
            }

            int j = positions.Count - 1;

            while (j > 0)
            {
                if (checkingSeat == seat)
                {
                    return((Position)(j + 1));
                }

                positions[j]--;
                if (positions[j] == 0)
                {
                    j--;
                }

                checkingSeat = checkingSeat.RightActive;
            }

            throw new Exception("Position identification fail");
        }
Ejemplo n.º 3
0
        private Decision GetPreviousDecision(NonEmptySeat seat)
        {
            var previousSeat = seat;

            while (previousSeat.RightActive != seat)
            {
                previousSeat = previousSeat.RightActive;

                if (previousSeat.Activity.Decision == Decision.RAISE)
                {
                    return(Decision.RAISE);
                }

                if (previousSeat.Activity.Decision == Decision.CALL)
                {
                    if (seat == previousSeat)
                    {
                        throw new Exception("Table is empty");
                    }
                }
            }

            return(Decision.FOLD);
        }
Ejemplo n.º 4
0
        private List <int> CalcPositions(NonEmptySeat seat)
        {
            var positions = new List <int>();

            positions.Add(2);
            positions.Add(3);
            positions.Add(2);

            var minus = seat.Table.Seats.Count - seat.Table.ActivePlayersCount;
            var i     = 0;

            while (minus > 0)
            {
                positions[i]--;
                minus--;

                if (positions[i] == 0)
                {
                    i++;
                }
            }

            return(positions);
        }
Ejemplo n.º 5
0
 public abstract Activity Process(NonEmptySeat seat);
Ejemplo n.º 6
0
 public abstract void Act(NonEmptySeat seat, Activity activity = null);