Exemple #1
0
        public void MoveChips(MoveChipInstruction instruction)
        {
            if (!this.bots.ContainsKey(instruction.Bot))
            {
                bool b = true;

                throw new InvalidOperationException(string.Format("Bot {0} doesn't exist", instruction.Bot));
            }


            var values = this.bots[instruction.Bot];

            if (values.Count != 2)
            {
                throw new InvalidOperationException(string.Format("Cannot execute MoveChipsInstruction with only 2 microchips on bot: {0}"));
            }

            instruction.Monitor(instruction.Bot, values);

            SendValue(instruction.Lower, instruction.SendLowerTo, values.Min());
            SendValue(instruction.Higher, instruction.SendHigherTo, values.Max());

            this.bots[instruction.Bot].Clear();
        }
Exemple #2
0
 public MoveChipInstructionBuilder New()
 {
     this.instruction         = new MoveChipInstruction();
     this.instruction.Monitor = (label, values) => { };
     return(this);
 }