' Version: 19
Dim Shared Alphabet3
(8) As LetterBin
' 000 001 010 011 100 101 110 111
Alphabet1(1).Signature = "0"
Alphabet1(2).Signature = "1"
Call NewAlphabet
(Alphabet1
(), Alphabet2
()) Call NewAlphabet
(Alphabet2
(), Alphabet3
()) Call NewAlphabet
(Alphabet3
(), Alphabet4
()) Call NewAlphabet
(Alphabet4
(), Alphabet5
()) Call NewAlphabet
(Alphabet5
(), Alphabet6
()) Call NewAlphabet
(Alphabet6
(), Alphabet7
()) Call NewAlphabet
(Alphabet7
(), Alphabet8
()) Call NewAlphabet
(Alphabet8
(), Alphabet9
()) Call NewAlphabet
(Alphabet9
(), Alphabet10
()) Call NewAlphabet
(Alphabet10
(), Alphabet11
()) Call NewAlphabet
(Alphabet11
(), Alphabet12
()) Call NewAlphabet
(Alphabet12
(), Alphabet13
())
' Load test data.
' This is the made-up part of the model.
' Statistics and metrics:
'''
' Bypass pre-cooked test data.
'TestData(1) = "1111111111111111111111"
'ReDim _Preserve TestData(1)
'''
For m
= 1 To 1 'UBound(TestData)
GuessPredicted = -1
GuessesCorrect = 0
GuessesTotal = 0
GuessStreak = 0
GuessStreakMax = 0
For n
= 1 To 9999 'Len(TestData(m))
'''
' Research Mode
'TheString = Left$(TestData(m), n)
'''
'''
' Gaming Mode
Print "Press LEFT or RIGHT." k = 0
TheString = TheString + "0"
TheString = TheString + "1"
'''
'Print Right$(TestData(m), Len(TestData(m)) - n)
' Reconciliation
If (GuessPredicted
<> -1) Then Print "I am RIGHT this round." GuessesCorrect = GuessesCorrect + 1
GuessStreak = GuessStreak + 1
If (GuessStreak
> GuessStreakMax
) Then GuessStreakMax
= GuessStreak
Grade(n, 2) = 1
Print "I am WRONG this round." GuessStreak = 0
Grade(n, 2) = 0
GuessesTotal = GuessesTotal + 1
Grade(n, 1) = GuessesCorrect / GuessesTotal
GuessPredicted = Analyze(TheString, AlphaWeight(), 0)
Print "I have made a new prediction." Print "Press LEFT or RIGHT to test me."
' Draw bottom graph
Call PrintGraph
(TheString
, Grade
())
AlphaWeight(k) = 0 * k ^ 2
'AlphaWeight(1) = 0
'AlphaWeight(2) = 0
'AlphaWeight(3) = 0
'AlphaWeight(4) = 0
AlphaWeight(5) = 1
'AlphaWeight(6) = 0
'AlphaWeight(7) = 0
'AlphaWeight(8) = 0
'AlphaWeight(9) = 0
'AlphaWeight(10) = 0
AlphaWeight(11) = 0
AlphaWeight(12) = 0
AlphaWeight(13) = 0
StringPhase(1) = TheStringIn
'For n = 2 To UBound(StringPhase) ' Uncomment for phase analysis.
'StringPhase(n) = Right$(StringPhase(n - 1), Len(StringPhase(n - 1)) - 1) + Left$(StringPhase(n - 1), 1)
'Next
' Initialize partial results.
Partialguess(n, 1) = -999
If (arrweight
(1) <> 0) Then Call CreateHisto
(StringPhase
(), 1, Alphabet1
()) If (arrweight
(2) <> 0) Then Call CreateHisto
(StringPhase
(), 2, Alphabet2
()) If (arrweight
(3) <> 0) Then Call CreateHisto
(StringPhase
(), 3, Alphabet3
()) If (arrweight
(4) <> 0) Then Call CreateHisto
(StringPhase
(), 4, Alphabet4
()) If (arrweight
(5) <> 0) Then Call CreateHisto
(StringPhase
(), 5, Alphabet5
()) If (arrweight
(6) <> 0) Then Call CreateHisto
(StringPhase
(), 6, Alphabet6
()) If (arrweight
(7) <> 0) Then Call CreateHisto
(StringPhase
(), 7, Alphabet7
()) If (arrweight
(8) <> 0) Then Call CreateHisto
(StringPhase
(), 8, Alphabet8
()) If (arrweight
(9) <> 0) Then Call CreateHisto
(StringPhase
(), 9, Alphabet9
()) If (arrweight
(10) <> 0) Then Call CreateHisto
(StringPhase
(), 10, Alphabet10
()) If (arrweight
(11) <> 0) Then Call CreateHisto
(StringPhase
(), 11, Alphabet11
()) If (arrweight
(12) <> 0) Then Call CreateHisto
(StringPhase
(), 12, Alphabet12
()) If (arrweight
(13) <> 0) Then Call CreateHisto
(StringPhase
(), 13, Alphabet13
())
If (pswitch
= 1) Then ' Set the last argument >=1 to print stats for that histogram. If ((Len(TheStringIn
) >= 1) And (arrweight
(1) <> 0)) Then Call PrintHisto
(Alphabet1
(), 0) If ((Len(TheStringIn
) >= 2) And (arrweight
(2) <> 0)) Then Call PrintHisto
(Alphabet2
(), 0) If ((Len(TheStringIn
) >= 3) And (arrweight
(3) <> 0)) Then Call PrintHisto
(Alphabet3
(), 0) If ((Len(TheStringIn
) >= 4) And (arrweight
(4) <> 0)) Then Call PrintHisto
(Alphabet4
(), 0) If ((Len(TheStringIn
) >= 5) And (arrweight
(5) <> 0)) Then Call PrintHisto
(Alphabet5
(), 4) If ((Len(TheStringIn
) >= 6) And (arrweight
(6) <> 0)) Then Call PrintHisto
(Alphabet6
(), 0) If ((Len(TheStringIn
) >= 7) And (arrweight
(7) <> 0)) Then Call PrintHisto
(Alphabet7
(), 0) If ((Len(TheStringIn
) >= 8) And (arrweight
(8) <> 0)) Then Call PrintHisto
(Alphabet8
(), 0) If ((Len(TheStringIn
) >= 9) And (arrweight
(9) <> 0)) Then Call PrintHisto
(Alphabet9
(), 0) If ((Len(TheStringIn
) >= 10) And (arrweight
(10) <> 0)) Then Call PrintHisto
(Alphabet10
(), 0) If ((Len(TheStringIn
) >= 11) And (arrweight
(11) <> 0)) Then Call PrintHisto
(Alphabet11
(), 0) If ((Len(TheStringIn
) >= 12) And (arrweight
(12) <> 0)) Then Call PrintHisto
(Alphabet12
(), 0) If ((Len(TheStringIn
) >= 13) And (arrweight
(13) <> 0)) Then Call PrintHisto
(Alphabet13
(), 0)
If ((Len(TheStringIn
) >= 1) And (arrweight
(1) <> 0)) Then Call MakeGuess
(TheStringIn
, 1, Alphabet1
(), Partialguess
(), 0) ' Set the last argument =1 to print guess for that histogram. If ((Len(TheStringIn
) >= 2) And (arrweight
(2) <> 0)) Then Call MakeGuess
(TheStringIn
, 2, Alphabet2
(), Partialguess
(), 0) If ((Len(TheStringIn
) >= 3) And (arrweight
(3) <> 0)) Then Call MakeGuess
(TheStringIn
, 3, Alphabet3
(), Partialguess
(), 0) If ((Len(TheStringIn
) >= 4) And (arrweight
(4) <> 0)) Then Call MakeGuess
(TheStringIn
, 4, Alphabet4
(), Partialguess
(), 0) If ((Len(TheStringIn
) >= 5) And (arrweight
(5) <> 0)) Then Call MakeGuess
(TheStringIn
, 5, Alphabet5
(), Partialguess
(), pswitch
) If ((Len(TheStringIn
) >= 6) And (arrweight
(6) <> 0)) Then Call MakeGuess
(TheStringIn
, 6, Alphabet6
(), Partialguess
(), 0) If ((Len(TheStringIn
) >= 7) And (arrweight
(7) <> 0)) Then Call MakeGuess
(TheStringIn
, 7, Alphabet7
(), Partialguess
(), 0) If ((Len(TheStringIn
) >= 8) And (arrweight
(8) <> 0)) Then Call MakeGuess
(TheStringIn
, 8, Alphabet8
(), Partialguess
(), 0) If ((Len(TheStringIn
) >= 9) And (arrweight
(9) <> 0)) Then Call MakeGuess
(TheStringIn
, 9, Alphabet9
(), Partialguess
(), 0) If ((Len(TheStringIn
) >= 10) And (arrweight
(10) <> 0)) Then Call MakeGuess
(TheStringIn
, 10, Alphabet10
(), Partialguess
(), 0) If ((Len(TheStringIn
) >= 11) And (arrweight
(11) <> 0)) Then Call MakeGuess
(TheStringIn
, 11, Alphabet11
(), Partialguess
(), 0) If ((Len(TheStringIn
) >= 12) And (arrweight
(12) <> 0)) Then Call MakeGuess
(TheStringIn
, 12, Alphabet12
(), Partialguess
(), 0) If ((Len(TheStringIn
) >= 13) And (arrweight
(13) <> 0)) Then Call MakeGuess
(TheStringIn
, 13, Alphabet13
(), Partialguess
(), 0)
If (Partialguess
(k
, 1) <> -999) Then Print Partialguess
(k
, 1);
j = 0
r = 0
' Weighted average calculation
If (Partialguess
(k
, 1) <> -999) Then r = r + arrweight(k) * Partialguess(k, 1)
j = j + arrweight(k)
r = r / j
r = 1
r = 0
TheReturn = r
Analyze = TheReturn
TheReturn = 0
j = 1
k = 0
If (arralpha
(n
).Count
>= j
) Then TheReturn
= TheReturn
+ Val(Right$(arralpha
(n
).Signature
, 1)) k = k + 1
j = arralpha(n).Count
TheReturn = TheReturn / k
TheReturn = .5
arrguess(wid, 1) = TheReturn
arrguess(wid, 2) = j
arralpha(n).Count = 0
' Uncomment this loop to enable phase analysis.
'For j = 1 To wid
j = 1
If (Mid$(arrfinger
(j
), k
, wid
) = arralpha
(n
).Signature
) Then arralpha(n).Count = arralpha(n).Count + 1
'Next
j = wid
Print arr
(n
).Signature; arr
(n
).Count
Sub NewAlphabet
(arrold
() As LetterBin
, arrnew
() As LetterBin
) n = 0
n = n + 1
arrnew(n).Signature = arrold(j).Signature
arrnew(j).Signature = "0" + arrnew(j).Signature
arrnew(j).Signature = "1" + arrnew(j).Signature
If (LowLimit
< HighLimit
) Then piv = Partition(arr(), LowLimit, HighLimit)
Call QuickSort
(arr
(), LowLimit
, piv
- 1) Call QuickSort
(arr
(), piv
+ 1, HighLimit
)
pivot = arr(HighLimit).Count
i = LowLimit - 1
For j
= LowLimit
To HighLimit
- 1 tmp = arr(j).Count - pivot
i = i + 1
Swap arr
(i
+ 1), arr
(HighLimit
) Partition = i + 1
'Function Pathological$ (TheSeed As String, TheLength As Integer)
' Dim TheReturn As String
' TheReturn = TheSeed
' Dim p
' Do
' Cls
' Locate 1, 1
' Print TheReturn;
' p = Analyze(TheReturn, 0)
' If (p = 1) Then
' TheReturn = TheReturn + "0"
' Else
' TheReturn = TheReturn + "1"
' End If
' Loop Until Len(TheReturn) = TheLength
' Pathological$ = TheReturn
'End Function
n = alwayszero
'''
' Percussive cases:
'''
n = n + 1: TestData(n) = "1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111"
n = n + 1: TestData(n) = "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
n = n + 1: TestData(n) = "0101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101"
n = n + 1: TestData(n) = "1010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010"
n = n + 1: TestData(n) = "0001110011000111001100011100110001110011000111001100011100110001110011000111001100011100110001110011000111001100011100110001110011000111001100011100110001110011"
n = n + 1: TestData(n) = "0100010111010001011101000101110100010111010001011101000101110100010111010001011101000101110100010111010001011101000101110100010111010001011101000101110100010111"
'''
' Human samples:
'''
' (from Keybone)
n = n + 1: TestData(n) = "101010101010101010101001010101010101001010111001010101010101010101010100010101010101010100101001010101001100101010001010100101010100101010100101010101010101010011011110010101010100100101010110010011001010011001010100010100101010010101010101010010101010101010010101001010101010100110010101010100101010101010011001001010100101010010101010100101010010101001010100101001010010101010111010100110011001010101010100110101001010101010100101001010111010101010101010100101001010101010010101010101001010101001010101001010100101010100101010010101010101001010101001010101010101001010101001010100101010101010010101010010010101010101010101010010100101010101001010100101001010101001111101010101010100101010110011001010101010101010110101010101101010101010100101010010101010010101010101101110010101001010101010110010100101010101001011010101010100110101010100101010010101010100101010101001010101010101001010101010011010101010101110110100101010111010101011011001011001010101001010101010101010101010011001010101010100101010101010101010010100101"
' (from Keybone)
n = n + 1: TestData(n) = "0101110101100011010100101011001110001011001010001110101111010100111011100100101001010011110101101000101010001010101111001010111010101010100001010101000101101100101111101010010101110110111001000101000011010101010001001001001111101011101010100010110101110101100000101010101110111010100100100001110111100101011110101010001010001110010110111110110010101001001011101000101001011100011101000010101010101101010010110100101101000101111010101110111001010011101111010101000010101111100010101011110101011011110100001010110"
' (from Loudar)
n = n + 1: TestData(n) = "1011001010010100100100110010101010101001010101010101011010010101001010101001010010100110101011010101010101011010101101010101010101010010110101010101100101010101010110101101011010010101010010100110101101001010110101011010010101101010110100101111010101010011011011010010110101010010110100101101010100101011010010101001010101010001011101011010010101011100111010010001101011110010011010001011100110101010010011010101001001010010000101010110001"
' (from Luke)
n = n + 1: TestData(n) = "01100101001010001100001101101111011010010101010110110101001000001111001111110101000101111011010101111101010101101010101001010101011000010101010101001011010100110100110100110011010101010101110101010111111101011010100000001101111000010111000110111001000010100001101010110100000111101011111100001011001010110010110"
' (from Sarafromct)
n = n + 1: TestData(n) = "10101010101011101000011101010111010101010101100111001010100111100001011011110101000001111010101101010000001111110011111110111101110111001110110010000100010101010101010100101011010110101010101010101001000000001111110000011110101010101010100010101110101010101101111111111111111111101010101010101000000"
' (from Spriggs)
n = n + 1: TestData(n) = "10111010101010101010101001010101010101001010101001010101010101010101010101010101010101010101010101010101001010100100100101010101010101001010100101010101010100101010100101010101010101010101001010010110010101010010101010101010101010101010100101001001001010101010101010101010101001010101001001101010010"
' (from Spriggs)
n = n + 1: TestData(n) = "11111011110100101011111111110100000011011110101100111100111111110111101110100111100110011111110101111111010111101111100111110111111111111011100111110111111110010000101011111001110101101010110111110"
' (from Hotpants)
n = n + 1: TestData(n) = "01010100011001010010101010101010101000110101010111101010100100011010101010100100101110010010010100001010101001010101010110010001001011000100100110101001001001010000000001010101101111101001010100010101001001010101000100101001100100010011010101010101010111010010101011101011011010110100100010010100100100010010001001"
LoadTestData = n