Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
new file for general js stuff and doc for test
- Loading branch information
Showing
5 changed files
with
122 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1,4 +1,29 @@ | |||
/* Functions used for testing the TM. | /* Functions used for testing the TM. | ||
test = { | |||
input : ([string]) | |||
total_words : (int) // number of words | |||
steps_avg : (float) | |||
memory_avg : (float) | |||
results : ([{ | |||
result : (string) // "accepted"/"rejected" , [result-word] | |||
steps : (int) | |||
max_storage_occ : (int) | |||
}]) | |||
} | |||
*/ | */ | ||
|
|
||
function resetTest() { | |||
test = { | |||
input: filterInput(document.getElementById('test_input').value), | |||
steps_avg: 0, | |||
memory_avg: 0 | |||
} | |||
} | |||
|
|||
function startTest() { | |||
disableGui() | |||
|
|||
enableGui() | |||
} | |||
|
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,37 @@ | |||
/* Some functions used by all the different features. | |||
*/ | |||
|
|||
function setToString(array) { | |||
var out = '{' | |||
array.forEach(function (val) {out += val+', '}) | |||
return out.substring(0, out.length-2) + '}' | |||
} | |||
function arrayToString(array) { | |||
var out = '' | |||
array.forEach(function (val) {out += val+', '}) | |||
return out.substring(0, out.length-2) | |||
} | |||
function arrayEqu(a1, a2) { | |||
if (a1.length != a2.length) return false | |||
for (var i = 0; i < a1.length; a1 ++) if (a1[i] != a2[i]) return false | |||
return true | |||
} | |||
function findNextTransition() { | |||
var t, diff | |||
for (var i = 0; i < machine.transitions.length; i++) { | |||
t = machine.transitions[i] | |||
if (t.origin != sim.state) continue | |||
diff = false | |||
for (var j = 0; j < t.read.length; j++) { | |||
if (t.read[j] != sim.tapes[j].content[sim.tapes[j].head_pos]) { | |||
diff = true | |||
break | |||
} | |||
} | |||
if (diff) continue | |||
|
|||
return {index: i, transition: t} | |||
} | |||
return null | |||
} | |||
|