Ejemplo n.º 1
0
        protected override NotPassBidBase SetLastBid()
        {
            int currentMaxJump = _startMaxJump;
            int cj             = 0;

            for (int i = Board.Instance.nNumber - 1; i > 0; --i)
            {
                if (Board.Instance.GetCard(_seme, (EnNumbers)i).initialPlayer == _me)
                {
                    cj             = 0;
                    currentMaxJump = currentMaxJump + _incr;
                    if (currentMaxJump > _maxMaxJump)
                    {
                        currentMaxJump = _maxMaxJump;
                    }
                }
                else if (cj < currentMaxJump)
                {
                    cj = cj + 1;
                }
                else
                {
                    return(new NormalBid(_me, (EnNumbers)i, 61));
                }
            }

            NormalBid bid = new NormalBid(_me, EnNumbers.DUE, 61);

            while (Board.Instance.GetCard(_seme, bid.number).initialPlayer == _me)
            {
                bid = new NormalBid(_me, bid.number + 1, 61);
            }

            return(bid);
        }
Ejemplo n.º 2
0
        public void packageBidNormalAckTest()
        {
            BidBase    b    = new NormalBid(Board.Instance.Me, EnNumbers.CAVALLO, 61);
            PackageBid pkgb = new PackageBid(b);

            byte [] bs = pkgb.getAckMessage();

            PackageBid pkgbRec = new PackageBid(PackageBase.getMessageFromAck(bs));

            Assert.AreEqual(EnPackageType.BID, pkgb.type);
            Assert.AreSame(Board.Instance.Me, pkgb.bid.bidder);
            Assert.True(b.Equals(pkgbRec.bid));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Lowers the bid without calling a card that this player has in its hand.
        /// </summary>
        /// <returns>The lowered bid.</returns>
        /// <param name="bid">The current bid.</param>
        private NotPassBidBase LowerTheBidUntilNotCIM(NotPassBidBase bid)
        {
            if (bid is CarichiBid)
            {
                return(bid);
            }

            NormalBid nb = (NormalBid)bid;

            while (Board.Instance.GetCard(_seme, nb.number).initialPlayer == _me && nb.number != EnNumbers.DUE && nb.point < 62)
            {
                nb = (NormalBid)nb.GetNext();
            }

            return(nb);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Method that returns which bid the AI wants to place in the auction.
        /// </summary>
        /// <returns>The bid.</returns>
        public BidBase ChooseABid()
        {
            NotPassBidBase bid = new NormalBid(EnNumbers.ASSE, 61);

            if (Board.Instance.currentAuctionWinningBid != null)
            {
                bid = Board.Instance.currentAuctionWinningBid.GetNext();
            }

            if (!_allowChiamataInMano)
            {
                bid = LowerTheBidUntilNotCIM(bid);
            }

            if (_lastBid >= bid)
            {
                return(bid.ChangeBidder(_me));
            }

            return(new PassBid(_me));
        }
Ejemplo n.º 5
0
        public void setup()
        {
            Board.Instance.Reset();

            using (TestRandom rnd = new TestRandom())
                Board.Instance.InitializeMaster(new string[] { "A", "B", "C", "D", "E" }, 2, rnd);                //il mazziere è C

            _null1 = null;
            _null2 = null;

            _pass1 = new PassBid(Board.Instance.AllPlayers [0]);
            _pass2 = new PassBid(Board.Instance.AllPlayers [1]);

            _normalBid1 = new NormalBid(Board.Instance.AllPlayers [0], EnNumbers.ASSE, 70);
            _normalBid2 = new NormalBid(Board.Instance.AllPlayers [1], EnNumbers.DUE, 61);
            _normalBid3 = new NormalBid(Board.Instance.AllPlayers [2], EnNumbers.DUE, 70);
            _normalBid4 = new NormalBid(Board.Instance.AllPlayers [2], EnNumbers.DUE, 70);

            _carichi1 = new CarichiBid(Board.Instance.AllPlayers [0], 61);
            _carichi2 = new CarichiBid(Board.Instance.AllPlayers [0], 70);
            _carichi3 = new CarichiBid(Board.Instance.AllPlayers [0], 70);
        }