コード例 #1
0
ファイル: LimitedListTests.cs プロジェクト: tollyx/NetRogue
        public void Contains_False_Test()
        {
            // Arrange
            int capacity = 1;
            LimitedList <object> list = new LimitedList <object>(capacity);
            var obj = new object();

            // Act
            bool contains = list.Contains(obj);

            // Assert
            Assert.IsFalse(contains);
        }
コード例 #2
0
ファイル: LimitedListTests.cs プロジェクト: tollyx/NetRogue
        public void Remove_Success_Test()
        {
            // Arrange
            int capacity = 1;
            LimitedList <object> list = new LimitedList <object>(capacity);
            var obj = new object();

            list.Add(obj);

            // Act
            bool removed = list.Remove(obj);

            // Assert
            Assert.IsTrue(removed);
            Assert.IsFalse(list.Contains(obj));
        }
コード例 #3
0
 public void cache_has_item()
 {
     _sut.Add(23);
     _sut.Contains(23).Should().BeTrue();
     _sut.Contains(2).Should().BeFalse();
 }
コード例 #4
0
ファイル: MainForm.cs プロジェクト: aum-inv/AUM
        private void RunKr(object o)
        {
            string itemCode = (string)o;

            string lastPrice = "";

            LimitedList <double> ll3 = new LimitedList <double>(3);
            LimitedList <double> ll5 = new LimitedList <double>(5);
            LimitedList <double> ll7 = new LimitedList <double>(7);

            int rnd = ItemCodeSet.GetItemRoundNum(itemCode);

            while (isRunKr)
            {
                try
                {
                    if (!SiseStorage.Instance.PricesKr.ContainsKey(itemCode))
                    {
                        System.Threading.Thread.Sleep(1000);
                        continue;
                    }

                    var priceQueue = SiseStorage.Instance.PricesKr[itemCode];

                    if (priceQueue.Count == 0)
                    {
                        System.Threading.Thread.Sleep(100);
                        continue;
                    }
                    CurrentPrice price;
                    var          isDequeue = priceQueue.TryDequeue(out price);
                    if (isDequeue)
                    {
                        if (lastPrice == price.price)
                        {
                            continue;
                        }
                        lastPrice = price.price;
                        double d = Math.Round(Convert.ToDouble(lastPrice), rnd);

                        if (!ll3.Contains(d))
                        {
                            ll3.Insert(d);
                        }
                        if (!ll5.Contains(d))
                        {
                            ll5.Insert(d);
                        }
                        if (!ll7.Contains(d))
                        {
                            ll7.Insert(d);
                        }

                        price.price3 = Math.Round(ll3.Average(), rnd);
                        price.price5 = Math.Round(ll5.Average(), rnd);
                        price.price7 = Math.Round(ll7.Average(), rnd);

                        SiseEvents.Instance.OnSiseHandler(itemCode, price);

                        if (isSiseBinding)
                        {
                            BindSise(itemCode, price);
                        }
                    }
                }
                catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.Message); }
            }
        }
コード例 #5
0
ファイル: AIUser.cs プロジェクト: AndreaMilanta/AmaruServer
        /// <summary>
        /// Faster function to evaluate all the possible movements in the movement phase
        /// </summary>
        /// <param name="gm"></param>
        /// <returns> Best movement action</returns>
        private KeyValuePair <Double, PlayerAction> ThinkToMove(GameManager gm)
        {
            GameManager                toUse       = CreateGameManagerAndStuff(gm);
            Player                     me          = toUse.UserDict[CharacterEnum.AMARU].Player;
            LimitedList <Card>         myCards     = me.Hand;
            LimitedList <CreatureCard> myWarZone   = me.Outer;
            LimitedList <CreatureCard> myInnerZone = me.Inner;

            List <KeyValuePair <Double, PlayerAction> > listPossibleActions = new List <KeyValuePair <double, PlayerAction> >();

            foreach (CreatureCard cd in myWarZone.Concat(myInnerZone))
            {
                try
                {
                    //   Log("TESTO la carta "+ cd.Name + "   in war zone? " + myWarZone.Contains(cd));
                    //   Log(me.IsShieldMaidenProtected.ToString());
                    GameManager        toUseTemp   = CreateGameManagerAndStuff(toUse);
                    MoveCreatureAction myIntention = new MoveCreatureAction(CharacterEnum.AMARU, cd.Id, (myInnerZone.Contains(cd)? Place.OUTER: Place.INNER), 0);
                    myIntention.Visit(toUseTemp.ValidationVisitor);
                    myIntention.Visit(toUseTemp.ExecutionVisitor);
                    Double valueOfGoal = ValueMyField(toUseTemp);
                    listPossibleActions.Add(new KeyValuePair <Double, PlayerAction>(valueOfGoal, myIntention));
                }
                catch (Exception e) {
                    Log("Eccezione " + e.ToString());
                    Log(cd.Name);
                }
            }
            listPossibleActions = listPossibleActions.OrderByDescending(x => x.Key).ToList();
            if (listPossibleActions.Count > 0)
            {
                Log(listPossibleActions[0].ToString());
                return(listPossibleActions[0]);
            }
            else
            {
                return(new KeyValuePair <double, PlayerAction>(Double.MinValue, new EndTurnAction(CharacterEnum.AMARU, -1, false)));
            }
        }