Turing.Sheet

References
public sealed class Turing.Sheet
A Turing sheet, or two dimensional Turing tape.

Constructors

Sheet

#
public Sheet(IEnumerable<Instruction> instructions, string initialState)
Setup a new Turing sheet.
instructions (IEnumerable<Turing.Instruction>)Instructions.
initialState (string)Initial state value.

Properties

CaretX

#
public int CaretX { get; }
Gets the caret x index.

CaretY

#
public int CaretY { get; }
Gets the caret y index.

IsFinished

#
public bool IsFinished { get; }
Gets whether this machine is in a finished state. This only happens when a terminal instruction is executed, or when the machine gets into a state which has no instruction associated with it.

Iteration

#
public int Iteration { get; }
Gets the number of iterations this machine has gone through.

State

#
public string State { get; }
Gets the state the machine is in currently.

Indexers

this[]

#
public string this[int x, int y] { get; set; }
Gets or sets the contents of a position in the field.
x (int)X index.
y (int)Y index.

Methods

ClearSheet

#
public void ClearSheet()
Clear the sheet.

ComputeBounds

#
public bool ComputeBounds(out int x0, out int x1, out int y0, out int y1)
Gets the lowest and highest defined indices along both axes.
x0 (out int)
x1 (out int)
y0 (out int)
y1 (out int)
True if bounds were computed.

CopyBlock

#
public string[][] CopyBlock(int x0, int x1, int y0, int y1)
Clone an entire rectangular region of values.
x0 (int)
x1 (int)
y0 (int)
y1 (int)
Nested arrays with sheet values. The secondary arrays represent the rows.

CopyValues

#
public (int x, int y, string value)[] CopyValues()
Clone the current sheer layout into an array.
Array of sheet coordinates and values.

FillBlock

#
public void FillBlock(int x0, int x1, int y0, int y1, string value)
Assign a bunch of values to a rectangular block.
x0 (int)Inclusive first x index.
x1 (int)Exclusive last x index.
y0 (int)Inclusive first y index.
y1 (int)Exclusive last y index.
value (string)Value to assign to each position in the block.

Run

#
public void Run()
Perform a single iteration.

Run

#
public void Run(int iterations)
Perform a number of iterations.
iterations (int)Maximum iterations to compute.

SetCaret

#
public void SetCaret(int x, int y)
Set the caret to a specific index. You'd be well advised to not set the caret while the machine is running, but I'm not your mother.
x (int)X index.
y (int)Y index.

SetupSheet

#
public void SetupSheet(IEnumerable<(int x, int y, string value)> values)
Set a bunch of values en masse.
values (IEnumerable<(int x, int y, string value)>)Index+Content tuples.

ToString

#
public override string ToString()
Create a text-based table overview of the sheet.
Object.ToString

TransferSheet

#
public void TransferSheet(Sheet source)
Copy all sheet cells from another Turing machine.
source (Turing.Sheet)Source machine.