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); }
void WriteBoard(Player p, DoubleStream stream) { foreach (var m in p.Minions) { WriteMinion(m, stream); } stream.Skip(BoardMinionsLenght); }
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 } }
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); }
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; }
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()); }
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); }
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); } }
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); }
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; }
static void WriteEnemyHand(Player enemy, DoubleStream stream) { stream.Write(enemy.HandCount / (double)Hand.MaxHand); }
static void WriteSpell(Spell s, DoubleStream stream) { int index = s.ID; stream[index]++; }
void WriteMCard(MinionCard m, DoubleStream stream) { int index = SpellCount + m.ID; stream[index]++; }
void WriteSpell(Spell s, DoubleStream stream) { int index = s.ID; stream.WriteOneHot(CardOneHot, index); }
void WriteMCard(MinionCard m, DoubleStream stream) { int index = SpellsCount + m.ID; stream.WriteOneHot(CardOneHot, index); }