Пример #1
0
        public override Playground InitPlayground()
        {
            var playground = new Playground(RuleSet.Size, Playground.FieldState.Empty);

            var watch = new Stopwatch();
            watch.Start();
            foreach (var shiptype in RuleSet.ShipTypes)
                for(int i = 0; i < shiptype.Number; i++)
                    while (watch.ElapsedMilliseconds < 1000) {
                        var pos = new Tuple<int, int, int>(Random.Value.Next(playground.Width - shiptype.Width), Random.Value.Next(playground.Height - shiptype.Height), Random.Value.Next(playground.Depth - shiptype.Depth));
                        if (playground.CanPlaceShip(shiptype, pos)) {
                            playground.PlaceShip(shiptype, pos);
                            break;
                        }
                    }

            return playground;
        }
Пример #2
0
 public virtual void SetEnemyPlayground(Playground playground)
 {
     if (playground.GetHash() != EnemyPlaygroundHash)
         throw new BOSRuleBreakingException("Playground-hash and the generated hash of the send playground do not match! Cheating is most likely! Early hash: " + EnemyPlaygroundHash + "; actual Hash: " + playground.GetHash());
     if (!playground.IsValid)
         throw new BOSRuleBreakingException("The send playground is invalid! This is most likely cheating!");
 }
Пример #3
0
 public virtual bool SetRuleSet(Ruling.RuleSet rules)
 {
     if (rules.IsValid) {
         RuleSet = rules;
         EnemyPlayground = new Playground(RuleSet.Size, Playground.FieldState.Unknown);
         return true;
     }
     return false;
 }