citiususc / jflap-lib

An improved version of JFLAP 7.0 to be used as a library as well as a command line tool.
Other
52 stars 17 forks source link

Turing Machine simulateInput always returns false #3

Open EmersonYe opened 6 years ago

EmersonYe commented 6 years ago

TMSimulator.simulateInput() always returns false because it is calling TMSimulator.isAccepted() to check status. However, TMSimulator.isAccepted() always returns false and even states in a comment that it only exists as a formality and is not meant to be called, as seen below. https://github.com/citiususc/jflap-lib/blob/aa2f46a6dc237d3bb232d872d966957a22ccc767/jflaplib-core/src/main/java/edu/duke/cs/jflap/automata/turing/TMSimulator.java#L347

TMSimulator.simulateInput(): https://github.com/citiususc/jflap-lib/blob/aa2f46a6dc237d3bb232d872d966957a22ccc767/jflaplib-core/src/main/java/edu/duke/cs/jflap/automata/turing/TMSimulator.java#L363-L387 TMSimulator.isAccepted(): https://github.com/citiususc/jflap-lib/blob/aa2f46a6dc237d3bb232d872d966957a22ccc767/jflaplib-core/src/main/java/edu/duke/cs/jflap/automata/turing/TMSimulator.java#L345-L354

I believe the line if (isAccepted()) should call TMConfiguration.isAccept() instead of TMSimulator.isAccepted() to properly check if TM input is accepted or not.

TMConfiguration.isAccept() https://github.com/citiususc/jflap-lib/blob/aa2f46a6dc237d3bb232d872d966957a22ccc767/jflaplib-core/src/main/java/edu/duke/cs/jflap/automata/turing/TMConfiguration.java#L79-L94

ushahid commented 1 year ago

Fixed it here:

https://github.com/ushahid/jflap-cli