Skip to main content
gamedev.net
🔒 Locked

[java] java turing machine

Started by JinJo 3 replies 1.3k views
Original Post
JinJo
JinJo
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?
Koroljov
Koroljov
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");?
Why do my programs never work on other computers?
JinJo
JinJo
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?
Koroljov
Koroljov
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.
Why do my programs never work on other computers?

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.