Open EmersonYe opened 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()
TMSimulator.isAccepted()
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
TMSimulator.simulateInput():
TMSimulator.isAccepted():
I believe the line if (isAccepted()) should call TMConfiguration.isAccept() instead of TMSimulator.isAccepted() to properly check if TM input is accepted or not.
if (isAccepted())
TMConfiguration.isAccept()
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
Fixed it here:
https://github.com/ushahid/jflap-cli
TMSimulator.simulateInput()
always returns false because it is callingTMSimulator.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#L347TMSimulator.simulateInput():
https://github.com/citiususc/jflap-lib/blob/aa2f46a6dc237d3bb232d872d966957a22ccc767/jflaplib-core/src/main/java/edu/duke/cs/jflap/automata/turing/TMSimulator.java#L363-L387TMSimulator.isAccepted():
https://github.com/citiususc/jflap-lib/blob/aa2f46a6dc237d3bb232d872d966957a22ccc767/jflaplib-core/src/main/java/edu/duke/cs/jflap/automata/turing/TMSimulator.java#L345-L354I believe the line
if (isAccepted())
should callTMConfiguration.isAccept()
instead ofTMSimulator.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