Sign in to follow this  

[java] java turing machine

This topic is 4776 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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
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
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
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

This topic is 4776 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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