コード例 #1
0
 public static void WriteRandomEvents(Player p, DoubleStream stream, int eventsCount)
 {
     foreach (var r in p.Board.RandomList)
     {
         writeRandomEvent(p, stream, r, eventsCount);
     }
     stream.Skip(eventsCount + eventsCount);
 }
コード例 #2
0
 void WriteBoard(Player p, DoubleStream stream)
 {
     foreach (var m in p.Minions)
     {
         WriteMinion(m, stream);
     }
     stream.Skip(BoardMinionsLenght);
 }
コード例 #3
0
 void WriteBoard(Player p, DoubleStream stream)
 {
     foreach (var m in p.Minions)
     {
         WriteMinion(m, stream);
     }
     for (int i = 0, to = Field.MaxMinions - p.Count; i < to; i++)
     {
         stream.WriteEmpty(MinionLenght); //empty
     }
 }
コード例 #4
0
        void WriteMinion(Minion m, DoubleStream stream)
        {
            int index = m.ID;

            stream.WriteOneHot(MinionOneHot, index);

            stream.Write(m.Sleeping ? 0 : 1);

            stream.Write(m.Atack / MinionMaxAttack);
            stream.Write(m.Health / MinionMaxHealth);
        }
コード例 #5
0
        void WriteMinion(Minion m, DoubleStream stream)
        {
            int index = m.ID;
            int start = index * MinionSingleLength;

            stream[start + 0]++;
            if (!m.Sleeping)
            {
                stream[start + 1]++;
            }

            //stream.Write(m.Atack / MinionMaxAttack);
            stream[start + 2] += m.Health / MinionMaxHealth;
        }
コード例 #6
0
        public double[] ConvertPosition(Player p)
        {
            var stream = new DoubleStream(inputSize);

            BasicSerialization.WritePlayer(p, stream);
            BasicSerialization.WritePlayer(p.Enemy, stream);

            WriteHand(p, stream);
            WriteEnemyHand(p.Enemy, stream);

            WriteBoard(p, stream);
            WriteBoard(p.Enemy, stream);

            BasicSerialization.WriteRandomEvents(p, stream, REventsCount);

            return(stream.ToArray());
        }
コード例 #7
0
 void WriteHand(Player p, DoubleStream stream)
 {
     foreach (var card in p.HandCards)
     {
         if (card is Spell s)
         {
             WriteSpell(s, stream);
         }
         else if (card is MinionCard m)
         {
             WriteMCard(m, stream);
         }
         else
         {
             throw new Exception("LOL WHAT?");
         }
     }
     stream.Skip(HandCardsLength);
 }
コード例 #8
0
 void WriteHand(Player p, DoubleStream stream)
 {
     foreach (var card in p.HandCards)
     {
         if (card is Spell s)
         {
             WriteSpell(s, stream);
         }
         else if (card is MinionCard m)
         {
             WriteMCard(m, stream);
         }
         else
         {
             throw new Exception("LOL WHAT?");
         }
     }
     for (int i = 0, to = Hand.MaxHand - p.HandCount; i < to; i++)
     {
         stream.WriteEmpty(CardLength);
     }
 }
コード例 #9
0
        public static void WritePlayer(Player p, DoubleStream stream)
        {
            double health = Math.Max(0, p.Hero.Health) / (double)p.Hero.StdHealth;

            stream.Write(health);

            // TODO: Attack

            double mana = p.Mana / (double)Player.ManaCap;

            stream.Write(mana);
            double maxmana = p.MaxMana / (double)Player.ManaCap;

            stream.Write(mana);

            double heropower = p.Hero.Power.UsedThisTurn ? 0 : 1;

            stream.Write(heropower);

            double cardsleft = p.DeckCount / (double)p.StartingCards.Length;

            stream.Write(cardsleft);
        }
コード例 #10
0
        static void writeRandomEvent(Player p, DoubleStream stream, RandomEvent r, int eventsCount)
        {
            int startIndex = r.Parent.IsA == p.IsA ? 0 : eventsCount;

            stream[startIndex + r.GetID] += 1;
        }
コード例 #11
0
 static void WriteEnemyHand(Player enemy, DoubleStream stream)
 {
     stream.Write(enemy.HandCount / (double)Hand.MaxHand);
 }
コード例 #12
0
        static void WriteSpell(Spell s, DoubleStream stream)
        {
            int index = s.ID;

            stream[index]++;
        }
コード例 #13
0
        void WriteMCard(MinionCard m, DoubleStream stream)
        {
            int index = SpellCount + m.ID;

            stream[index]++;
        }
コード例 #14
0
        void WriteSpell(Spell s, DoubleStream stream)
        {
            int index = s.ID;

            stream.WriteOneHot(CardOneHot, index);
        }
コード例 #15
0
        void WriteMCard(MinionCard m, DoubleStream stream)
        {
            int index = SpellsCount + m.ID;

            stream.WriteOneHot(CardOneHot, index);
        }