TuringHead
Represents the "head" of a Turing machine.
TuringHead is responsible for reading and writing data on the tape (stored via NetworkState entries) and controlling the flow of execution by managing the current mode and head position.
Table of Contents
Properties
- $error : string
- Holds any error message encountered by the head.
- $data : string
- The current data stored by the head.
- $headPosition : int
- The current position of the head on the tape.
- $mode : TuringMode
- The current mode of the head (e.g., CONTINUE, STUCK, etc.).
- $nextState : TuringMove|int
- The next state/move directive for the head.
Methods
- getData() : string
- Retrieves the data stored by the head.
- getMode() : TuringMode
- Retrieves the current mode of the head.
- getNext() : TuringMove|int
- Retrieves the next state/move directive.
- getPosition() : int
- Retrieves the current position of the head.
- setData() : TuringHead
- Sets the data stored by the head.
- setMode() : TuringHead
- Sets the current mode of the head.
- setNext() : TuringHead
- Sets the next state/move directive for the head.
- setPosition() : TuringHead
- Sets the head's position on the tape.
Properties
$error
Holds any error message encountered by the head.
public
string
$error
$data
The current data stored by the head.
private
string
$data
$headPosition
The current position of the head on the tape.
private
int
$headPosition
= 0
$mode
The current mode of the head (e.g., CONTINUE, STUCK, etc.).
private
TuringMode
$mode
= \LaravelNeuro\Enums\TuringMode::CONTINUE
$nextState
The next state/move directive for the head.
private
TuringMove|int
$nextState
= \LaravelNeuro\Enums\TuringMove::NEXT
Can be an instance of TuringMove or an integer representing a position.
Methods
getData()
Retrieves the data stored by the head.
public
getData() : string
Return values
string —The stored data.
getMode()
Retrieves the current mode of the head.
public
getMode() : TuringMode
Return values
TuringMode —The current mode.
getNext()
Retrieves the next state/move directive.
public
getNext() : TuringMove|int
Return values
TuringMove|int —The next state or move.
getPosition()
Retrieves the current position of the head.
public
getPosition() : int
Return values
int —The head position.
setData()
Sets the data stored by the head.
public
setData(string $data) : TuringHead
Parameters
- $data : string
-
The data to set.
Return values
TuringHead —Returns the current instance for chaining.
setMode()
Sets the current mode of the head.
public
setMode(TuringMode $mode) : TuringHead
Parameters
- $mode : TuringMode
-
The new mode.
Return values
TuringHead —Returns the current instance for chaining.
setNext()
Sets the next state/move directive for the head.
public
setNext(TuringMove|int $nextState) : TuringHead
The value must be either an instance of TuringMove or an integer.
Parameters
- $nextState : TuringMove|int
-
The next state directive.
Tags
Return values
TuringHead —Returns the current instance for chaining.
setPosition()
Sets the head's position on the tape.
public
setPosition(int $headPosition) : TuringHead
Parameters
- $headPosition : int
-
The position index.
Return values
TuringHead —Returns the current instance for chaining.