Sign in to follow this  
JinJo

[java] java turing machine

Recommended Posts

JinJo    100
I have to hand in a turing machine program by about 1:15 today written in java. I have the main features planned etc but this is the only java program i have wrote except hello world. My main problem seems to be setting up the Gui (positions etc). Aslo I have no idea how to read input from a file (the tape and the TM states). Any tips?

Share this post


Link to post
Share on other sites
Koroljov    115
use InputStream in=(new URL("name of the file")).openStream();
use int input=in.read(); to read a byte. (don't forget to inport java.io.* and java.net.*) (and don't forget to catch exceptions);

What does the GUI of a turing machine looks like? Can't you just print all the information with System.out.print("something");?

Share this post


Link to post
Share on other sites
JinJo    100
Thanks for that.

I suppose I could just use system out.

I was wanting it to show you graphically what was happening at each stage and allow you to add in new instructions while the program was running.

A bit ambitious to do in a day I think.

Do you have any examples of a TM in java that doesn't use a GUI?

Share this post


Link to post
Share on other sites
Roboguy    794
just make it like a CUI(Console User Interface) chat program, you really don't need a GUI, since even if you do use a GUI, it will be all text I/O anyway

Share this post


Link to post
Share on other sites
Koroljov    115
No I don't have such examples. (by the way,I hope you're in an other time zone than I).

What would you need? A large boolean array, or maybe you could use a java.util.BitSet.

boolean[] bits=new boolean[256];

I do not know much about turing machines. Are the instructions coded in the same array, or are the instructions coded somewhere else? Anyway, I suppose you'll need some code to parse instructions.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this