Jump to content
  • Advertisement
Sign in to follow this  
JinJo

[java] java turing machine

This topic is 4966 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
Advertisement
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
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
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!