sims.mdt
Class TuringMachine

java.lang.Object
  extended by sims.mdt.TuringMachine
All Implemented Interfaces:
GrapheInterface, Errors
Direct Known Subclasses:
MachineRead

public abstract class TuringMachine
extends java.lang.Object
implements Errors, GrapheInterface


Field Summary
 
Fields inherited from interface sims.mdt.Errors
error1, error10, error11, error12, error13, error2, error3, error4, error5, error6, error7, error8, error9
 
Constructor Summary
TuringMachine()
          Only constructor, initialize structures.
 
Method Summary
 java.util.Collection arcs()
          Will return a vector of edges, one for each instruction in the file.
 MConfig currentConf()
           
 java.lang.String getCurState()
           
 int getInstructionLine()
           
 int getMin(int i)
           
 java.lang.String getName()
           
 int getNbrArc()
          Gives the number of edges in the graph, equals to the number of instructions of a Turing Machine.
 int getNbrEtat()
          Gives the number of states of the machine, hence the number of vertices in the graph.
 int getNbTapes()
           
 java.lang.Object getRacine()
          Gives the root state of a machine, the start vertex in the graph.
 int getScannedSquare(int i)
           
 int getSpaceCplx()
           
 int getSpeed()
           
 java.lang.Integer getStateStatus(java.lang.String key)
           
 java.lang.String getTapeStatus(int i)
           
 java.lang.String getTapeWord(int i)
           
 int getTimeCplx()
           
 java.lang.String getTransState(java.lang.String key)
           
 boolean isGravity()
          To know if a machine is a gravity machine.
 boolean isND()
          To know if the machine is non deterministic.
 boolean isProb()
          To know if a machine is probabilistic, will return true if the machine is a gravity one.
 int nextConf()
          calculs next config, in both cases of an deterministic of non deterministic machine by calling the appropriate method.
 int nextConfD()
          calculs next configuration, for deterministic machine
 int nextConfND()
          nextConf for a nondeterministic machine (executed even if no indetermination presently faced)
 java.lang.String readWord(int i)
           
 int setTapeCont(java.lang.String s, int i)
          To set the tape i content as the String in parameter.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TuringMachine

public TuringMachine()
              throws java.io.IOException
Only constructor, initialize structures.

Throws:
java.io.IOException
Method Detail

nextConf

public int nextConf()
calculs next config, in both cases of an deterministic of non deterministic machine by calling the appropriate method.

Returns:
0 if nothing special, 1 for acception, else 2 if refused

nextConfD

public int nextConfD()
calculs next configuration, for deterministic machine

Returns:
0 if nothing special, 1 for acception, else 2 if refused

nextConfND

public int nextConfND()
nextConf for a nondeterministic machine (executed even if no indetermination presently faced)

Returns:
0 if nothing special, 1 for acception, else 2 if refused

readWord

public java.lang.String readWord(int i)
Returns:
the word written on the main tape (i), from the first non-blank char to the last non-blank

currentConf

public MConfig currentConf()
Returns:
the current config, instance of MConfig

isND

public boolean isND()
To know if the machine is non deterministic. Will return true if the machine is probabilistic, or gravity, those are special cases of non determinism.

Returns:
true if the machine is non deterministic, false otherwise.

isProb

public boolean isProb()
To know if a machine is probabilistic, will return true if the machine is a gravity one.

Returns:
true if the machine is probabilistic, false otherwise.

isGravity

public boolean isGravity()
To know if a machine is a gravity machine.

Returns:
true if the machine is a gravity machine, false otherwise.

arcs

public java.util.Collection arcs()
Will return a vector of edges, one for each instruction in the file.

Specified by:
arcs in interface GrapheInterface
Returns:
a collection of edges, instances of Arc.
See Also:
Arc.java

getNbrEtat

public int getNbrEtat()
Description copied from interface: GrapheInterface
Gives the number of states of the machine, hence the number of vertices in the graph.

Specified by:
getNbrEtat in interface GrapheInterface
Returns:
the number of states of the machine.

getNbrArc

public int getNbrArc()
Description copied from interface: GrapheInterface
Gives the number of edges in the graph, equals to the number of instructions of a Turing Machine.

Specified by:
getNbrArc in interface GrapheInterface
Returns:
the number of edges..

getRacine

public java.lang.Object getRacine()
Description copied from interface: GrapheInterface
Gives the root state of a machine, the start vertex in the graph.

Specified by:
getRacine in interface GrapheInterface
Returns:
the root state.

getTapeStatus

public java.lang.String getTapeStatus(int i)
Returns:
the tape content, as a String.

getNbTapes

public int getNbTapes()
Returns:
the number of tapes of the machine.

getCurState

public java.lang.String getCurState()
Returns:
the current state.

getStateStatus

public java.lang.Integer getStateStatus(java.lang.String key)
Returns:
an Integer corresping to the status of the state passed as parameter. 1 if the state is accepting, 2 if it's rejecting, 3 for a breakpoint, 0 for others.

getTransState

public java.lang.String getTransState(java.lang.String key)
Returns:
the new state corresponding to the key passed in parameter, for full sized deterministic instructions.

getSpaceCplx

public int getSpaceCplx()
Returns:
the current space complexity, equals to the number of cells visited on all tapes.

getTimeCplx

public int getTimeCplx()
Returns:
the current time complexity value, equals to the number of transitions done.

getSpeed

public int getSpeed()
Returns:
the speed of this machine simulation.

getTapeWord

public java.lang.String getTapeWord(int i)
Returns:
the word on the tape i.

getScannedSquare

public int getScannedSquare(int i)
Returns:
the scanned square index for the tape i.

getName

public java.lang.String getName()
Returns:
the name of the machine.

getMin

public int getMin(int i)
Returns:
the minimal cell reached on the tape i.

getInstructionLine

public int getInstructionLine()
Returns:
the line of the last used instruction.

setTapeCont

public int setTapeCont(java.lang.String s,
                       int i)
To set the tape i content as the String in parameter.

Parameters:
s - the word we want to copy on the tape, replacing the old one.
i - the tape we want to update number
Returns:
1 if operation succeeded, -1 if an error occured.