14. xlTuring.xlsm
「再帰呼び出し」(状態遷移規則との照合)
Function ruleFunction(ByVal
currentInState, ByVal currentReadTape,
ByVal currentRuleRow)
…
If (inState = currentInState And
(readTape = currentReadTape Or
readTape = "*")) Then
ruleFunction = currentRuleRow
Else
ruleFunction =
ruleFunction(currentInState,
currentReadTape, currentRuleRow + 1)
End If
End Function
15. xlTuring.xlsm
「連想配列」("Slowest", "Slow", "Moderate", "Fast", "Fastest")
Private Sub setIntervals()
Set msInterval =
CreateObject("Scripting.Dictionary")
msInterval.Add "Slowest", 1024
msInterval.Add "Slow", 512
msInterval.Add "Moderate", 256
msInterval.Add "Fast", 128
msInterval.Add "Fastest", 0
End Sub
16. xlTuring.xlsm
「割り込み処理」("Run"押下で実行/停止)
Private Sub runMachine()
If isRunning = False Then
isRunning = True Else
isRunning = False
End If
If msInterval Is Nothing Then Call
setIntervals
Do Until isRunning = False
Call stepMachine
Sleep (ActiveWorkbook.Worksheets
("Rules").Cells(1, 7).Value)
DoEvents
Loop
End Sub