private bool IsCollision(Waldo waldo)
        {
            Waldo other             = waldo.Type == WaldoType.Alpha ? Beta : Alpha;
            bool  moleculeCollision = waldo.HasAtom && atomManager.IsAtomAtPosition(waldo.Position);
            bool  waldoCollision    = waldo.HasAtom && other.HasAtom && waldo.Position.Equals(other.Position);

            return(moleculeCollision && waldoCollision);
        }
 public void Reset()
 {
     Cycles      = 0;
     AlphaTarget = 0;
     BetaTarget  = 0;
     Alpha       = new Waldo(Reactor.AlphaStart, Reactor.Bound, WaldoType.Alpha);
     Beta        = new Waldo(Reactor.BetaStart, Reactor.Bound, WaldoType.Beta);
     atomManager = new AtomManager();
 }
        private bool GrabAtom(Waldo waldo)
        {
            if (!waldo.HasAtom)
            {
                Atom grab = atomManager.GetAtomAtPosition(waldo.Position);
                waldo.Atom = grab;
            }

            return(true);
        }
 private bool GrabOrDropAtom(Waldo waldo)
 {
     if (waldo.HasAtom)
     {
         return(GrabAtom(waldo));
     }
     else
     {
         return(DropAtom(waldo));
     }
 }
        private bool DoTile(Waldo waldo)
        {
            var            type        = waldo.Type;
            TileAttributes tile        = Reactor.GetTileAttributes(waldo.Position);
            var            commands    = tile.GetCommands(type);
            Direction      direction   = commands.Item1;
            Instruction    instruction = commands.Item2;

            // Set the direction for the next step.
            waldo.CurrentDirection = direction;

            // Process the instruction.
            switch (instruction)
            {
            case Instruction.InAlpha:
                return(InputMolecule(WaldoType.Alpha));

            case Instruction.InBeta:
                return(InputMolecule(WaldoType.Beta));

            case Instruction.Grab:
                return(GrabAtom(waldo));

            case Instruction.Drop:
                return(DropAtom(waldo));

            case Instruction.GrabDrop:
                return(GrabOrDropAtom(waldo));

            case Instruction.OutAlpha:
                return(RemoveOutput(WaldoType.Alpha));

            case Instruction.OutBeta:
                return(RemoveOutput(WaldoType.Beta));

            case Instruction.RotateClockwise:
                return(Rotate(waldo, true));

            case Instruction.RotateCounterClockwise:
                return(Rotate(waldo, false));

            case Instruction.RemoveBond:
            case Instruction.AddBond:
            case Instruction.Sync:
            case Instruction.Empty:
            default:
                return(true);
            }
        }
        private bool Step(Waldo waldo)
        {
            // Move the waldo and its atom.
            waldo.Step();

            // Check for a collision and then process tile instructions.
            if (!IsCollision(waldo))
            {
                if (DoTile(waldo))
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                return(false);
            }
        }
 private bool DropAtom(Waldo waldo)
 {
     waldo.Atom = null;
     return(true);
 }
 private bool Rotate(Waldo waldo, bool clockwise)
 {
     return(true);
 }