This specifies a Turing machine that will write a blank in the first cell to the right that contains a 1.
Turing Machines in Karel J Robot are discussed at: http://csis.pace.edu/~bergin/KarelJava2ed/turingmachine.html
Here is the code for the class. Note that a TM robot automatically executes starting in state1 when you create it.
[ User Guide] [.FrontPage] [.RecentChanges]
Turing Machines in Karel J Robot are discussed at: http://csis.pace.edu/~bergin/KarelJava2ed/turingmachine.html
| kareltherobot.KarelFixture | ||||
| kareltherobot.PickOneTM | ||||
| World | reset | |||
| World | placeBeepers | 1 | 5 | 1 |
| Create | karel | |||
| Assert | BeepersInWorld | 0 | ||
| Assert | BeepersInBeeperBag | karel | ||
| Assert | NotRunning | karel | ||
Here is the code for the class. Note that a TM robot automatically executes starting in state1 when you create it.
/*
* Created on Oct 13, 2003
*
*/
package kareltherobot;
import java.awt.Color;
/** A Turing Machine robot to write a blank in the first cell to the right
* of the origin (inclusive) that originally has a 1.
* @author jbergin
*
*/
public class PickOneTM extends TuringMachine
{
public PickOneTM()
{
super();
}
public PickOneTM(Color badge)
{
super(badge);
}
public void state1()
{
if(nextToABeeper())
{
putBlank();
finalState();
}
else
{ moveRight();
state1();
}
}
}
[ User Guide] [.FrontPage] [.RecentChanges]