public TrivialMoleculeAssembler(ProgramWriter writer, IEnumerable <Molecule> products) : base(writer) { var product = products.Single(); new Product(this, new Vector2(), product.Rotation, product.ID); }
public VanBerloGenerator(ProgramWriter writer) : base(writer) { new Glyph(this, new Vector2(0, 1), Direction.SW, GlyphType.Duplication); m_wheelArm = new Arm(this, new Vector2(1, 1), Direction.E, MechanismType.VanBerlo); OutputArm = new Arm(this, new Vector2(3, 0), Direction.W, MechanismType.Arm1, extension: 3); }
public MetalProjector(ProgramWriter writer) : base(writer) { new Glyph(this, new Vector2(0, 0), Direction.E, GlyphType.Projection); m_projectionArm = new Arm(this, new Vector2(0, 1), Direction.SW, MechanismType.Arm1); OutputArm = new Arm(this, new Vector2(4, 0), Direction.W, MechanismType.Arm1, extension: 3); }
protected override AtomGenerator CreateAtomGenerator(ProgramWriter writer) { return(new AtomGenerators.AtomBuffer(writer, m_stacks.Select(stack => new AtomGenerators.AtomBuffer.StackInfo { MultiAtom = stack.MaxCount > 1, UsesRestore = stack.UsedPop, WastesAtoms = stack.Elements.Count > 0 }))); }
public ComplexMoleculeAssembler(ProgramWriter writer, IEnumerable <Molecule> products) : base(writer) { m_products = products; m_assembleCoroutine = new LoopingCoroutine <object>(Assemble); m_area = new AssemblyArea(this, writer, products); m_outputArea = new OutputArea(m_area, writer, products); }
public SaltGenerator(ProgramWriter writer) : base(writer) { new Glyph(this, new Vector2(1, 0), Direction.E, GlyphType.Calcification); new Track(this, new Vector2(0, 2), Direction.E, 1); m_bigArm = new Arm(this, new Vector2(0, 2), Direction.SW, MechanismType.Arm1, extension: 2); m_smallArm = new Arm(this, new Vector2(1, 1), Direction.SW, MechanismType.Arm1); OutputArm = new Arm(this, new Vector2(5, 0), Direction.W, MechanismType.Arm1, extension: 3); }
public AssemblyArea(SolverComponent parent, ProgramWriter writer, IEnumerable <Molecule> products) : base(parent, writer, parent.OutputPosition) { Width = products.Max(p => p.Width); HasTriplex = products.Any(p => p.HasTriplex); CreateBonders(); CreateArms(); CreateTracks(); }
public QuintessenceGenerator(ProgramWriter writer) : base(writer) { m_consumeCoroutine = new LoopingCoroutine <object>(ConsumeCardinals); new Glyph(this, new Vector2(1, -1), Direction.E, GlyphType.Unification); m_leftArm = new Arm(this, new Vector2(0, -1), Direction.NE, MechanismType.Arm1); m_rightArm = new Arm(this, new Vector2(2, 0), Direction.W, MechanismType.Piston, extension: 2); OutputArm = new Arm(this, new Vector2(4, -1), Direction.W, MechanismType.Arm1, extension: 3); }
public TrivialInputArea(ProgramWriter writer, IEnumerable <Molecule> reagents) : base(writer) { var reagent = reagents.First(); if (reagent.Atoms.Count() > 1) { throw new ArgumentException("TrivialInputArea can't handle reagents with multiple atoms."); } new Reagent(this, new Vector2(0, 0), 0, reagent.ID); }
public AtomBuffer(ProgramWriter writer, IEnumerable <StackInfo> stackInfo) : base(writer) { int i = 0; foreach (var info in stackInfo) { AddStack(i++, info); } OutputArm = new Arm(this, new Vector2(m_stacks.Count * 2 + 3, 0), Direction.W, MechanismType.Arm1, extension: 3); }
public OutputArea(SolverComponent parent, ProgramWriter writer, IEnumerable <Molecule> products) : base(parent, writer, parent.OutputPosition) { m_products = products; CreateOutputs(); var armPos = new Vector2(-1, 1); m_outputArm = new Arm(this, armPos, Direction.SE, MechanismType.Arm1); new Track(this, armPos, Direction.NE, m_outputs.Values.Max(o => o.DropPosition)); }
public MetalPurifier(ProgramWriter writer, int size) : base(writer) { m_size = size; if (size < 1) { throw new ArgumentOutOfRangeException("size", size, "Size must be 1 or greater."); } m_consumeCoroutine = new LoopingCoroutine <object>(ConsumeMetal); CreateObjects(); }
public SingleAtomInput(SolverComponent parent, ProgramWriter writer, Vector2 position, Molecule molecule, int direction, Instruction instruction) : base(parent, writer, position, molecule) { if (molecule.Atoms.Count() > 1) { throw new ArgumentException("SingleAtomInput can't handle molecules with multiple atoms."); } Element = molecule.Atoms.First().Element; m_instruction = instruction; CreateObjects(molecule, direction, instruction); }
public QuintessenceDisperser(ProgramWriter writer) : base(writer) { m_generateCoroutine = new LoopingCoroutine <Element>(GenerateCardinals); m_inputArm = new Arm(this, new Vector2(2, -2), Direction.NW, MechanismType.Arm1, extension: 2); new Glyph(this, new Vector2(3, 0), Direction.E, GlyphType.Dispersion); m_disperseArm = new Arm(this, new Vector2(2, 1), Direction.SW, MechanismType.Arm1); m_airFireArm = new Arm(this, new Vector2(4, -2), Direction.NW, MechanismType.Piston, extension: 2); m_waterArm = new Arm(this, new Vector2(4, 1), Direction.SW, MechanismType.Piston, extension: 2); OutputArm = new Arm(this, new Vector2(6, -2), Direction.NW, MechanismType.Arm1, extension: 2); }
public MorsVitaeGenerator(ProgramWriter writer) : base(writer) { m_consumeCoroutine = new LoopingCoroutine <object>(ConsumeSalt); m_generateCoroutine = new LoopingCoroutine <Element>(GenerateMorsVitae); m_inputArm = new Arm(this, new Vector2(2, -2), Direction.NW, MechanismType.Arm1, extension: 2); m_saltArm = new Arm(this, new Vector2(1, -1), Direction.NW, MechanismType.Arm1); new Glyph(this, new Vector2(1, 0), Direction.E, GlyphType.Animismus); m_vitaeArm = new Arm(this, new Vector2(2, 1), Direction.W, MechanismType.Arm1); m_morsArm = new Arm(this, new Vector2(3, -1), Direction.W, MechanismType.Arm1); OutputArm = new Arm(this, new Vector2(4, -2), Direction.NW, MechanismType.Arm1, extension: 2); }
protected override AtomGenerator CreateAtomGenerator(ProgramWriter writer) { if (m_products.All(p => p.Atoms.Count() == 1)) { if (m_products.Count() == 1) { return(new TrivialMoleculeAssembler(writer, m_products)); } else if (m_products.Count() <= SimpleMoleculeAssembler.MaxProducts) { return(new SimpleMoleculeAssembler(writer, m_products)); } } return(new ComplexMoleculeAssembler(writer, m_products)); }
public ComplexInputArea(ProgramWriter writer, IEnumerable <Molecule> reagents) : base(writer) { var multiAtomReagents = reagents.Where(r => r.Atoms.Count() > 1); AddMultiAtomInputs(multiAtomReagents); var singleAtomReagents = reagents.Where(r => r.Atoms.Count() == 1); AddSingleAtomInputs(singleAtomReagents); if (m_inputs.Count > 1) { var highestInput = m_inputs.MaxBy(input => input.Position.Y); m_conveyor = new AtomConveyor(this, writer, new Vector2(0, 0), highestInput.Position.Y + highestInput.OutputPosition.Y); } }
public MultiAtomInput(SolverComponent parent, ProgramWriter writer, Vector2 position, Molecule molecule) : base(parent, writer, position, molecule) { m_extractAtomsCoroutine = new LoopingCoroutine <Element>(ExtractAtoms); // The atoms need to be moved at least 3 spaces to fully unbond them m_unbondWidth = Math.Max(3, Molecule.Width); var reagentPos = new Vector2(-Molecule.Width * 2 - m_unbondWidth - 2, -molecule.Height + 1); new Reagent(this, reagentPos.Add(molecule.Origin), molecule.Rotation, molecule.ID); var armPos = AddArms(reagentPos); AddTracks(armPos); AddGlyphs(); }
protected override AtomGenerator CreateAtomGenerator(ProgramWriter writer) { var usedInputs = m_inputs.Where(input => input.Used); var reagents = usedInputs.Select(input => input.Molecule); if (usedInputs.All(input => input.Molecule.Atoms.Count() == 1)) { if (usedInputs.Count() == 1) { return(new TrivialInputArea(writer, reagents)); } else if (usedInputs.Count() <= SimpleInputArea.MaxReagents) { return(new SimpleInputArea(writer, reagents)); } } return(new AtomGenerators.ComplexInputArea(writer, reagents)); }
public LinearMoleculeInput(SolverComponent parent, ProgramWriter writer, Vector2 position, Molecule molecule) : base(parent, writer, position, molecule) { Molecule = molecule; if (molecule.Height != 1) { throw new ArgumentException(Invariant($"Molecule must have height 1. Specified height: {molecule.Height}."), "molecule"); } m_extractAtomsCoroutine = new LoopingCoroutine <Element>(ExtractAtoms); var reagentPos = new Vector2(-Molecule.Width - 2, 1); new Reagent(this, reagentPos.Add(molecule.Origin), molecule.Rotation, molecule.ID); m_grabArm = new Arm(this, reagentPos.Add(0, 1), Direction.SW, MechanismType.Piston); m_outputArm = new Arm(this, new Vector2(-3, 3), Direction.SW, MechanismType.Arm1, extension: 3); new Track(this, m_grabArm.Position, Direction.E, Molecule.Width - 1); new Glyph(this, new Vector2(-4, 0), Direction.E, GlyphType.Unbonding); }
public SimpleInputArea(ProgramWriter writer, IEnumerable <Molecule> reagents) : base(writer) { if (reagents.Any(r => r.Atoms.Count() > 1)) { throw new ArgumentException("SimpleInputArea can't handle reagents with multiple atoms."); } if (reagents.Count() > MaxReagents) { throw new ArgumentException(Invariant($"SimpleInputArea can't handle more than {MaxReagents} distinct reagents.")); } int dir = Direction.W; foreach (var reagent in reagents) { m_inputs.Add(new SingleAtomInput(this, Writer, new Vector2(0, 0), reagent, dir, Instruction.Extend)); dir--; } }
public SimpleMoleculeAssembler(ProgramWriter writer, IEnumerable <Molecule> products) : base(writer) { if (products.Any(r => r.Atoms.Count() > 1)) { throw new ArgumentException("SimpleMoleculeAssembler can't handle products with multiple atoms."); } if (products.Count() > MaxProducts) { throw new ArgumentException(Invariant($"SimpleMoleculeAssembler can't handle more than {MaxProducts} products.")); } int dir = Direction.E; foreach (var product in products) { CreateOutput(product, dir); dir = DirectionUtil.Rotate60Clockwise(dir); } }
public AtomConveyor(SolverComponent parent, ProgramWriter writer, Vector2 position, int height) : base(parent, writer, position) { if (height % 2 > 0) { throw new ArgumentException("Height must be a multitple of two.", "height"); } Height = height; for (int y = Height - 2; y >= 2; y -= 2) { m_downArms.Add(new Arm(this, new Vector2(2, y), Direction.NW, MechanismType.Arm1, extension: 2)); } // This arm has to be in a different spot and direction to avoid atoms hitting it when moving East m_cornerArm = new Arm(this, new Vector2(-2, 2), Direction.E, MechanismType.Arm1, extension: 2); for (int i = 1; i <= 2; i++) { m_acrossArms.Add(new Arm(this, new Vector2(i * 2, -2), Direction.NW, MechanismType.Arm1, extension: 2)); } }
protected SolverComponent(SolverComponent parent, ProgramWriter writer, Vector2 position) : base(parent, position, 0) { Writer = writer; }
internal static global::System.Runtime.InteropServices.HandleRef getCPtr(ProgramWriter obj) { return((obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr); }
protected SolverComponent(ProgramWriter writer) : this(null, writer, new Vector2()) { }
protected override AtomGenerator CreateAtomGenerator(ProgramWriter writer) { return(new AtomGenerators.MorsVitaeGenerator(writer)); }
protected override AtomGenerator CreateAtomGenerator(ProgramWriter writer) { return(new AtomGenerators.VanBerloGenerator(writer)); }
protected override AtomGenerator CreateAtomGenerator(ProgramWriter writer) { return(new AtomGenerators.QuintessenceDisperser(writer)); }
protected AtomGenerator(ProgramWriter writer) : base(writer) { }