QB64.org Forum

Active Forums => QB64 Discussion => Topic started by: random1 on December 07, 2021, 11:37:55 am

Title: Looking for old program or help recreating it
Post by: random1 on December 07, 2021, 11:37:55 am
Many years ago, mid 90's  I came across a sort of sequential prediction tool.
I don't remember the name but it was suppose to show how bad people were
at random.
The program presented the user with two buttons labeled (0) and (1).  The user
would select one of the two and then the program would try to predict the users
selection.  The more a person played the better it got at predicting.  The users
input was held until after the prediction was made then it would be added to the
the predictors data string.
I did not understand the code back then but held on to it for many years thinking
it could come in handy.  I changed computers many times since then and the
source code got lost in the process.  It was written using qb45 is about all I can
remember.
I have a tool that processes around 800 binary strings and I thought this tool
might come in handy to test the randomness of the data.  The strings are just
a series of zeros and ones, either the event true=1 or false=0.

Anyway, looking for anyone knowledgeable in this sort of thing to post a few
ideas including source code.  The program could also include a 3rd state for
whenever no clear prediction could be made.  I use a wildcard (*)   

Small data sample
0001000001011100000011000100011000010010000000000000000011000000000000000001110010000000000001111000000001001110000000000000100000000011110000000000000000000000000000010100000000000000000100000000000000110001111000010001000000000000000000011010000000000000000010001101100000100001000000110011000011010010000000000000000000100001000011000110001010000000100000000000000000000000000000000000010000000000100000000000000010100000100000000000000000000000000000000000100001000000000000000010110100000000000010010000000000000000000100000000001100000011000000000000000000000000000000110010000110000100000   

Thanks R1
 


Title: Re: Looking for old program or help recreating it
Post by: bplus on December 07, 2021, 11:43:35 am
I think I saw a program like that for Rock, Paper, Scissors at a Basic forum. Might try that for searches.
Title: Re: Looking for old program or help recreating it
Post by: random1 on December 07, 2021, 03:08:49 pm
All rock, paper, scissors that I have ever seen just use a random number generator
to select one of the options.

What I am looking for is more a learning algorithm for forecasting / prediction.
The app I mentioned learnt from the users inputs and used user data to predict the
users next choice.

My idea was to swap the user input with data strings and automate the process.  What I
am using now and how it works.

First it takes a number of random samples from within the string, both the number of samples
and the length of each sample are set within a configuration menu. Around 350 works best for
the number of samples along with a sample size of 8 to 25 digits, user defined.

Next it calculates ratios for ones vs zeros for each sample. This allows me to calculate a sort
of running average.  The overall totals for the main data string are calculated before the data
is fed into the predictor and the probabilities are used to help calculate a weight which is then
used in the final prediction.
   
The final prediction is made by looking at a sample taken from the last so many entries -1
so if the sample length is 25 then it collects the last 24 and then adds one to the zero count
and calculates the ratio then the same thing is done again adding a one to the ones count.

Whichever comes closest to the running average +/- the weight is the predicted value.  It's
sort of a best fit model.

If I remember correctly the program I mentioned at the head of the topic reached over a 80%
hit rate in less than 100 plays when looking at the last 10 or so attempts.

The program mentioned uses random choices at first until it had enough data to feed the prediction algorithm.

The more games played the better it got at predicting users next choice.  At the time I was not
able to figure out how the algorithm worked as it's code was way above my skill level.

I am starting a new predictor project and welcome any input from others.  Some of the 800 plus
data strings I use are too random to be of any use while others are not.  My goal is to find around
25 out of the 800 that can be predicted with a high degree of consistency. 

R1
Title: Re: Looking for old program or help recreating it
Post by: bplus on December 07, 2021, 03:51:38 pm
Yeah the RPS thing was an AI or NeuroNet that picked up patterns and was to show how badly humans played Rock, Paper, Scissors because humans are bad at randomness.

I like this challenge, I will try an approach I used here:
https://www.qb64.org/forum/index.php?topic=2122.0
Title: Re: Looking for old program or help recreating it
Post by: bplus on December 07, 2021, 04:45:29 pm
At first I thought this was crap, then I saw a > sign turned the wrong way!

I get better than average for AI:
Code: QB64: [Select]
  1. _Title "Predicting Human Randomness" 'b+ 2021-12-07
  2.     If Len(s$) < 8 Then
  3.         If Rnd < .5 Then AI$ = "H" Else AI$ = "T"
  4.     Else
  5.         sum = 0: count = 0
  6.         match$ = Mid$(s$, Len(s$) - 7, 7)
  7.         place = InStr(s$, match$)
  8.         While place <> 0 And place < Len(s$) - 7
  9.             count = count + 1
  10.             char$ = Mid$(s$, place + 8, 1)
  11.             If char$ = "H" Then sum = sum + 1
  12.             place = InStr(place + 1, s$, match$)
  13.         Wend
  14.         If count Then
  15.             Sound 500, 1  ' >>>>>>>>>>>>>>>>>>>>>>>>>>> this signals it found at least one match
  16.             ' >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> check how it does after the sound
  17.             If sum / count > .5 Then AI$ = "H" Else AI$ = "T"
  18.         Else
  19.             If Rnd > .5 Then AI$ = "H" Else AI$ = "T"
  20.         End If
  21.     End If
  22.     Input "Enter H or T "; p$
  23.     p$ = UCase$(p$)
  24.     If p$ = "H" Or p$ = "T" Then s$ = s$ + p$ Else Exit Do
  25.     Print "AI predicted "; AI$
  26.     If AI$ = p$ Then ai = ai + 1
  27.     Print "AI is correct "; 100 * ai / Len(s$); "% times."
  28. Print "AI is correct "; 100 * ai / Len(s$); "% times."
  29. Print "Goodbye!"
  30. Beep 'sorry I get crazy doing h enter, t enter
  31.  
  32.  

Sure if you see what AI is doing you can break it but how about not looking... ;-))
Title: Re: Looking for old program or help recreating it
Post by: bplus on December 07, 2021, 05:20:22 pm
Ran code 1,000,000 times several times.  AI is 50% +- <1% against a Rnd selection for H or T.
Title: Re: Looking for old program or help recreating it
Post by: George McGinn on December 07, 2021, 05:51:50 pm
Human behavior has more patterns that just a random generator.

I vaguely remember that program from way back. If I recall, it used statistical probabilities based on past patterns, such as if the human hits Key A always or most of the time when pressing Key B twice in a row, etc, it used a crude AI to be more predictive.

I had a program that I wrote for Roulette back in the 1990's (I only found my first release of it on 3 1/2 floppies when I wrote it as shareware back in 1990) that determined basic patterns for RED/BLACK and groups of numbers, and against a real wheel I had back then, it was more than 50-50 (like 60% correct). But iPhone didn't exist back then, so I could not drag a large PC into a casino. Instead, I had my program analyze the wheel and betting layout, and came up with a set up numbers and bets to play that makes it very hard for the ball to find an open spot. (DM me if you want these, I have them somewhere)

I never won big money with it, but it made trips to AC and Vegas more enjoyable. Baccarat, that's a different story.

I should re-invent it now that iPhones do exist!  Hmmmm...

I bet we can come up with a better predictive AI today. Just a matter of how much time one's willing to spend on coding --- could make for an interesting QB64 game.
Title: Re: Looking for old program or help recreating it
Post by: cfalcon030 on December 07, 2021, 06:56:08 pm
If you don't mind me asking, what is your end goal? If it's to determine the randomness of your sample data you will need a different algorithm like a Runs test and not a predictive algorithm.
https://en.m.wikipedia.org/wiki/Wald%E2%80%93Wolfowitz_runs_test
Title: Re: Looking for old program or help recreating it
Post by: bplus on December 07, 2021, 07:12:12 pm
My goal was to try and catch humans (myself) being predictable when I try to be random.

I think if you get an AI that does better than 60% you've got something that catches patterns in human play.
Title: Re: Looking for old program or help recreating it
Post by: STxAxTIC on December 07, 2021, 07:41:09 pm
This discussion is 90% similar to a thing we studied once, but I took it overboard. I think this handworked example shows a way to answer this question without bogging you guys down with weird notation:

 [ This attachment cannot be displayed inline in 'Print Page' view ]  

tldr: there is a 1/4096 chance that this string was hammered out randomly on a keyboard:  0 1 0 0 1 1 0 0 1 1 1 0 0 1 0 0 1 1 0 0 1 1 1 0
Title: Re: Looking for old program or help recreating it
Post by: random1 on December 08, 2021, 12:19:30 am
My goal
Whatever code we can come up with, I have the methods to test it's effectiveness.

What I am looking for is a method to predict the next digit using the data string history
to make the prediction.  Everything else has already been coded, ie the before and after
code

Whatever I end up using will be part of a universal forecast / prediction tool.

When I coded the main program I done it in such a way that I can swap out the
predictor code without making any other changes.  The input string is named
Dat1$ and the predictors output variable is PV1$.  Anyone with the time to take
a stab at it can use these two variables for input and output.  Name any other
variables whatever you want.  If your code requires fine tuning of any of the
other variables then supply a list and I will add them to the configuration menu
where they can be adjusted.

The main program is already coded to do all the pre & post processing.  It's fully
functional and uses a prng to simulate the predicted value.  I always do this first
to test the code and secondly to get a base line to measure the predictors output. 
Any good predictor should be able to beat the prng's output.

Like I said, I start with over 800 data strings which are fed to the predictor one at a
time in hopes of finding maybe 25 that are mostly predictable.     

The configuration menu allows adjusting up to 10 constants that may be used by the
predictor for fine tuning.  These include but are not limited to, the number of data points,
# of samples to use, length of each sample, weights, trigger threshold etc...   

For development data just generate random strings 0's and 1's around 3000 to 5000
digits in length.  I will test any posted code against real data and report the results.

Thanks in advance

R1
 
   
Title: Re: Looking for old program or help recreating it
Post by: STxAxTIC on December 08, 2021, 12:57:27 am
This is a cool question. Maybe there's a Markov chain-like hack that can be done to help with this, but I'm still maybe... call it 66% sure that the method I described above can handle this.

The Argument: If the user is doing some kind of pattern apart from randomness when they type, then the pattern may be detectable in any number of "frequencies", which means to say, detectable by looking at "clusters of N digits". For this problem, realistic values of N may be from 2 to say, 10.

The Method: we can define different "alphabets" based on clusters of 1's and 0's in groups of N. For N=2, we have a 4-letter alphabet 00, 01, 10, 11. For N=3, there are quite a few more "letters", i.e. 000, 001, 010, 011, etc etc , 110, 111. I call these clusters "letters" because you should think of each cluster as *one* symbol. Without driving the connection too hard, we can say A=00, B=01, C=10, D=11. Or further, choosing a different set of letters for N=3, a=000, b=001, c=010, etc etc.

With me so far? A big string of 1's and 0's as you have given can be translated into a string made of letters ABCD, which will have half the length as the original. Or, express the original string of 1's and 0's using the N=3 letters to get a shorter translation. Each translation carries the same information, of course. The point is, you can easily see which "letters" are repeated, which are ignored, so on and so forth. It's definitely a way to go. I may try it!

I don't want us to talk past each other though cause if I solve this thing I need an audience of N>0.

------------------------------

BUT, that's a lot of work. I think the cheapest, least airtight but nontrivial way to do this uses one variable and one rule: "once the user feels they have repeated themselves X times", remember X.
Title: Re: Looking for old program or help recreating it
Post by: Dimster on December 08, 2021, 11:08:14 am
Just looking at your sample set, you could just total the number of times a "0" was selected v's a "1". In your sample set the "0" out numbers the "1" by a large margin. So predicting a "0" at the beginning your program would be correct more times than it's wrong. If "0" is the predominant then that becomes the goto prediction and the program then just needs to watch for the pattern of the "1". ie, if a "1" then how often is the very next select another "1". So you just need the program to decide on when to predict a "1". We all have predictable behaviors. I would think, if you had a moving average for the selection of "1" your program could determine if the user is increasing or deceasing the selection of "1". Not that this kind of pattern prediction would be correct all the time but it could be correct more times than it would be wrong. This approach is not that sophisticated, such a program would not be a true Artificial Intelligent predictor of human behavior because there are only the two inputs (like a flip of a coin). Neither does it "learn" so I'd guess it would plateau in it's effectiveness of correct predictions and be very slow to adapt to the user's change in strategy of selection/repeat selections. But given enough data in the moving average it could adapt as well.
Title: Re: Looking for old program or help recreating it
Post by: random1 on December 08, 2021, 07:17:17 pm
Dimster

All the strings have different ratios of 0's and 1's.  Some work out to 90/10 and your correct that
playing the value with the highest ratio in these cases would produce the most hits.  I am looking
for something that can take into account several factors such as runs of 0's or 1's, frequency, etc.
and then make it's prediction based on these factors. 

STxAxTIC
My manual analysis uses Markov chains and allows searching for strings within the chain.  See the
attached picture

These work well enough, it's the time that it takes, that's the problem.  After 10 or so analysis my mind
is worn out so to say processing the data.  I have a automated version of the Markov string analysis but
it needs some help or a sort of a decision tree to make the final prediction. 

No one piece of information is good enough to base a prediction on, I tried coding a decision tree with no
success as it too needs some sort of learning algorithm that combines the data into experts before
making it's choices.   

In the attached image, looking at the top string of data, you can see the first 4 values highlighted in
blue.  The tool searches the entire string looking for an exact match.  Whenever if finds a match it
records the value preceding the selected pattern.  The second string shows the results of the search

Only a small portion of the main data string is visible in the tools window.  The second string and the graph at the bottom show the results of the search string.  You can also see a simple set of statistics for the returned results. 

Shows (0)= the number of times 0 appears within the results
Out = it's last appearance
Avg= average
L/R = longest run
Probability
STC = short trend shows
Exp = the number of times the value is expected to show in a shortened data set.  It's calculated
using the overall probability * the short trend.  I think stc is set to 20.  You can see by this value
how well the results track with the overall.  If this value is different, ie, higher or lower than it's
expected value than it;s a good indicator to include in the prediction process.
   
The values are displayed for both 0's and 1's.  The color graph is there because it's easier on the eyes
than looking at the 0&1's string.

One approach would be to increase the number of statistical observations and then code some
sort of a decision tree to make the final choice.  The values shown are not sufficient so more
are needed.   In the automated tool I am building all these plus others are planned as part of
the final prediction.
The tool in the picture allows for adding and subtracting digits in the search string, if a person
only knew when to stop, LOL.
 

https://i.postimg.cc/NjvwW9KL/markov-analysis.png (https://i.postimg.cc/NjvwW9KL/markov-analysis.png) 
   

Thanks Again
R1
Title: Re: Looking for old program or help recreating it
Post by: random1 on December 08, 2021, 07:52:29 pm
Something else I find interesting.  The results string shows 95 results.  Any 4 digit binary string
has 16 possible arrangements of 0's and 1's.   The expected average for any one pattern of four
digits is 95/16=6, rounded.  In the picture we can see that the pattern 0110 appears 8 times
which equals  .084 vs the expected .063.  Is this usable, maybe, maybe not.

https://i.postimg.cc/4dgDSryM/ma-2.png (https://i.postimg.cc/4dgDSryM/ma-2.png)

R1

Edit
I missed a, 0110 in the search results, it appears 9 times for .094 hit rate
Title: Re: Looking for old program or help recreating it
Post by: STxAxTIC on December 08, 2021, 08:12:40 pm
Hey @random1

I'll look a little more deeply into your attempts right after I post this, but I want you let you know I'm cracking this problem pretty easily based on a previous work of mine. I want to bring you on board with this. So please consider this random string:

"010010010100100101010100101010101010101010101101101010101001111101010101010101010101001010101010"

Qualitatively, what I tried to do was just mash 1 and 0 in a sloppy left-right fashion. Sure, there are clusters of 0's and 1's, no problem. But the overall dominating pattern, particularly at the end, is alternating 0's and 1's. So, can we make a program to detect that? Absolutely yes. The model is fully general and will detect any pattern at any frequency up to n=5 characters at a time, but one can easily make this bigger. See if you can make sense of the code below. I didn't explain it much here, but the stuff I was saying above is implemented in this code. You can see that there will be numbers accumulating next to common patterns in the test string. Super fast, super systematic, will answer your question... Lemme know what you think before this code gets too far ahead. I'll quit til I hear back.

Code: QB64: [Select]
  1. Screen _NewImage(800, 800, 32)
  2.  
  3. Type Letter
  4.     Signature As String
  5.     Count As Integer
  6.  
  7. Dim Shared Alphabet1(2) As Letter
  8. Alphabet1(1).Signature = "0"
  9. Alphabet1(2).Signature = "1"
  10.  
  11. Dim Shared Alphabet2(4) As Letter
  12. Alphabet2(1).Signature = "00"
  13. Alphabet2(2).Signature = "01"
  14. Alphabet2(3).Signature = "10"
  15. Alphabet2(4).Signature = "11"
  16.  
  17. Dim Shared Alphabet3(8) As Letter
  18. Alphabet3(1).Signature = "000"
  19. Alphabet3(2).Signature = "001"
  20. Alphabet3(3).Signature = "010"
  21. Alphabet3(4).Signature = "011"
  22. Alphabet3(5).Signature = "100"
  23. Alphabet3(6).Signature = "101"
  24. Alphabet3(7).Signature = "110"
  25. Alphabet3(8).Signature = "111"
  26.  
  27. Dim Shared Alphabet4(16) As Letter
  28. Alphabet4(1).Signature = "0000"
  29. Alphabet4(2).Signature = "0001"
  30. Alphabet4(3).Signature = "0010"
  31. Alphabet4(4).Signature = "0011"
  32. Alphabet4(5).Signature = "0100"
  33. Alphabet4(6).Signature = "0101"
  34. Alphabet4(7).Signature = "0110"
  35. Alphabet4(8).Signature = "0111"
  36. Alphabet4(9).Signature = "1000"
  37. Alphabet4(10).Signature = "1001"
  38. Alphabet4(11).Signature = "1010"
  39. Alphabet4(12).Signature = "1011"
  40. Alphabet4(13).Signature = "1100"
  41. Alphabet4(14).Signature = "1101"
  42. Alphabet4(15).Signature = "1110"
  43. Alphabet4(16).Signature = "1111"
  44.  
  45. Dim Shared Alphabet5(32) As Letter
  46. Alphabet5(1).Signature = "00000"
  47. Alphabet5(2).Signature = "00001"
  48. Alphabet5(3).Signature = "00010"
  49. Alphabet5(4).Signature = "00011"
  50. Alphabet5(5).Signature = "00100"
  51. Alphabet5(6).Signature = "00101"
  52. Alphabet5(7).Signature = "00110"
  53. Alphabet5(8).Signature = "00111"
  54. Alphabet5(9).Signature = "01000"
  55. Alphabet5(10).Signature = "01001"
  56. Alphabet5(11).Signature = "01010"
  57. Alphabet5(12).Signature = "01011"
  58. Alphabet5(13).Signature = "01100"
  59. Alphabet5(14).Signature = "01101"
  60. Alphabet5(15).Signature = "01110"
  61. Alphabet5(16).Signature = "01111"
  62. Alphabet5(17).Signature = "10000"
  63. Alphabet5(18).Signature = "10001"
  64. Alphabet5(19).Signature = "10010"
  65. Alphabet5(20).Signature = "10011"
  66. Alphabet5(21).Signature = "10100"
  67. Alphabet5(22).Signature = "10101"
  68. Alphabet5(23).Signature = "10110"
  69. Alphabet5(24).Signature = "10111"
  70. Alphabet5(25).Signature = "11000"
  71. Alphabet5(26).Signature = "11001"
  72. Alphabet5(27).Signature = "11010"
  73. Alphabet5(28).Signature = "11011"
  74. Alphabet5(29).Signature = "11100"
  75. Alphabet5(30).Signature = "11101"
  76. Alphabet5(31).Signature = "11110"
  77. Alphabet5(32).Signature = "11111"
  78.  
  79.  
  80. Call ResetCount
  81.  
  82. Dim FingerPrint(6) As String
  83.  
  84. FingerPrint(1) = "010010010100100101010100101010101010101010101101101010101001111101010101010101010101001010101010"
  85.  
  86. For n = 2 To UBound(FingerPrint)
  87.     FingerPrint(n) = Right$(FingerPrint(n - 1), Len(FingerPrint(n - 1)) - 1) + Left$(FingerPrint(n - 1), 1)
  88.  
  89. For m = 1 To 2
  90.     For n = 1 To Len(FingerPrint(m)) Step 2
  91.         a$ = Mid$(FingerPrint(m), n, 2)
  92.         For k = 1 To UBound(Alphabet2)
  93.             If a$ = Alphabet2(k).Signature Then
  94.                 Alphabet2(k).Count = Alphabet2(k).Count + 1
  95.             End If
  96.         Next
  97.     Next
  98.  
  99.     For k = 1 To UBound(Alphabet2)
  100.         Locate k, 1 + 12 * (m - 1)
  101.         Print Alphabet2(k).Signature; Alphabet2(k).Count
  102.     Next
  103.  
  104.     Sleep
  105.  
  106.  
  107. For m = 1 To 3
  108.     For n = 1 To Len(FingerPrint(m)) Step 3
  109.         a$ = Mid$(FingerPrint(m), n, 3)
  110.         For k = 1 To UBound(Alphabet3)
  111.             If a$ = Alphabet3(k).Signature Then
  112.                 Alphabet3(k).Count = Alphabet3(k).Count + 1
  113.             End If
  114.         Next
  115.     Next
  116.  
  117.     For k = 1 To UBound(Alphabet3)
  118.         Locate k, 1 + 12 * (m - 1)
  119.         Print Alphabet3(k).Signature; Alphabet3(k).Count
  120.     Next
  121.  
  122.     Sleep
  123.  
  124.  
  125. For m = 1 To 4
  126.     For n = 1 To Len(FingerPrint(m)) Step 4
  127.         a$ = Mid$(FingerPrint(m), n, 4)
  128.         For k = 1 To UBound(Alphabet4)
  129.             If a$ = Alphabet4(k).Signature Then
  130.                 Alphabet4(k).Count = Alphabet4(k).Count + 1
  131.             End If
  132.         Next
  133.     Next
  134.  
  135.     For k = 1 To UBound(Alphabet4)
  136.         Locate k, 1 + 12 * (m - 1)
  137.         Print Alphabet4(k).Signature; Alphabet4(k).Count
  138.     Next
  139.  
  140.     Sleep
  141.  
  142.  
  143. For m = 1 To 5
  144.     For n = 1 To Len(FingerPrint(m)) Step 5
  145.         a$ = Mid$(FingerPrint(m), n, 5)
  146.         For k = 1 To UBound(Alphabet5)
  147.             If a$ = Alphabet5(k).Signature Then
  148.                 Alphabet5(k).Count = Alphabet5(k).Count + 1
  149.             End If
  150.         Next
  151.     Next
  152.  
  153.     For k = 1 To UBound(Alphabet5)
  154.         Locate k, 1 + 12 * (m - 1)
  155.         Print Alphabet5(k).Signature; Alphabet5(k).Count
  156.     Next
  157.  
  158.     Sleep
  159.  
  160.  
  161. Sub ResetCount
  162.     For n = 1 To UBound(Alphabet1)
  163.         Alphabet1(n).Count = 0
  164.     Next
  165.     For n = 1 To UBound(Alphabet2)
  166.         Alphabet2(n).Count = 0
  167.     Next
  168.     For n = 1 To UBound(Alphabet3)
  169.         Alphabet3(n).Count = 0
  170.     Next
  171.     For n = 1 To UBound(Alphabet4)
  172.         Alphabet4(n).Count = 0
  173.     Next

Title: Re: Looking for old program or help recreating it
Post by: STxAxTIC on December 08, 2021, 08:24:42 pm
Alright, I couldn't resist running your sample data string into my program. I can see you picked a weird sequence, but I highlighted the most indicative numbers (as of now)... see if any of that seems useful, seeing how you studied that string extensively, I bet:

Code: [Select]
0001000001011100000011000100011000010010000000000000000011000000000000000001110010000000000001111000000001001110000000000000100000000011110000000000000000000000000000010100000000000000000100000000000000110001111000010001000000000000000000011010000000000000000010001101100000100001000000110011000011010010000000000000000000100001000011000110001010000000100000000000000000000000000000000000010000000000100000000000000010100000100000000000000000000000000000000000100001000000000000000010110100000000000010010000000000000000000100000000001100000011000000000000000000000000000000110010000110000100000   
  [ This attachment cannot be displayed inline in 'Print Page' view ]  

Oh, and if I was to finish coding the program, I would have it predict a 0 for the next digit.
Title: Re: Looking for old program or help recreating it
Post by: random1 on December 08, 2021, 09:58:35 pm
I feel I need to elaborate a little more.  Look at the second image and pay attention
to the 0110 patterns within the results string that are highlighted in green.  Counting
the one I missed there are 9.  The data flows from right to left with the latest entries
on the left.  If we look at the results string from right to left we notice that the following
digit after each 0110 pattern is a (1).  This is what I would classify as an Expert. 

I would have no reservations predicting digit 1 as the next value in the string.  Each
string has to be analyzed to try and find it's own expert.  And each expert should be
assigned a confidence level between 0 and .99.  It's also that more than one expert
can be found through our analysis.  The search pattern should always be taken from
the left most part of the string because that's what we are looking for to make the
next prediction.   The experts if any will change day to day most of the time so it's
important to be able to find them on the fly so to say. 

The possibilities are almost limitless as to what we might use to construct a prediction
model so try to think outside the box.  Anyway, I hope the information I have presented
here helps to kick start other ideas.

R1     
           
Title: Re: Looking for old program or help recreating it
Post by: STxAxTIC on December 08, 2021, 10:04:15 pm
I'll keep looking at what you're attempting but do you not agree that the program above assigns "0110" a somewhat high "score"? (It would be on the previous screen, not in the screenshot itself, which has the 5 digit analysis.) There are few more common strings, such as "0000", so that truth is up there too.

Let me ask, what is the end result of this? You want an Eliza-like program that tries to guess what my next number is, and then honestly reports the guess after I finally make my choice? Cause that's where I thought you were going.
Title: Re: Looking for old program or help recreating it
Post by: random1 on December 08, 2021, 10:09:47 pm
 STxAxTIC

I will have to look up the string I posted to see what the next value was as it's been
updated a couple times since I posted it.  I should have kept a note of which string I
used.  My program copies each string I look at to the clipboard automatically and I
just selected one at random.  If/when you finish your code so that it makes a 0 or 1
prediction I will run it against all 800 + strings and report back to it's overall hit rate.
Many thanks for posting.

R1
Title: Re: Looking for old program or help recreating it
Post by: random1 on December 08, 2021, 10:28:43 pm
The main goal is to produce a universal prediction tool.  The 0110 is nothing more than
the values of the last 4 entries.  The string changes day to day and when using the first
4 digits then we have 16 possibilities but each day the sequence is determined by the
events I track.  Each string is updated daily by adding a 0 or 1 to the string.  if the event
accrued then a 1 is added if not then a 0.  The reason I mentioned the old program  was
my interest in the algorithm it used.  I was wondering how it would stack up as a predictor
against my data.  Instead of me imputing one digit at a time I would feed it a string of
3k to 5k in length and see how successful it was.   It seems to me if the method it used
could predict my next choice then given enough data it might be useful to my current
project.  I am not building a game, I wanted to repurpose the code into something useful. 
 
Sorry if I was not clear in this.

R1
Title: Re: Looking for old program or help recreating it
Post by: random1 on December 08, 2021, 10:50:03 pm
P.S.  I track over 800 events each day so I have over 800 strings that I try to predict.
Standard prediction tools don't work, I've tried all sorts of methods and figure I needed
to start thinking outside the box if it's going to be successful.

Anyway, that's where I am at.   My last attempt failed and it was sometimes hitting
over 80% correct.  The problem was that the tool was not consistent enough to meet
my needs. This has been a ongoing project that I have been working on for years.

R1   
Title: Re: Looking for old program or help recreating it
Post by: STxAxTIC on December 08, 2021, 11:32:10 pm
I may have to do a video or something on this because the details are getting a bit hard to convey. Anyway, I updated the code to be much more powerful, and I'm attaching a screenshot that outlines one possible good analysis. If we want to continue this, we need to pick a dataset that we'll both use and come up with definite questions about the data that we could use our methods to answer. (Statistical stuff can't really be trusted.) Anyway, here's where it stands on my end. I may do something less lazy than a weighted average at the end, but for now it's getting there:

Code: QB64: [Select]
  1. Type Letter
  2.     Signature As String
  3.     Count As Integer
  4.  
  5. Dim Shared Alphabet1(2) As Letter
  6. Alphabet1(1).Signature = "0"
  7. Alphabet1(2).Signature = "1"
  8.  
  9. Dim Shared Alphabet2(4) As Letter
  10. Dim Shared Alphabet3(8) As Letter
  11. Dim Shared Alphabet4(16) As Letter
  12. Dim Shared Alphabet5(32) As Letter
  13. Dim Shared Alphabet6(64) As Letter
  14. Dim Shared Alphabet7(128) As Letter
  15. Dim Shared Alphabet8(256) As Letter
  16.  
  17. Call NewAlphabet(Alphabet1(), Alphabet2())
  18. Call NewAlphabet(Alphabet2(), Alphabet3())
  19. Call NewAlphabet(Alphabet3(), Alphabet4())
  20. Call NewAlphabet(Alphabet4(), Alphabet5())
  21. Call NewAlphabet(Alphabet5(), Alphabet6())
  22. Call NewAlphabet(Alphabet6(), Alphabet7())
  23. Call NewAlphabet(Alphabet7(), Alphabet8())
  24.  
  25. Dim Shared FingerPrint(16) As String
  26.  
  27. 'FingerPrint(1) = "010010010100100101010100101010101010101010101101101010101001111101010101010101010101001010101010"
  28. FingerPrint(1) = "0001000001011100000011000100011000010010000000000000000011000000000000000001110010000000000001111000000001001110000000000000100000000011110000000000000000000000000000010100000000000000000100000000000000110001111000010001000000000000000000011010000000000000000010001101100000100001000000110011000011010010000000000000000000100001000011000110001010000000100000000000000000000000000000000000010000000000100000000000000010100000100000000000000000000000000000000000100001000000000000000010110100000000000010010000000000000000000100000000001100000011000000000000000000000000000000110010000110000100000"
  29.  
  30. For n = 2 To UBound(FingerPrint)
  31.     FingerPrint(n) = Right$(FingerPrint(n - 1), Len(FingerPrint(n - 1)) - 1) + Left$(FingerPrint(n - 1), 1)
  32.  
  33. Call UpdateHisto(Alphabet2(), 2)
  34. Call PrintHisto(Alphabet2())
  35.  
  36. Call UpdateHisto(Alphabet3(), 3)
  37. Call PrintHisto(Alphabet3())
  38.  
  39. Call UpdateHisto(Alphabet4(), 4)
  40. Call PrintHisto(Alphabet4())
  41.  
  42. Call UpdateHisto(Alphabet5(), 5)
  43. Call PrintHisto(Alphabet5())
  44.  
  45. Call UpdateHisto(Alphabet6(), 6)
  46. Call PrintHisto(Alphabet6())
  47.  
  48. Call UpdateHisto(Alphabet7(), 7)
  49. Call PrintHisto(Alphabet7())
  50.  
  51. Call UpdateHisto(Alphabet8(), 8)
  52. Call PrintHisto(Alphabet8())
  53.  
  54.  
  55. Sub UpdateHisto (arr() As Letter, w As Integer)
  56.     For m = 1 To w
  57.         For n = 1 To Len(FingerPrint(m)) Step w
  58.             a$ = Mid$(FingerPrint(m), n, w)
  59.             For k = 1 To UBound(arr)
  60.                 If a$ = arr(k).Signature Then
  61.                     arr(k).Count = arr(k).Count + 1
  62.                 End If
  63.             Next
  64.         Next
  65.     Next
  66.  
  67. Sub PrintHisto (arr() As Letter)
  68.     Call BubbleSort(arr())
  69.     For k = UBound(arr) To 1 Step -1
  70.         Print arr(k).Signature; arr(k).Count
  71.     Next
  72.     Sleep
  73.     Cls
  74.  
  75. Sub NewAlphabet (arrold() As Letter, arrnew() As Letter)
  76.     n = 0
  77.     For j = 1 To 2
  78.         For k = 1 To UBound(arrold)
  79.             n = n + 1
  80.             arrnew(n).Signature = arrold(k).Signature
  81.         Next
  82.     Next
  83.     For k = 1 To UBound(arrnew)
  84.         If k <= UBound(arrnew) / 2 Then
  85.             arrnew(k).Signature = "0" + arrnew(k).Signature
  86.         Else
  87.             arrnew(k).Signature = "1" + arrnew(k).Signature
  88.         End If
  89.     Next
  90.  
  91. Sub BubbleSort (arr() As Letter)
  92.     Dim As Integer i, j
  93.     Dim As Double u, v
  94.     For j = UBound(arr) To 1 Step -1
  95.         For i = 2 To UBound(arr)
  96.             u = arr(i - 1).Count
  97.             v = arr(i).Count
  98.             If (u < v) Then
  99.                 Swap arr(i - 1), arr(i)
  100.             End If
  101.         Next
  102.     Next

  [ This attachment cannot be displayed inline in 'Print Page' view ]  
Title: Re: Looking for old program or help recreating it
Post by: SMcNeill on December 09, 2021, 12:42:58 am
What you're trying to do, it sounds like, is basically what this guy over at Numberphile talks about.  Take a look at the video.  I think you might like it and it might give you some insight into what your program needs to have to be a human sequence tester.

Title: Re: Looking for old program or help recreating it
Post by: STxAxTIC on December 09, 2021, 01:47:53 am
Yeah, this guy's ^ in the same ballpark, mostly. This whole topic does make me sigh just a little, like am I the only one who remembers doing work like this with you guys (Steve, bplus) like 2 years ago? We were able to detect ordered strings hidden in a bunch of randomness. That old problem, the video above, the present problem - all the same ballpark. In fact, the topic of the video is quite a bit simpler than the thing we're doing. (Just run the guy's string of H and T through my code and see the uneven distributions.) Anyway, thanks for bringing that up Steve. I'm gonna keep playing this this 'cause I'm not sure if I'm being thorough enough in my explanations.
Title: Re: Looking for old program or help recreating it
Post by: STxAxTIC on December 09, 2021, 07:39:45 am
Okay so @random1...

For the sake of setting the bar somewhere, consider this data set:

Code: [Select]
string = "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000": nextdigit = "0"
'
string = "01010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101": nextdigit = "0"
string = "10101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010": nextdigit = "1"
'
string = "00100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100": nextdigit = "1"
string = "01001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001": nextdigit = "0"
string = "10010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010": nextdigit = "0"
'
string = "00010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001": nextdigit = "0"
string = "00100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010": nextdigit = "0"
string = "01000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100": nextdigit = "0"
string = "10001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000": nextdigit = "1"
'
string = "00001000010000100001000010000100001000010000100001000010000100001000010000100001000010000100001000010000100001000010000100001000": nextdigit = "0"
string = "00010000100001000010000100001000010000100001000010000100001000010000100001000010000100001000010000100001000010000100001000010000": nextdigit = "1"
string = "00100001000010000100001000010000100001000010000100001000010000100001000010000100001000010000100001000010000100001000010000100001": nextdigit = "0"
string = "01000010000100001000010000100001000010000100001000010000100001000010000100001000010000100001000010000100001000010000100001000010": nextdigit = "0"
string = "10000100001000010000100001000010000100001000010000100001000010000100001000010000100001000010000100001000010000100001000010000100": nextdigit = "0"
'
string = "00000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100": nextdigit = "0"
string = "00001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000": nextdigit = "0"
string = "00010000010000010000010000010000010000010000010000010000010000010000010000010000010000010000010000010000010000010000010000010000": nextdigit = "0"
string = "00100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000": nextdigit = "1"
string = "01000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001": nextdigit = "0"
string = "10000010000010000010000010000010000010000010000010000010000010000010000010000010000010000010000010000010000010000010000010000010": nextdigit = "0"
'
string = "00000010000001000000100000010000001000000100000010000001000000100000010000001000000100000010000001000000100000010000001000000100": nextdigit = "0"
string = "00100000010000001000000100000010000001000000100000010000001000000100000010000001000000100000010000001000000100000010000001000000": nextdigit = "1"
'
string = "00000001000000010000000100000001000000010000000100000001000000010000000100000001000000010000000100000001000000010000000100000001": nextdigit = "0"
string = "10000000100000001000000010000000100000001000000010000000100000001000000010000000100000001000000010000000100000001000000010000000": nextdigit = "1"
'
string = "00110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011": nextdigit = "0"
string = "01100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110": nextdigit = "0"
string = "11001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100": nextdigit = "1"
string = "10011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001": nextdigit = "1"
'
string = "00011100011100011100011100011100011100011100011100011100011100011100011100011100011100011100011100011100011100011100011100011100": nextdigit = "0"
string = "00111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000": nextdigit = "1"
string = "01110001110001110001110001110001110001110001110001110001110001110001110001110001110001110001110001110001110001110001110001110001": nextdigit = "1"
string = "11100011100011100011100011100011100011100011100011100011100011100011100011100011100011100011100011100011100011100011100011100011": nextdigit = "1"
string = "11000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111": nextdigit = "0"
string = "10001110001110001110001110001110001110001110001110001110001110001110001110001110001110001110001110001110001110001110001110001110": nextdigit = "0"
'
string = "01001100011101001100011101001100011101001100011101001100011101001100011101001100011101001100011101001100011101001100011101001100": nextdigit = "0"
string = "10011000111010011000111010011000111010011000111010011000111010011000111010011000111010011000111010011000111010011000111010011000": nextdigit = "1"
string = "00110001110100110001110100110001110100110001110100110001110100110001110100110001110100110001110100110001110100110001110100110001": nextdigit = "1"
string = "01100011101001100011101001100011101001100011101001100011101001100011101001100011101001100011101001100011101001100011101001100011": nextdigit = "1"
string = "11000111010011000111010011000111010011000111010011000111010011000111010011000111010011000111010011000111010011000111010011000111": nextdigit = "0"
string = "10001110100110001110100110001110100110001110100110001110100110001110100110001110100110001110100110001110100110001110100110001110": nextdigit = "1"
string = "00011101001100011101001100011101001100011101001100011101001100011101001100011101001100011101001100011101001100011101001100011101": nextdigit = "0"
'
string = "01001010101010010101010001110100101010101001010101000111010010101010100101010100011101001010101010010101010001110100101010101001": nextdigit = "0"
string = "10010101010100101010100011101001010101010010101010001110100101010101001010101000111010010101010100101010100011101001010101010010": nextdigit = "1"
string = "00101010101001010101000111010010101010100101010100011101001010101010010101010001110100101010101001010101000111010010101010100101": nextdigit = "0"
string = "01010101010010101010001110100101010101001010101000111010010101010100101010100011101001010101010010101010001110100101010101001010": nextdigit = "1"
string = "10101010100101010100011101001010101010010101010001110100101010101001010101000111010010101010100101010100011101001010101010010101": nextdigit = "0"
string = "01010101001010101000111010010101010100101010100011101001010101010010101010001110100101010101001010101000111010010101010100101010": nextdigit = "1"
string = "10101010010101010001110100101010101001010101000111010010101010100101010100011101001010101010010101010001110100101010101001010101": nextdigit = "0"
string = "01010100101010100011101001010101010010101010001110100101010101001010101000111010010101010100101010100011101001010101010010101010": nextdigit = "0"
string = "10101001010101000111010010101010100101010100011101001010101010010101010001110100101010101001010101000111010010101010100101010100": nextdigit = "0"
string = "01010010101010001110100101010101001010101000111010010101010100101010100011101001010101010010101010001110100101010101001010101000": nextdigit = "1"
string = "10100101010100011101001010101010010101010001110100101010101001010101000111010010101010100101010100011101001010101010010101010001": nextdigit = "1"

What we've got is a nice bunch of patterns of zero and ones. In each case, even for the ugly later cases, there is always a pattern going on, and I specified the correct next digit in a separate string. This is the kind of data set I would need to test a method I would come up with. Come up with a guess, square it off against the known result. So before reading on, my fast question to you is: How well will your methods predict the so-called "next digit" in each of these? Will that take long? Give it a shot for me.

-----

The code below gets every single one of those examples correct, with the exception of *one* case, and that's because I had to nerf my code down to make sure it wasn't somehow giving an "always right" bug. I needed to see *one* mistake take place, so I contrived a case that I knew could trick it (it takes place right before the end). Alas, it doesn't need to be this way, there is no flaw in the method that I can see - it'll just have to run slightly slower to be 100% perfect. But anyway, here is the bar. Call it 99% "perfect" for the data being used:

Code: QB64: [Select]
  1. Type Letter
  2.     Signature As String
  3.     Count As Integer
  4.  
  5. Dim Shared FingerPrint(16) As String
  6.  
  7. Dim Shared Alphabet1(2) As Letter
  8. Alphabet1(1).Signature = "0"
  9. Alphabet1(2).Signature = "1"
  10.  
  11. Dim Shared Alphabet2(4) As Letter
  12. Dim Shared Alphabet3(8) As Letter
  13. Dim Shared Alphabet4(16) As Letter
  14. Dim Shared Alphabet5(32) As Letter
  15. Dim Shared Alphabet6(64) As Letter
  16. Dim Shared Alphabet7(128) As Letter
  17. Dim Shared Alphabet8(256) As Letter
  18. Dim Shared Alphabet9(512) As Letter
  19. Dim Shared Alphabet10(1024) As Letter
  20. Dim Shared Alphabet11(2048) As Letter
  21. Dim Shared Alphabet12(4096) As Letter
  22. 'Dim Shared Alphabet13(8192) As Letter
  23.  
  24. Call NewAlphabet(Alphabet1(), Alphabet2())
  25. Call NewAlphabet(Alphabet2(), Alphabet3())
  26. Call NewAlphabet(Alphabet3(), Alphabet4())
  27. Call NewAlphabet(Alphabet4(), Alphabet5())
  28. Call NewAlphabet(Alphabet5(), Alphabet6())
  29. Call NewAlphabet(Alphabet6(), Alphabet7())
  30. Call NewAlphabet(Alphabet7(), Alphabet8())
  31. Call NewAlphabet(Alphabet8(), Alphabet9())
  32. Call NewAlphabet(Alphabet9(), Alphabet10())
  33. Call NewAlphabet(Alphabet10(), Alphabet11())
  34. Call NewAlphabet(Alphabet11(), Alphabet12())
  35. 'Call NewAlphabet(Alphabet12(), Alphabet13())
  36.  
  37. n = 0
  38. ReDim Shared TheInput(1000, 2) As String
  39.  
  40. n = n + 1: TheInput(n, 1) = "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000": TheInput(n, 2) = "0"
  41. '
  42. n = n + 1: TheInput(n, 1) = "01010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101": TheInput(n, 2) = "0"
  43. n = n + 1: TheInput(n, 1) = "10101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010": TheInput(n, 2) = "1"
  44. '
  45. n = n + 1: TheInput(n, 1) = "00100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100": TheInput(n, 2) = "1"
  46. n = n + 1: TheInput(n, 1) = "01001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001": TheInput(n, 2) = "0"
  47. n = n + 1: TheInput(n, 1) = "10010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010": TheInput(n, 2) = "0"
  48. '
  49. n = n + 1: TheInput(n, 1) = "00010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001": TheInput(n, 2) = "0"
  50. n = n + 1: TheInput(n, 1) = "00100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010": TheInput(n, 2) = "0"
  51. n = n + 1: TheInput(n, 1) = "01000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100": TheInput(n, 2) = "0"
  52. n = n + 1: TheInput(n, 1) = "10001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000": TheInput(n, 2) = "1"
  53. '
  54. n = n + 1: TheInput(n, 1) = "00001000010000100001000010000100001000010000100001000010000100001000010000100001000010000100001000010000100001000010000100001000": TheInput(n, 2) = "0"
  55. n = n + 1: TheInput(n, 1) = "00010000100001000010000100001000010000100001000010000100001000010000100001000010000100001000010000100001000010000100001000010000": TheInput(n, 2) = "1"
  56. n = n + 1: TheInput(n, 1) = "00100001000010000100001000010000100001000010000100001000010000100001000010000100001000010000100001000010000100001000010000100001": TheInput(n, 2) = "0"
  57. n = n + 1: TheInput(n, 1) = "01000010000100001000010000100001000010000100001000010000100001000010000100001000010000100001000010000100001000010000100001000010": TheInput(n, 2) = "0"
  58. n = n + 1: TheInput(n, 1) = "10000100001000010000100001000010000100001000010000100001000010000100001000010000100001000010000100001000010000100001000010000100": TheInput(n, 2) = "0"
  59. '
  60. n = n + 1: TheInput(n, 1) = "00000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100": TheInput(n, 2) = "0"
  61. n = n + 1: TheInput(n, 1) = "00001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000": TheInput(n, 2) = "0"
  62. n = n + 1: TheInput(n, 1) = "00010000010000010000010000010000010000010000010000010000010000010000010000010000010000010000010000010000010000010000010000010000": TheInput(n, 2) = "0"
  63. n = n + 1: TheInput(n, 1) = "00100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000": TheInput(n, 2) = "1"
  64. n = n + 1: TheInput(n, 1) = "01000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001": TheInput(n, 2) = "0"
  65. n = n + 1: TheInput(n, 1) = "10000010000010000010000010000010000010000010000010000010000010000010000010000010000010000010000010000010000010000010000010000010": TheInput(n, 2) = "0"
  66. '
  67. n = n + 1: TheInput(n, 1) = "00000010000001000000100000010000001000000100000010000001000000100000010000001000000100000010000001000000100000010000001000000100": TheInput(n, 2) = "0"
  68. n = n + 1: TheInput(n, 1) = "00100000010000001000000100000010000001000000100000010000001000000100000010000001000000100000010000001000000100000010000001000000": TheInput(n, 2) = "1"
  69. '
  70. n = n + 1: TheInput(n, 1) = "00000001000000010000000100000001000000010000000100000001000000010000000100000001000000010000000100000001000000010000000100000001": TheInput(n, 2) = "0"
  71. n = n + 1: TheInput(n, 1) = "10000000100000001000000010000000100000001000000010000000100000001000000010000000100000001000000010000000100000001000000010000000": TheInput(n, 2) = "1"
  72. '
  73. n = n + 1: TheInput(n, 1) = "00110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011": TheInput(n, 2) = "0"
  74. n = n + 1: TheInput(n, 1) = "01100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110": TheInput(n, 2) = "0"
  75. n = n + 1: TheInput(n, 1) = "11001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100": TheInput(n, 2) = "1"
  76. n = n + 1: TheInput(n, 1) = "10011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001": TheInput(n, 2) = "1"
  77. '
  78. n = n + 1: TheInput(n, 1) = "00011100011100011100011100011100011100011100011100011100011100011100011100011100011100011100011100011100011100011100011100011100": TheInput(n, 2) = "0"
  79. n = n + 1: TheInput(n, 1) = "00111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000": TheInput(n, 2) = "1"
  80. n = n + 1: TheInput(n, 1) = "01110001110001110001110001110001110001110001110001110001110001110001110001110001110001110001110001110001110001110001110001110001": TheInput(n, 2) = "1"
  81. n = n + 1: TheInput(n, 1) = "11100011100011100011100011100011100011100011100011100011100011100011100011100011100011100011100011100011100011100011100011100011": TheInput(n, 2) = "1"
  82. n = n + 1: TheInput(n, 1) = "11000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111": TheInput(n, 2) = "0"
  83. n = n + 1: TheInput(n, 1) = "10001110001110001110001110001110001110001110001110001110001110001110001110001110001110001110001110001110001110001110001110001110": TheInput(n, 2) = "0"
  84. '
  85. n = n + 1: TheInput(n, 1) = "01001100011101001100011101001100011101001100011101001100011101001100011101001100011101001100011101001100011101001100011101001100": TheInput(n, 2) = "0"
  86. n = n + 1: TheInput(n, 1) = "10011000111010011000111010011000111010011000111010011000111010011000111010011000111010011000111010011000111010011000111010011000": TheInput(n, 2) = "1"
  87. n = n + 1: TheInput(n, 1) = "00110001110100110001110100110001110100110001110100110001110100110001110100110001110100110001110100110001110100110001110100110001": TheInput(n, 2) = "1"
  88. n = n + 1: TheInput(n, 1) = "01100011101001100011101001100011101001100011101001100011101001100011101001100011101001100011101001100011101001100011101001100011": TheInput(n, 2) = "1"
  89. n = n + 1: TheInput(n, 1) = "11000111010011000111010011000111010011000111010011000111010011000111010011000111010011000111010011000111010011000111010011000111": TheInput(n, 2) = "0"
  90. n = n + 1: TheInput(n, 1) = "10001110100110001110100110001110100110001110100110001110100110001110100110001110100110001110100110001110100110001110100110001110": TheInput(n, 2) = "1"
  91. n = n + 1: TheInput(n, 1) = "00011101001100011101001100011101001100011101001100011101001100011101001100011101001100011101001100011101001100011101001100011101": TheInput(n, 2) = "0"
  92. '
  93. n = n + 1: TheInput(n, 1) = "01001010101010010101010001110100101010101001010101000111010010101010100101010100011101001010101010010101010001110100101010101001": TheInput(n, 2) = "0" '0
  94. n = n + 1: TheInput(n, 1) = "10010101010100101010100011101001010101010010101010001110100101010101001010101000111010010101010100101010100011101001010101010010": TheInput(n, 2) = "1" '1
  95. n = n + 1: TheInput(n, 1) = "00101010101001010101000111010010101010100101010100011101001010101010010101010001110100101010101001010101000111010010101010100101": TheInput(n, 2) = "0" '0
  96. n = n + 1: TheInput(n, 1) = "01010101010010101010001110100101010101001010101000111010010101010100101010100011101001010101010010101010001110100101010101001010": TheInput(n, 2) = "1" '1
  97. n = n + 1: TheInput(n, 1) = "10101010100101010100011101001010101010010101010001110100101010101001010101000111010010101010100101010100011101001010101010010101": TheInput(n, 2) = "0" '0
  98. n = n + 1: TheInput(n, 1) = "01010101001010101000111010010101010100101010100011101001010101010010101010001110100101010101001010101000111010010101010100101010": TheInput(n, 2) = "1" '1
  99. n = n + 1: TheInput(n, 1) = "10101010010101010001110100101010101001010101000111010010101010100101010100011101001010101010010101010001110100101010101001010101": TheInput(n, 2) = "0" '0
  100. n = n + 1: TheInput(n, 1) = "01010100101010100011101001010101010010101010001110100101010101001010101000111010010101010100101010100011101001010101010010101010": TheInput(n, 2) = "0" '0
  101. n = n + 1: TheInput(n, 1) = "10101001010101000111010010101010100101010100011101001010101010010101010001110100101010101001010101000111010010101010100101010100": TheInput(n, 2) = "0" '0
  102. n = n + 1: TheInput(n, 1) = "01010010101010001110100101010101001010101000111010010101010100101010100011101001010101010010101010001110100101010101001010101000": TheInput(n, 2) = "1" '1
  103. n = n + 1: TheInput(n, 1) = "10100101010100011101001010101010010101010001110100101010101001010101000111010010101010100101010100011101001010101010010101010001": TheInput(n, 2) = "1" '1
  104. '
  105. n = n + 1: TheInput(n, 1) = "0001000001011100000011000100011000010010000000000000000011000000000000000001110010000000000001111000000001001110000000000000100000000011110000000000000000000000000000010100000000000000000100000000000000110001111000010001000000000000000000011010000000000000000010001101100000100001000000110011000011010010000000000000000000100001000011000110001010000000100000000000000000000000000000000000010000000000100000000000000010100000100000000000000000000000000000000000100001000000000000000010110100000000000010010000000000000000000100000000001100000011000000000000000000000000000000110010000110000100000": TheInput(n, 2) = "?"
  106. '
  107.  
  108. For m = 1 To n
  109.  
  110.     FingerPrint(1) = TheInput(m, 1)
  111.  
  112.     For k = 2 To UBound(FingerPrint)
  113.         FingerPrint(k) = Right$(FingerPrint(k - 1), Len(FingerPrint(k - 1)) - 1) + Left$(FingerPrint(k - 1), 1)
  114.     Next
  115.  
  116.     Call CreateHisto(Alphabet2(), 2)
  117.     'Call PrintHisto(Alphabet2())
  118.     p2 = MakeGuess(Alphabet2(), 2)
  119.  
  120.     Call CreateHisto(Alphabet3(), 3)
  121.     'Call PrintHisto(Alphabet3())
  122.     p3 = MakeGuess(Alphabet3(), 3)
  123.  
  124.     Call CreateHisto(Alphabet4(), 4)
  125.     'Call PrintHisto(Alphabet4())
  126.     p4 = MakeGuess(Alphabet4(), 4)
  127.  
  128.     Call CreateHisto(Alphabet5(), 5)
  129.     'Call PrintHisto(Alphabet5())
  130.     p5 = MakeGuess(Alphabet5(), 5)
  131.  
  132.     Call CreateHisto(Alphabet6(), 6)
  133.     'Call PrintHisto(Alphabet6())
  134.     p6 = MakeGuess(Alphabet6(), 6)
  135.  
  136.     Call CreateHisto(Alphabet7(), 7)
  137.     'Call PrintHisto(Alphabet7())
  138.     p7 = MakeGuess(Alphabet7(), 7)
  139.  
  140.     Call CreateHisto(Alphabet8(), 8)
  141.     'Call PrintHisto(Alphabet8())
  142.     p8 = MakeGuess(Alphabet8(), 8)
  143.  
  144.     Call CreateHisto(Alphabet9(), 9)
  145.     'Call PrintHisto(Alphabet9())
  146.     p9 = MakeGuess(Alphabet9(), 9)
  147.  
  148.     Call CreateHisto(Alphabet10(), 10)
  149.     'Call PrintHisto(Alphabet10())
  150.     p10 = MakeGuess(Alphabet10(), 10)
  151.  
  152.     Call CreateHisto(Alphabet11(), 11)
  153.     'Call PrintHisto(Alphabet11())
  154.     p11 = MakeGuess(Alphabet11(), 11)
  155.  
  156.     Call CreateHisto(Alphabet12(), 12)
  157.     'Call PrintHisto(Alphabet12())
  158.     p12 = MakeGuess(Alphabet12(), 12)
  159.  
  160.     'Call CreateHisto(Alphabet13(), 13)
  161.     'Call PrintHisto(Alphabet13())
  162.     'p13 = MakeGuess(Alphabet13(), 13)
  163.  
  164.     Cls
  165.     Print "String:"
  166.     Print FingerPrint(1)
  167.     Print
  168.     Print "Predicted:"; p12
  169.     Print "Actual:    "; TheInput(m, 2)
  170.     'Print
  171.     'Print p2; p3; p4; p5; p6; p7; p8; p9; p10; p11; p12; p13
  172.     Sleep
  173.  
  174.  
  175.  
  176. Function MakeGuess (arr() As Letter, w As Integer)
  177.     Dim TheReturn As Integer
  178.     x$ = Right$(FingerPrint(1), w - 1)
  179.     For k = 1 To UBound(arr)
  180.         If Left$(arr(k).Signature, w - 1) = x$ Then
  181.             'Print "..."; arr(k).Signature
  182.             TheReturn = Val(Right$(arr(k).Signature, 1))
  183.             Exit For
  184.         End If
  185.     Next
  186.     MakeGuess = TheReturn
  187.  
  188. Sub CreateHisto (arr() As Letter, w As Integer)
  189.     For m = 1 To w
  190.         For n = 1 To Len(FingerPrint(m)) Step w
  191.             a$ = Mid$(FingerPrint(m), n, w)
  192.             For k = 1 To UBound(arr)
  193.                 If a$ = arr(k).Signature Then
  194.                     arr(k).Count = arr(k).Count + 1
  195.                 End If
  196.             Next
  197.         Next
  198.     Next
  199.     Call BubbleSort(arr())
  200.  
  201. Sub PrintHisto (arr() As Letter)
  202.     For k = 1 To 3
  203.         Print arr(k).Signature; arr(k).Count
  204.     Next
  205.  
  206. Sub NewAlphabet (arrold() As Letter, arrnew() As Letter)
  207.     n = 0
  208.     For j = 1 To 2
  209.         For k = 1 To UBound(arrold)
  210.             n = n + 1
  211.             arrnew(n).Signature = arrold(k).Signature
  212.         Next
  213.     Next
  214.     For k = 1 To UBound(arrnew)
  215.         If k <= UBound(arrnew) / 2 Then
  216.             arrnew(k).Signature = "0" + arrnew(k).Signature
  217.         Else
  218.             arrnew(k).Signature = "1" + arrnew(k).Signature
  219.         End If
  220.     Next
  221.  
  222. Sub BubbleSort (arr() As Letter)
  223.     Dim As Integer i, j
  224.     Dim As Double u, v
  225.     For j = UBound(arr) To 1 Step -1
  226.         For i = 2 To UBound(arr)
  227.             u = arr(i - 1).Count
  228.             v = arr(i).Count
  229.             If (u < v) Then
  230.                 Swap arr(i - 1), arr(i)
  231.             End If
  232.         Next
  233.     Next
Title: Re: Looking for old program or help recreating it
Post by: random1 on December 09, 2021, 09:49:57 am
SMcNeill

The video you posted is on target and a big goal is avoiding the gamblers fallacy like a plague.

Thanks for posting 
 



 
Title: Re: Looking for old program or help recreating it
Post by: random1 on December 09, 2021, 10:52:31 am
STxAxTIC

The strings you show do not have any random elements except for the mentioned.
My approach at this would be a basic counter loop with a quick decimal to binary
converter.  Use an array to store the counts.  Running averages is something I use
but by itself it's not enough to make a solid prediction when the data can be some-
what random.   The video SMcNeill posted shows where I am at and also explains
where the 3rd state comes in, a wild card that skips whenever no clear prediction
can be made. 
Please don't think I am downplaying your input, I am not.  Lets say that we start
with the right most digit in the string and from that value we try to predict the
digit to the left of it.  We then check the prediction against the second leftmost
digit.  Next we add the second digit to the first so that we now have 2 digits to
use in making the next prediction and so on and on. 
If the data does not contain any random data, then as soon as the length of the
pattern is determined it's a no brain'er from that point.  The direction I am headed
is to create a self adapting algorithm to minimize the error, not exactly a neural
network but close.  It seems simple enough until one starts coding.  My thoughts
are to combine several such algorithms into a single predictor using all the outputs
to make the prediction.  The running average is already part of the project.   The
speed of the code is not that important as long as were not talking hours, my current
code takes around 45 seconds to process 800+ strings which includes 2 graphics.

Picture
Green graph shows single string process and pink shows overrall

https://i.postimg.cc/9fqHZchS/splash.png (https://i.postimg.cc/9fqHZchS/splash.png)

R1   
 
 
Title: Re: Looking for old program or help recreating it
Post by: Dimster on December 09, 2021, 11:05:51 am
Just trying to determine if you are trying to predict an event or predict the behavior of a person?

Quote
The main goal is to produce a universal prediction tool.  The 0110 is nothing more than
the values of the last 4 entries.  The string changes day to day and when using the first
4 digits then we have 16 possibilities but each day the sequence is determined by the
events I track.  Each string is updated daily by adding a 0 or 1 to the string.  if the event
accrued then a 1 is added if not then a 0.

Events of nature are truly random but a persons behavior may be predictable.
Title: Re: Looking for old program or help recreating it
Post by: STxAxTIC on December 09, 2021, 12:42:00 pm
Yeah, I kinda figured this would happen.

random1, my method works on random strings also - of course - we need to TEST things with regularized input before we give the algorithm true unknowns.

IF you can't run your stuff on my test data, or won't, the way it really sounds, then Im considering this issue closed and you guys have some reading to do!

Please, let's see how your attempt handles the data I provided. No speculation about it, let's see a test.
Title: Re: Looking for old program or help recreating it
Post by: bplus on December 09, 2021, 12:50:13 pm
Yeah Steve's link was what I was trying to get at, now that I've seen it, I see how poorly I coded my attempt.
Title: Re: Looking for old program or help recreating it
Post by: random1 on December 09, 2021, 01:03:26 pm
The idea is to predict the next event using a algorithm similar to the one in the program
I mentioned at the start of the topic.

In the posted video, notice the bets; penny, dollar and 100 dollars.  The bets seems to be
based on a confidence level, this alone sums up what I am trying to do.  We could think
of the 1's and 0,s as heads and tails if it makes it easier to understand.  Predicting a (0)
is as important as predicting a (1), just need accurate predictions.

My goal is to find 20 to 25 of the 800+ strings that have a very high confidence level and
skip the rest, keep the $100.00 bets so to say and pass on the others. 

One does not need to process the entire string, in the video the $100 bet is made on the
20th of 20 predictions.  The strings length and the amount of data used will be different
depending on the method used.   

I have a couple new ideas and will start coding them in the next day or two.   

Hope this helps

R1 


   
Title: Re: Looking for old program or help recreating it
Post by: STxAxTIC on December 09, 2021, 01:18:10 pm
Okay last reply, I promise - I can't believe what I'm seeing here!

Quote
The strings you show do not have any random elements

Irrelevant point anyway, but if your method works, it will work on that data set.

Quote
The idea is to predict the next event using a algorithm similar to the one in the program
I mentioned at the start of the topic
.

I claim to have solved the bold part of the statement you made. Why insist on the italic part then?

Quote
One does not need to process the entire string

I disagree with this, a fully-informed answer should use all of the data available. Use the whole string, not just recent characters.

Quote
The main goal is to produce a universal prediction tool.

I'm not sure how I feel about this, but the thing I'm using is very close to, or maybe simple *is* - universal. I've publicly tested this method on numbers, strings, etc etc. I honestly can't believe Steve and/or bplus haven't openly remembered this study, or maybe the implications of it were stronger to me than they were to the average reader.

You'll prolly skip right over this encounter in the long run, just remember you have a solution laying around when you care to look into what I'm doing.


Title: Re: Looking for old program or help recreating it
Post by: random1 on December 09, 2021, 01:37:29 pm
"" Yeah, I kinda figured this would happen.

random1, my method works on random strings also - of course - we need to TEST things with regularized input before we give the algorithm true unknowns.

IF you can't run your stuff on my test data, or won't, the way it really sounds, then Im considering this issue closed and you guys have some reading to do!

Please, let's see how your attempt handles the data I provided. No speculation about it, let's see a test."


See the picture below.  I will fully test your code against all 800+strings but can't do it right now
as I am in the middle of a rewrite.  Like I said I don't ignore anything people post but that does not
mean I can jump on it right now.  I detect a bit of ass-hole in your last post.  You don't have to post
anything and it's not my responsibility to work on your time.  People like you are the main reason
I do very little posting.  On second thought, I may not even give your code another look. 
       


https://i.postimg.cc/yYMz0Bc2/stat.png (https://i.postimg.cc/yYMz0Bc2/stat.png)
Title: Re: Looking for old program or help recreating it
Post by: STxAxTIC on December 09, 2021, 01:49:11 pm
Alright man, we can be past the issue of my code. I know it works, the world can see it works. But let's forget about that - pretend I never worked on this problem. Let me start afresh, do a big re-set, and only see things your way, and I mean it.

This will mean:
Quote
I will fully test your code against all 800+strings but can't do it right now

...can go away.

So let's re-begin: I don't need you to test my algorithm, I need you to test my data set. Just run those strings through what you've got and show me how it does. Ya?
Title: Re: Looking for old program or help recreating it
Post by: SpriggsySpriggs on December 09, 2021, 01:50:15 pm
@random1 Welcome to the forum! I don't think I've seen you on here before (but I've been less active recently). Glad to see you are wanting to deal in mathematical programs! @STxAxTIC is our resident mathematician and provides great examples so I hope you can use them to your benefit. Good luck with your program and I wish you the best!
Title: Re: Looking for old program or help recreating it
Post by: SMcNeill on December 09, 2021, 01:58:58 pm
I think the biggest problem with this type of program is simply getting a valid data set to test against. 

Asking QB64 to give you a list of 20 heads or tail results is worthless.  You're not trying to test if the computer is random; you're trying to make a prediction based on human psychology with random numbers.  It's like telling folks to, "Give me a random number between 1 and 10."

Go ahead.   Do it.    Before you read any more of this post, pause and think of a random number between one and ten.

.
.
.
.
.

Got it?

.
.
.
.
.


It's 7.

.
.
.
.
.

Or, at least for 47% of you, it's seven, according to various studies done when people were asked to generate a value from 1 to 10.  If it's not 7, chances are, it's 3.

WHY??

Because both are midways off-center, making them seem "random" to our brain, and both are prime numbers, making them stand out as less divisible and "special" to us.  They just "seem" random, when, in fact, they're anything but that!

Ask yourself, "Why don't people choose 1 or 10, when given a choice to choose any value between those numbers?"

Various theories exist on answering that question, but the one I tend to like is simply, "Told to guess between one and ten, our brains simply remove those numbers from the pool to begin with."  That leaves two through nine to be the real range of values that most people might choose from.  (Minus a very few extremes who fall onto the end of our bell curve of human psychology.)

From two to nine, most people don't want to be on the extremes, as that "just doesn't feel random", so they shoot for somewhere near the center of that range...   But, you don't want to go for the EXACT center; it's "not really random" to the human brain either -- after all, it's the exact center!  So that leaves us with 3, 4, 6, 7, 8 as a value that most people will choose from...

Of those, there's only two prime numbers, which seem "odd" to us by their unique nature, and as such, we realize that they're not "normal numbers."  An "abnormal number" HAS to be more random than a plain old "normal number".   Right??

At least, it is as far as the human mind is concerned for the vast portion of humanity!!

BUT, the problem comes that once you tell this to someone, and then you tell them to "Guess a number from one to ten", they'll react upon the information I just gave you.  Three and Seven are no longer viable numbers, as that person now things of them as "AHA!  He's going to trap me into being normal and thinking of one of those values!"  Chances are, they're now going to go to an extreme and think of "something random, outside the pattern"!

They'll choose one or ten, as I emphasized that people don't choose those values normally!!

And that's why it's so hard to get a valid set of random numbers from people...  The moment you mention it, they instantly start to think, "What's this guy doing?  How can I *BEAT* him at his process?  How do I prove I'm not an *average* bear??"

Suddenly you're not testing human behavior for guessing random numbers -- instead you're now trying to see if you can predict human behavior for people trying to beat your algorithm for prediction!

Which makes this type of project one that is incredibly hard to do, just because it's hard to actually get a valid data set to run it against.
Title: Re: Looking for old program or help recreating it
Post by: SMcNeill on December 09, 2021, 02:03:30 pm
I detect a bit of ass-hole in your last post. 

Don't worry.  I often detect a LOT of asshole when STxATxIC posts.  Feel free to tune him out completely if you want.   I certainly don't do much more than glance quickly over his crap anymore and pay very little attention to whatever he's spouting off over at the moment. 

But, I have to admit, it's nice to see I'm not the only one who feels this way, as far as he's concerned.  LOL!  ;)
Title: Re: Looking for old program or help recreating it
Post by: STxAxTIC on December 09, 2021, 02:05:54 pm
Quote
Which makes this type of project one that is incredibly hard to do, just because it's hard to actually get a valid data set to run it against.

I agree, hence why I chose these strings for testing:

Code: [Select]
string = "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000": nextdigit = "0"
'
string = "01010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101": nextdigit = "0"
string = "10101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010": nextdigit = "1"
'
string = "00100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100": nextdigit = "1"
string = "01001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001": nextdigit = "0"
string = "10010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010": nextdigit = "0"
'
string = "00010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001": nextdigit = "0"
string = "00100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010": nextdigit = "0"
string = "01000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100": nextdigit = "0"
string = "10001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000": nextdigit = "1"
'
string = "00001000010000100001000010000100001000010000100001000010000100001000010000100001000010000100001000010000100001000010000100001000": nextdigit = "0"
string = "00010000100001000010000100001000010000100001000010000100001000010000100001000010000100001000010000100001000010000100001000010000": nextdigit = "1"
string = "00100001000010000100001000010000100001000010000100001000010000100001000010000100001000010000100001000010000100001000010000100001": nextdigit = "0"
string = "01000010000100001000010000100001000010000100001000010000100001000010000100001000010000100001000010000100001000010000100001000010": nextdigit = "0"
string = "10000100001000010000100001000010000100001000010000100001000010000100001000010000100001000010000100001000010000100001000010000100": nextdigit = "0"
'
string = "00000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100": nextdigit = "0"
string = "00001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000": nextdigit = "0"
string = "00010000010000010000010000010000010000010000010000010000010000010000010000010000010000010000010000010000010000010000010000010000": nextdigit = "0"
string = "00100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000": nextdigit = "1"
string = "01000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001": nextdigit = "0"
string = "10000010000010000010000010000010000010000010000010000010000010000010000010000010000010000010000010000010000010000010000010000010": nextdigit = "0"
'
string = "00000010000001000000100000010000001000000100000010000001000000100000010000001000000100000010000001000000100000010000001000000100": nextdigit = "0"
string = "00100000010000001000000100000010000001000000100000010000001000000100000010000001000000100000010000001000000100000010000001000000": nextdigit = "1"
'
string = "00000001000000010000000100000001000000010000000100000001000000010000000100000001000000010000000100000001000000010000000100000001": nextdigit = "0"
string = "10000000100000001000000010000000100000001000000010000000100000001000000010000000100000001000000010000000100000001000000010000000": nextdigit = "1"
'
string = "00110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011": nextdigit = "0"
string = "01100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110": nextdigit = "0"
string = "11001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100": nextdigit = "1"
string = "10011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001": nextdigit = "1"
'
string = "00011100011100011100011100011100011100011100011100011100011100011100011100011100011100011100011100011100011100011100011100011100": nextdigit = "0"
string = "00111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000": nextdigit = "1"
string = "01110001110001110001110001110001110001110001110001110001110001110001110001110001110001110001110001110001110001110001110001110001": nextdigit = "1"
string = "11100011100011100011100011100011100011100011100011100011100011100011100011100011100011100011100011100011100011100011100011100011": nextdigit = "1"
string = "11000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111": nextdigit = "0"
string = "10001110001110001110001110001110001110001110001110001110001110001110001110001110001110001110001110001110001110001110001110001110": nextdigit = "0"
'
string = "01001100011101001100011101001100011101001100011101001100011101001100011101001100011101001100011101001100011101001100011101001100": nextdigit = "0"
string = "10011000111010011000111010011000111010011000111010011000111010011000111010011000111010011000111010011000111010011000111010011000": nextdigit = "1"
string = "00110001110100110001110100110001110100110001110100110001110100110001110100110001110100110001110100110001110100110001110100110001": nextdigit = "1"
string = "01100011101001100011101001100011101001100011101001100011101001100011101001100011101001100011101001100011101001100011101001100011": nextdigit = "1"
string = "11000111010011000111010011000111010011000111010011000111010011000111010011000111010011000111010011000111010011000111010011000111": nextdigit = "0"
string = "10001110100110001110100110001110100110001110100110001110100110001110100110001110100110001110100110001110100110001110100110001110": nextdigit = "1"
string = "00011101001100011101001100011101001100011101001100011101001100011101001100011101001100011101001100011101001100011101001100011101": nextdigit = "0"
'
string = "01001010101010010101010001110100101010101001010101000111010010101010100101010100011101001010101010010101010001110100101010101001": nextdigit = "0"
string = "10010101010100101010100011101001010101010010101010001110100101010101001010101000111010010101010100101010100011101001010101010010": nextdigit = "1"
string = "00101010101001010101000111010010101010100101010100011101001010101010010101010001110100101010101001010101000111010010101010100101": nextdigit = "0"
string = "01010101010010101010001110100101010101001010101000111010010101010100101010100011101001010101010010101010001110100101010101001010": nextdigit = "1"
string = "10101010100101010100011101001010101010010101010001110100101010101001010101000111010010101010100101010100011101001010101010010101": nextdigit = "0"
string = "01010101001010101000111010010101010100101010100011101001010101010010101010001110100101010101001010101000111010010101010100101010": nextdigit = "1"
string = "10101010010101010001110100101010101001010101000111010010101010100101010100011101001010101010010101010001110100101010101001010101": nextdigit = "0"
string = "01010100101010100011101001010101010010101010001110100101010101001010101000111010010101010100101010100011101001010101010010101010": nextdigit = "0"
string = "10101001010101000111010010101010100101010100011101001010101010010101010001110100101010101001010101000111010010101010100101010100": nextdigit = "0"
string = "01010010101010001110100101010101001010101000111010010101010100101010100011101001010101010010101010001110100101010101001010101000": nextdigit = "1"
string = "10100101010100011101001010101010010101010001110100101010101001010101000111010010101010100101010100011101001010101010010101010001": nextdigit = "1"

And everything else Steve just went on about only concretizes why it's critical that the algorithm being used is completely robotic, completely unbiased, completely systematic, completely uninformed by a human. (That's the reason reason my code, which I swore I wouldn't mention anymore, is so small.)
Title: Re: Looking for old program or help recreating it
Post by: STxAxTIC on December 09, 2021, 02:09:20 pm
Yup, as usual Steve wants to go all ad-hominem when he feels a certain way. Why, man? I wasn't even coming after you. Go wait for me in a calculus thread where I can pants you in the proper arena.
Title: Re: Looking for old program or help recreating it
Post by: random1 on December 09, 2021, 04:01:14 pm
STxAxTIC

Here is a challenge that will prove rather your program works or not.
I only have a hour or so each day to work on this project. 

Attached is a plain text file that contains 44 strings updated a few
minutes ago.  It should be easy for you to add the code to input
the strings directly into your program and then record and post the
predicted value for each string. 

Each line contains 500 values which should be enough.  Post your
predicted values for 1 through 44, if for some reason your predictor
cannot make a prediction for a string then just add a "*" for that value. 

This way it will make testing the predictions easier.  Each prediction
should be a 0,1 or *.  Some of the strings contain all or mostly zeros. 

Anyone else that wants to run a test can have at it.  But I need your
results before the end of the day which is when I run the next update

P.S.
I never said anything one way or the other as to rather or not your
program had any merit, here's your way to prove it.

R1
Title: Re: Looking for old program or help recreating it
Post by: cfalcon030 on December 09, 2021, 05:27:42 pm
Does this match what you are looking for

https://archive.org/details/gameeven.qb64
Title: Re: Looking for old program or help recreating it
Post by: STxAxTIC on December 09, 2021, 07:52:52 pm
Hello r1

I'm willing to play the game using the file you've provided, and I'll do you a little better: I refined my prediction calculation a little bit, so when it's not sure what to do, the answer will be a decimal between 0 and 1. If you see something like 0.25, it means I'm leaning more towards 0. A true coin-on-its-side result would be 0.5, call this your "asterisk" case.. A 0.75 means it's leaning toward 1. Because I've started to tweak and bugfix my estimator equation thingy, I'm quietly adding version numbers to this code for the time being, in case we have to refer back to something very specific.

Before I spill any beans here, another remark: I really really really think we should be starting this analysis using data that has semi-regularity to it, but not trivial regularity, for the sole - and very important - reason that we need an actual truth table to compare our predictions with. With no actual standard, it's a pissing contest in high winds. So because I'm doing this for you without an argument, I beg, I plead with you, PLEASE return the favor to me and run your algorithm on the sample data I cooked up.

Anyway, here are the predictions. Labeling the strings starting with 1 and ending with 40-something:

Code: [Select]
01: 0
02: 0
03: 0
04: .125
05: 0
06: .125
07: .875
08: 0
09: 0
10: 0
11: 0
12: .875
13: 0
14: .5
15: .125
16: 0
17: 0
18: 0
19: 0
20: 1
21: 0
22: .25
23: .125
24: .75
25: 0
26: 0
27: .125
28: .125
29: 0
30: 0
31: 1
32: .75
33: 0
34: 0
35: 0
36: .125
37: 0
38: .75
39: .125
40: 0
41: 0
42: .75
43: .125
44: 0

Full code right here, still making it pretty:
Code: QB64: [Select]
  1.  
  2. ' Version: 4
  3.  
  4. Type Letter
  5.     Signature As String
  6.     Count As Integer
  7.  
  8. Dim Shared TheInput(1000, 2) As String
  9.  
  10. Dim Shared FingerPrint(16) As String
  11.  
  12. Dim Shared Alphabet1(2) As Letter
  13. Alphabet1(1).Signature = "0"
  14. Alphabet1(2).Signature = "1"
  15. Alphabet1(1).Count = 0
  16. Alphabet1(2).Count = 0
  17.  
  18. Dim Shared Alphabet2(4) As Letter
  19. Dim Shared Alphabet3(8) As Letter
  20. Dim Shared Alphabet4(16) As Letter
  21. Dim Shared Alphabet5(32) As Letter
  22. Dim Shared Alphabet6(64) As Letter
  23. Dim Shared Alphabet7(128) As Letter
  24. Dim Shared Alphabet8(256) As Letter
  25. Dim Shared Alphabet9(512) As Letter
  26. Dim Shared Alphabet10(1024) As Letter
  27. Dim Shared Alphabet11(2048) As Letter
  28. Dim Shared Alphabet12(4096) As Letter
  29. Dim Shared Alphabet13(8192) As Letter
  30.  
  31. Call NewAlphabet(Alphabet1(), Alphabet2())
  32. Call NewAlphabet(Alphabet2(), Alphabet3())
  33. Call NewAlphabet(Alphabet3(), Alphabet4())
  34. Call NewAlphabet(Alphabet4(), Alphabet5())
  35. Call NewAlphabet(Alphabet5(), Alphabet6())
  36. Call NewAlphabet(Alphabet6(), Alphabet7())
  37. Call NewAlphabet(Alphabet7(), Alphabet8())
  38. Call NewAlphabet(Alphabet8(), Alphabet9())
  39. Call NewAlphabet(Alphabet9(), Alphabet10())
  40. Call NewAlphabet(Alphabet10(), Alphabet11())
  41. Call NewAlphabet(Alphabet11(), Alphabet12())
  42. Call NewAlphabet(Alphabet12(), Alphabet13())
  43.  
  44. Call LoadInput
  45.  
  46.  
  47. m = 1
  48.  
  49.     Cls
  50.     Call Analyze(m)
  51.     Print
  52.  
  53.     _Display
  54.     _KeyClear
  55.     Do: k = _KeyHit: Loop Until k
  56.  
  57.     Select Case k
  58.         Case 19712
  59.             m = m + 1
  60.         Case 19200
  61.             m = m - 1
  62.         Case Else
  63.             Cls: _Display
  64.     End Select
  65.     _KeyClear
  66.  
  67.     _Limit 30
  68.  
  69.  
  70. Sub LoadInput
  71.     Dim n As Integer
  72.     '''
  73.     n = 0
  74.     '''
  75.     n = n + 1: TheInput(n, 1) = "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000": TheInput(n, 2) = "0"
  76.     n = n + 1: TheInput(n, 1) = "01010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101": TheInput(n, 2) = "0"
  77.     n = n + 1: TheInput(n, 1) = "10101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010": TheInput(n, 2) = "1"
  78.     n = n + 1: TheInput(n, 1) = "00100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100": TheInput(n, 2) = "1"
  79.     n = n + 1: TheInput(n, 1) = "01001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001": TheInput(n, 2) = "0"
  80.     n = n + 1: TheInput(n, 1) = "10010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010": TheInput(n, 2) = "0"
  81.     n = n + 1: TheInput(n, 1) = "00010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001": TheInput(n, 2) = "0"
  82.     n = n + 1: TheInput(n, 1) = "00100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010": TheInput(n, 2) = "0"
  83.     n = n + 1: TheInput(n, 1) = "01000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100": TheInput(n, 2) = "0"
  84.     n = n + 1: TheInput(n, 1) = "10001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000": TheInput(n, 2) = "1"
  85.     n = n + 1: TheInput(n, 1) = "00001000010000100001000010000100001000010000100001000010000100001000010000100001000010000100001000010000100001000010000100001000": TheInput(n, 2) = "0"
  86.     n = n + 1: TheInput(n, 1) = "00010000100001000010000100001000010000100001000010000100001000010000100001000010000100001000010000100001000010000100001000010000": TheInput(n, 2) = "1"
  87.     n = n + 1: TheInput(n, 1) = "00100001000010000100001000010000100001000010000100001000010000100001000010000100001000010000100001000010000100001000010000100001": TheInput(n, 2) = "0"
  88.     n = n + 1: TheInput(n, 1) = "01000010000100001000010000100001000010000100001000010000100001000010000100001000010000100001000010000100001000010000100001000010": TheInput(n, 2) = "0"
  89.     n = n + 1: TheInput(n, 1) = "10000100001000010000100001000010000100001000010000100001000010000100001000010000100001000010000100001000010000100001000010000100": TheInput(n, 2) = "0"
  90.     n = n + 1: TheInput(n, 1) = "00000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100": TheInput(n, 2) = "0"
  91.     n = n + 1: TheInput(n, 1) = "00001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000": TheInput(n, 2) = "0"
  92.     n = n + 1: TheInput(n, 1) = "00010000010000010000010000010000010000010000010000010000010000010000010000010000010000010000010000010000010000010000010000010000": TheInput(n, 2) = "0"
  93.     n = n + 1: TheInput(n, 1) = "00100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000": TheInput(n, 2) = "1"
  94.     n = n + 1: TheInput(n, 1) = "01000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001": TheInput(n, 2) = "0"
  95.     n = n + 1: TheInput(n, 1) = "10000010000010000010000010000010000010000010000010000010000010000010000010000010000010000010000010000010000010000010000010000010": TheInput(n, 2) = "0"
  96.     n = n + 1: TheInput(n, 1) = "00000010000001000000100000010000001000000100000010000001000000100000010000001000000100000010000001000000100000010000001000000100": TheInput(n, 2) = "0"
  97.     n = n + 1: TheInput(n, 1) = "00100000010000001000000100000010000001000000100000010000001000000100000010000001000000100000010000001000000100000010000001000000": TheInput(n, 2) = "1"
  98.     n = n + 1: TheInput(n, 1) = "00000001000000010000000100000001000000010000000100000001000000010000000100000001000000010000000100000001000000010000000100000001": TheInput(n, 2) = "0"
  99.     n = n + 1: TheInput(n, 1) = "10000000100000001000000010000000100000001000000010000000100000001000000010000000100000001000000010000000100000001000000010000000": TheInput(n, 2) = "1"
  100.     n = n + 1: TheInput(n, 1) = "00110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011": TheInput(n, 2) = "0"
  101.     n = n + 1: TheInput(n, 1) = "01100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110": TheInput(n, 2) = "0"
  102.     n = n + 1: TheInput(n, 1) = "11001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100": TheInput(n, 2) = "1"
  103.     n = n + 1: TheInput(n, 1) = "10011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001": TheInput(n, 2) = "1"
  104.     n = n + 1: TheInput(n, 1) = "00011100011100011100011100011100011100011100011100011100011100011100011100011100011100011100011100011100011100011100011100011100": TheInput(n, 2) = "0"
  105.     n = n + 1: TheInput(n, 1) = "00111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000": TheInput(n, 2) = "1"
  106.     n = n + 1: TheInput(n, 1) = "01110001110001110001110001110001110001110001110001110001110001110001110001110001110001110001110001110001110001110001110001110001": TheInput(n, 2) = "1"
  107.     n = n + 1: TheInput(n, 1) = "11100011100011100011100011100011100011100011100011100011100011100011100011100011100011100011100011100011100011100011100011100011": TheInput(n, 2) = "1"
  108.     n = n + 1: TheInput(n, 1) = "11000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111": TheInput(n, 2) = "0"
  109.     n = n + 1: TheInput(n, 1) = "10001110001110001110001110001110001110001110001110001110001110001110001110001110001110001110001110001110001110001110001110001110": TheInput(n, 2) = "0"
  110.     n = n + 1: TheInput(n, 1) = "01001100011101001100011101001100011101001100011101001100011101001100011101001100011101001100011101001100011101001100011101001100": TheInput(n, 2) = "0"
  111.     n = n + 1: TheInput(n, 1) = "10011000111010011000111010011000111010011000111010011000111010011000111010011000111010011000111010011000111010011000111010011000": TheInput(n, 2) = "1"
  112.     n = n + 1: TheInput(n, 1) = "00110001110100110001110100110001110100110001110100110001110100110001110100110001110100110001110100110001110100110001110100110001": TheInput(n, 2) = "1"
  113.     n = n + 1: TheInput(n, 1) = "01100011101001100011101001100011101001100011101001100011101001100011101001100011101001100011101001100011101001100011101001100011": TheInput(n, 2) = "1"
  114.     n = n + 1: TheInput(n, 1) = "11000111010011000111010011000111010011000111010011000111010011000111010011000111010011000111010011000111010011000111010011000111": TheInput(n, 2) = "0"
  115.     n = n + 1: TheInput(n, 1) = "10001110100110001110100110001110100110001110100110001110100110001110100110001110100110001110100110001110100110001110100110001110": TheInput(n, 2) = "1"
  116.     n = n + 1: TheInput(n, 1) = "00011101001100011101001100011101001100011101001100011101001100011101001100011101001100011101001100011101001100011101001100011101": TheInput(n, 2) = "0"
  117.     n = n + 1: TheInput(n, 1) = "01001010101010010101010001110100101010101001010101000111010010101010100101010100011101001010101010010101010001110100101010101001": TheInput(n, 2) = "0"
  118.     n = n + 1: TheInput(n, 1) = "10010101010100101010100011101001010101010010101010001110100101010101001010101000111010010101010100101010100011101001010101010010": TheInput(n, 2) = "1"
  119.     n = n + 1: TheInput(n, 1) = "00101010101001010101000111010010101010100101010100011101001010101010010101010001110100101010101001010101000111010010101010100101": TheInput(n, 2) = "0"
  120.     n = n + 1: TheInput(n, 1) = "01010101010010101010001110100101010101001010101000111010010101010100101010100011101001010101010010101010001110100101010101001010": TheInput(n, 2) = "1"
  121.     n = n + 1: TheInput(n, 1) = "10101010100101010100011101001010101010010101010001110100101010101001010101000111010010101010100101010100011101001010101010010101": TheInput(n, 2) = "0"
  122.     n = n + 1: TheInput(n, 1) = "01010101001010101000111010010101010100101010100011101001010101010010101010001110100101010101001010101000111010010101010100101010": TheInput(n, 2) = "1"
  123.     n = n + 1: TheInput(n, 1) = "10101010010101010001110100101010101001010101000111010010101010100101010100011101001010101010010101010001110100101010101001010101": TheInput(n, 2) = "0"
  124.     n = n + 1: TheInput(n, 1) = "01010100101010100011101001010101010010101010001110100101010101001010101000111010010101010100101010100011101001010101010010101010": TheInput(n, 2) = "0"
  125.     n = n + 1: TheInput(n, 1) = "10101001010101000111010010101010100101010100011101001010101010010101010001110100101010101001010101000111010010101010100101010100": TheInput(n, 2) = "0"
  126.     n = n + 1: TheInput(n, 1) = "01010010101010001110100101010101001010101000111010010101010100101010100011101001010101010010101010001110100101010101001010101000": TheInput(n, 2) = "1"
  127.     n = n + 1: TheInput(n, 1) = "10100101010100011101001010101010010101010001110100101010101001010101000111010010101010100101010100011101001010101010010101010001": TheInput(n, 2) = "1"
  128.     n = n + 1: TheInput(n, 1) = "10100101010100011101001010101010010101010001110100101010101001010101000111010010101010100101010100011101001010101010010101010001": TheInput(n, 2) = "?"
  129.     n = n + 1: TheInput(n, 1) = "0001000001011100000011000100011000010010000000000000000011000000000000000001110010000000000001111000000001001110000000000000100000000011110000000000000000000000000000010100000000000000000100000000000000110001111000010001000000000000000000011010000000000000000010001101100000100001000000110011000011010010000000000000000000100001000011000110001010000000100000000000000000000000000000000000010000000000100000000000000010100000100000000000000000000000000000000000100001000000000000000010110100000000000010010000000000000000000100000000001100000011000000000000000000000000000000110010000110000100000": TheInput(n, 2) = "?"
  130.     '''
  131.     'n = 0
  132.     '''
  133.     n = n + 1: TheInput(n, 1) = "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000": TheInput(n, 2) = "?"
  134.     n = n + 1: TheInput(n, 1) = "00000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000": TheInput(n, 2) = "?"
  135.     n = n + 1: TheInput(n, 1) = "00000100000101110000001100010001100001001000000000000000001100000000000000000111001000000000000111100000000100111000000000000010000000001111000000000000000000000000000001010000000000000000010000000000000011000111100001000100000000000000000001101000000000000000001000110110000010000100000011001100001101001000000000000000000010000100001100011000101000000010000000000000000000000000000000000001000000000010000000000000001010000010000000000000000000000000000000000010000100000000000000001011010000000000": TheInput(n, 2) = "?"
  136.     n = n + 1: TheInput(n, 1) = "00011101100000000001011100001011101000100111101100011000000011001010101000101000111111011000111000100000000000000110110000000001001001110110100001011011101100000011001010001111111110101100001101100001100011000111101100110000000101101101110000001110110111000011000110000000001101111000110000000011111100110001111000011101111101010011111111101111010011011001111101100010001100101101001011000010100111111101111010111111010110001100011000000100010001100111111001101101111000000010110111110000001011010011": TheInput(n, 2) = "?"
  137.     n = n + 1: TheInput(n, 1) = "00000000100000000000110000000000000000010000000000000000010000000000000000001000000000000000000000000000000001000000010000000000000000000000000000000000000000000000000000011000000000000000001000000001000000000000000000000000000000000000000001001011001000000000000110000000000000000000000000000000000100010000000000000000000000000000000000001100000000000000000000000000000000100000000000000000001000000000000000000000000000000000000000000000100000000000000000100000000000000000000000000000000000000000": TheInput(n, 2) = "?"
  138.     n = n + 1: TheInput(n, 1) = "01111011010110000100001000011001101101000011000011000000000100110010001010000100010000001110111000001000000000101110101100000000100011100101101110000010110101111001011010100000111011100110100001100100111010111110000010000110010000000100111100110000000101010100111001000000101000100101111001001001000010000100110011011010011011101000110011000000101000000100010000101101000101000110000100010101010111100000000001100000110010000001000011100001001000100000011100000101000001010101000100011010000100010011": TheInput(n, 2) = "?"
  139.     n = n + 1: TheInput(n, 1) = "11000110011000111000001101000010001000001110001001110010000110000111010001010001100010101100001111100000111100101100000011000111101101110010101101010000101010000001111100000111110101010000000011011100100110101100111101000000100100101000011010000000010110101010011001110011111000010001100110001111111001100010011100010101001100000101010101100000000001001010000011011100010011001000001001110111100110010010000010000111111101100011010101010101000111010110101000000010001001001011011011100101111110110010": TheInput(n, 2) = "?"
  140.     n = n + 1: TheInput(n, 1) = "10101101010001010110010110011111011111111101110100010011101110000000100011010000100111111001110110100011011110011101110001110011110000111011011110111011101100000010100111100010000010100111110010100100010001010101111000111010011101010111001110110000101101110001110010011101010110101110001111000101011001001101001011111101110010110101001100110010111101010111010010000010110100010001101110110101101110000101101010001001101101011000111110100000011101110010101111011110111110100110101001111101110001010110": TheInput(n, 2) = "?"
  141.     n = n + 1: TheInput(n, 1) = "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000": TheInput(n, 2) = "?"
  142.     n = n + 1: TheInput(n, 1) = "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000001000000000000000000000000000100000000000000000000000000000000000000000000000100000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000": TheInput(n, 2) = "?"
  143.     n = n + 1: TheInput(n, 1) = "00000110110101110000001100100101000001001111101111100000011000000000001001000100011000000000100011100000100000001001000001000010000000010111001101000001100000010101100011010011111000100111010000000000001010001011101110010100000000000010001011101000010000100000101100110100000011111000000001110000010101010000111111110000000110000100111110011000100000010001010100000000000110000000011000100000000111110011110010000100001010000010011100000000010001101010000000000110010000000110000000110011000000000000": TheInput(n, 2) = "?"
  144.     n = n + 1: TheInput(n, 1) = "11011001010011000110101011011010000110001001010001001111100111001011110110111010001111010110010100100101011010110010010100111010111001101011100100001010011111111010011100101101000011011011000111011011010110111100110011100010100001101010110101110101110111010111010010011001110100011010011010101111101110100100100111101101001011100001001100100111010101100100101000111111111001001111100111010110111100001000000111101000111000001101011001001110001000010100110011111001001010101001110111010101111001100001": TheInput(n, 2) = "?"
  145.     n = n + 1: TheInput(n, 1) = "00000000000000000000010000000001100000000000000000000001010000000000110010000000000000000000000000000000000000000000000000001100000000000111000101000000000000000000000000000100010001000000000000000000000000000000001100010010000000000000000001100000000000000000000000000001000000000000000000000000000000000010000011000000000000010000000000000001000000001000000000000000000000000000000000000100100000000000100000000000000000000000000000000000100000000000000000000000000000000000000000100000000000000000": TheInput(n, 2) = "?"
  146.     n = n + 1: TheInput(n, 1) = "11101000011011010000101000100000010001001000000110011110001011010001001101101010001100111000000101001000011000001010010100010011100110101000101000000000010100111001010100010010101010100011000011000001011010000000010000000001011110110111000010000001011011100000000111001110100000110000000011000101100000001001000100110011000100100000100001001000000011010010100000000100100000101001100000110001001001110101010001000000011000000010101000110010000100001011000001101000101010011011001110010110000010000000": TheInput(n, 2) = "?"
  147.     n = n + 1: TheInput(n, 1) = "00000010100110101001001000100000010100100100101101010010000001001100000000001011001110011011000010000111111001100010110011000010100110110000000000011010011010010100100011011011001100110001101001110000101001001100100010001101001000001011111100011011100000011001001010111000000000111101111001111001111111101000000000101100011001001011011010010000100001100010011110010000001011000001010111010010011111001001001110111100110010000110100111101000000101110100101010001111001111101100010101001001010101000101": TheInput(n, 2) = "?"
  148.     n = n + 1: TheInput(n, 1) = "00111100000000000111001001100000111010010010010011100010001100001100000011011000100010000101110010110100110110011100010001111110011011000110010000001001101111111000011000010001101110011101111010100110100110000111011101001111110011011111100110111000001101101110001001001000011110100110000111110111010000001100100100100111110110100001001011100110111000100011110100100100110010011110011011100011101111010010000110000011101100000111001011000110000010001101111011111011001100000010000101000000000000101110": TheInput(n, 2) = "?"
  149.     n = n + 1: TheInput(n, 1) = "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000": TheInput(n, 2) = "?"
  150.     n = n + 1: TheInput(n, 1) = "00000000000000000000000000000000000000000100000000000000000000000010000000000000001000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000": TheInput(n, 2) = "?"
  151.     n = n + 1: TheInput(n, 1) = "00000000010111101100110000001011000001001011001100000001001100001001000001001100010000111111000011100001000000001111010010000100001000000010001101001011101011011010000101010011110110110001100001000010000010100011000000110001000000011101110001000000000000110000100000101100000001011010000101000000100100011000111111110010110101010100011110100110110000010001101000000000101001000010100110000100010100111000010010100100001000110000000100010100010000000010000100011100010010110100010000010010001001000010": TheInput(n, 2) = "?"
  152.     n = n + 1: TheInput(n, 1) = "11111111011001010010001100000100110110101110100011010010111011110100101000100000000101100000000100110010111110111000110101101010111111011101101010011111100100110100010011011001100000001110111110000101000000001100110101011110011111101100001110011101111100111100011100010010110111100001010000010001101001001111000000000101001000100100000110011000101011100100000100111011010110100000010001011010101011010010100111011000100011001000001010001011101010000100001011001011100001001011101110100110110010111100": TheInput(n, 2) = "?"
  153.     n = n + 1: TheInput(n, 1) = "00000000000000000000000000010000000000000000000000000000000100000000100000000000000000000011100000000000000000000000000001000000000000000000000000000011001000000000000100000000000000000000000000010010000000000000000000000000000000000000000000000000000000000000000000000000000010001000000000000000000000000000000000000010000000000000000000000010000000000000000000000000000000000000000000000001001000000000011100000000000000001000000000000000000100000000100010000110100000000000000000000000000000000000": TheInput(n, 2) = "?"
  154.     n = n + 1: TheInput(n, 1) = "01011000100010001000011010000010010010000100100101000100011001000010000010110110010110001100010001000010110110000011010100000100100010010011111101111100110010101100000001000000100111010000010000100000000111100110000101110001100100000001000001001100100100010000001001000110000000000100011100110110000101100011100010110100000011001001011000010001001000101010010010000001000000100101100101001110110010010000100010100010000000100111001100000000001000111111010100001000001010000010101010110101101000001100": TheInput(n, 2) = "?"
  155.     n = n + 1: TheInput(n, 1) = "00000101000010010110000110001101111110010001110010000010101001111111010000011011100000110000010101101110101111110101001100000100000000100110001000000000000001110011101011011110000001000110101001000000000000010100010010110110000010001100100010011001010011111011001110110000110100010010000010010110011000010110110010101000111000000100000001101100100110010100110111001110110101010001101100000000110010100010000001000101011100000000000111101110101011001011001100100000001101110000001001101010000000111011": TheInput(n, 2) = "?"
  156.     n = n + 1: TheInput(n, 1) = "10100010000111100111110001101101100001100111001010011110011001101110100111000111001010100111100010110010101010100100100000101010111100100000010111001000101110010010111000001100011011001011010100101101101110001001111100110000001011100000010110011010001000001101101111001000011101001000110010110111100011111011001100011110100110100111001110000101010001010001101001101001011001111010011001101010000001111010110011100001010100011100110100011011110011100101000001110010010111100111110011001110011111001010": TheInput(n, 2) = "?"
  157.     n = n + 1: TheInput(n, 1) = "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000": TheInput(n, 2) = "?"
  158.     n = n + 1: TheInput(n, 1) = "00000000000000000000000000000000000000000100000000000001100000000000000000000000000000000000000000010000000000000000000000000000000001000000000000000000000000000000000001000000000000100000000000000000000000000000000000000000000000001100000000000000000000000000000000000000000000000000000000000000000000000000110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000": TheInput(n, 2) = "?"
  159.     n = n + 1: TheInput(n, 1) = "00100000011101101100000000000000000000001010001010001010010000000011101000010100001000000110000110100000000010001000111100100100001010110000011000001010110100110011000010001000110101001001100001011000001000000000000010110000100000110000001001000000100000110100100100100001010011000000010101010010100101000000001011100010000000001100000110100010100010000001110000000100000001110010100100001110000001100110000100001000001000000000010000001000001000000001001100000000010011110100000000001010100001111111": TheInput(n, 2) = "?"
  160.     n = n + 1: TheInput(n, 1) = "01010110100011101001111011101011111111101001100000010100001001111110010111100011101100011111110001101101111000110011010011010011110000101111110110010001000001010100100100110011010010010110101011100000111111111101111110110011111101010011110000111101000010010011010000011100001000011011000011001101100011011101000101010101111011000100001111010100111001011100011100011011011000000010011010010100110010011001111011010010110011111000101110010111111100100100111110111010101001101011010100000001011010010000": TheInput(n, 2) = "?"
  161.     n = n + 1: TheInput(n, 1) = "00000000000000000000000000000000000000000000000000000000000000000000000000000100000001000000000000000000000000000000000000000001000000000000000000000000000000000000000010000000000000010010100000000000001000000000001000100000000000000000000001000000000000000000000000000000010000000010000000000000000000000001000000010000000000000000000000000000000000000000010000000110000000000000000000000001000000000010000100000000000000000100000001000000010000000000000000000000010000000000000000001000000000000000": TheInput(n, 2) = "?"
  162.     n = n + 1: TheInput(n, 1) = "00000001100010111010101010001001000011001100000000000000010011000111001101001010110010010010010100101010000001001000111000000010110000010001001110100000000101101001110100010100000101000100000101000000010000110000010011010000100101001111000000011110001000001101101100000001000101000000011001011001110111100010010001000011110011110010010001000001110100100010101001110000010100000010010100000000101001000100101000011000000001001010111010110100000011001100101010000000100100100111111001110101000100000001": TheInput(n, 2) = "?"
  163.     n = n + 1: TheInput(n, 1) = "11010010010101000010000011010000101110111010011001101000101111011101001110000001011110100101101111000100000010110001010101000110100001100000111000111100011110110011101101101111101010100100011101000000010010101110000011011100010010101110101010000001110001001111110011011101000010110000101111000000101100011100101100001001100001111110000101110000010010000001001010000000011011000001000101000100000111101100110011000111010000001000010000000000100101010001100001011000001010001000111111110110101000011111": TheInput(n, 2) = "?"
  164.     n = n + 1: TheInput(n, 1) = "11011111000111100000010011111111101111001100100010111010010000011000110100111010011000111101000111010000110110101010011010101011100110011101000001011011111110011100110100001001010000001000010010100101111011000101001000000011110011110001100100100011011001010000101101111110101011011100000111000111000011110101111011101000101010000111011110000111111101011101110110001000011000111011011011111100110000001011011010110101101111011001011000111100101100111010011100110111101100110110100110000010011111110101": TheInput(n, 2) = "?"
  165.     n = n + 1: TheInput(n, 1) = "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000": TheInput(n, 2) = "?"
  166.     n = n + 1: TheInput(n, 1) = "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000": TheInput(n, 2) = "?"
  167.     n = n + 1: TheInput(n, 1) = "00100000000000000011000000000000000000000110000010011111100000000000000001000000001000000000000000010110000110000001100010000000000011110000000001100000000000110011000011000000010000001110000000011000001000010000110100000010000000111101000000000000000000100000000001100000100011000000000100000000000101000000000011010000001100010100000110110010100001010000110000001000000001100000110000001100000000011010000000000000101001100000000000000000100000011010100000000010010000100100010000000000000001111000": TheInput(n, 2) = "?"
  168.     n = n + 1: TheInput(n, 1) = "00010100011101010101100000101000001100111001101101000000011001111001100110110111010111111011110001100000000001100000011001111000111001000110011010001110100110011001110111100000101000110001100110100111000111001000001001110101101110000000110000000000011001010101000110011101011001100011001001011001101100011110000101101001100011001010011000001100110000101000001111110110000000001100001100010010101111100101001101010000000110011011111100011111010000000101000000100101100111010110001101111010101010000110": TheInput(n, 2) = "?"
  169.     n = n + 1: TheInput(n, 1) = "00000010000000000001100000000000000001000000000000000000000000000000000000000000000001001000000000000000000100000000000000000000010000000000000000100100000101000001000000100001100000000000000000000000000010110000000000000000100001000000000000001000000001100010000000010000010000000000000110000000001000000000001000010000000000010000000000000000000000000000000000000100001000000000000100001000000000000000000100000000000100000000000000000000000001001000000000000000000001000010000000000010000011000000": TheInput(n, 2) = "?"
  170.     n = n + 1: TheInput(n, 1) = "11010000111110000000000011000001011000010011010100100000000000110011011101010010100100000000000000010001101001000001001010011000100101101000111011000001000010010000010000010100001000100110100001100100001001001001100011110010011000110111000011000000011000000000100110001000101101100000001000000000000100000000000001001110001110100000010100001011101010110100001001001000000010010100001010100111011111000100001010000011010001000011001101110001101110000011010101101001010100110100010001011100110100110111": TheInput(n, 2) = "?"
  171.     n = n + 1: TheInput(n, 1) = "00000000110110001000000011001000100000001110011010100010101101111100101100101000001010000000101101010100101011010000010001001110001001100001110101011010111010000100001011001010010100011001011000010000100001000000000100001111001000101011111110100001110010011000100001101000101001101011110001011111000110111010010101000001001011101101110000001011110000011001100011111001010100010101110011000100110000101101010010110000000000010011001001101101000010000010001110000011111100111101100100110000001000110000": TheInput(n, 2) = "?"
  172.     n = n + 1: TheInput(n, 1) = "00101101111001100011001000011101001000000001100000101001000010110101000011001101110010110011000010101100111010101111100101100111000010110111010100000000001010000111111011001000111011100100011111101010010101011111111010010110010001101010100101010110111010111000101111001101001101101111010101010010110001000110110110101000010100001000010011101010011110001000001111001100110001011010100011101011100000100000111001000111001010101111010010010100110111001000100011010110100011111011101001101010111101101010": TheInput(n, 2) = "?"
  173.     n = n + 1: TheInput(n, 1) = "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000": TheInput(n, 2) = "?"
  174.     n = n + 1: TheInput(n, 1) = "10000000100000000000000001001001000000100011010001010100000100000000010101100110101000000000000100000101010000000101000000000101100000000000010000001000001011000110100110100010010100010111000100000100001010000000101010001000111001000000010000100100000000000000100000001001000000110001010001001010010000000010101001000111011000100100100000010010000100100000000000001000010010000110010110000110100000000000101001010100000110010001110000111000000110000000000000000000000100101100001010000100000101100010": TheInput(n, 2) = "?"
  175.     n = n + 1: TheInput(n, 1) = "00001101011011101101111110010000011011010000101110101011001001111000101010010001010111100001110011011010100011011010101010111010001010100110101100000110110100101001011001010000001010100000111010111011100100110111010101010100000010000010101110001011010011001111011110110000110010001010001000110100101111101100000110111000000000000010001111101001011011010111110110000100101000111000101001110001010011110100010100100011110000001100001011000100100000011110111111100011000011000011100101111010111010010101": TheInput(n, 2) = "?"
  176.     n = n + 1: TheInput(n, 1) = "01110011000100111110101110110110101110011100101000000011111010011111101010001000000000111110011010111010001110111000111111010010011101111101100111110001000000011000001000001101101001001000010001011000010001111100010001100111000100111111100011010001101101110110000001010110001111000100101110010001101101010001010110110000100111011001010100101101110000001111001111110111100101101001001001111001011111111011000010101001001001101010001111000011011001111111001011111101111001010010110000100001010000011000": TheInput(n, 2) = "?"
  177.     '''
  178.  
  179.  
  180.  
  181. Sub Analyze (TheIndex As Integer)
  182.     Dim actual As String
  183.     Dim k As Integer
  184.     Dim As Double p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13
  185.  
  186.     FingerPrint(1) = TheInput(TheIndex, 1)
  187.     actual = TheInput(TheIndex, 2)
  188.  
  189.     For k = 2 To UBound(FingerPrint)
  190.         FingerPrint(k) = Right$(FingerPrint(k - 1), Len(FingerPrint(k - 1)) - 1) + Left$(FingerPrint(k - 1), 1)
  191.     Next
  192.  
  193.     Call CreateHisto(Alphabet2(), 2)
  194.     Call CreateHisto(Alphabet3(), 3)
  195.     Call CreateHisto(Alphabet4(), 4)
  196.     Call CreateHisto(Alphabet5(), 5)
  197.     Call CreateHisto(Alphabet6(), 6)
  198.     Call CreateHisto(Alphabet7(), 7)
  199.     Call CreateHisto(Alphabet8(), 8)
  200.     Call CreateHisto(Alphabet9(), 9)
  201.     Call CreateHisto(Alphabet10(), 10)
  202.     Call CreateHisto(Alphabet11(), 11)
  203.     Call CreateHisto(Alphabet12(), 12)
  204.     Call CreateHisto(Alphabet13(), 13)
  205.  
  206.     Call PrintHisto(Alphabet2(), 0)
  207.     Call PrintHisto(Alphabet3(), 0)
  208.     Call PrintHisto(Alphabet4(), 0)
  209.     Call PrintHisto(Alphabet5(), 0)
  210.     Call PrintHisto(Alphabet6(), 0)
  211.     Call PrintHisto(Alphabet7(), 0)
  212.     Call PrintHisto(Alphabet8(), 0)
  213.     Call PrintHisto(Alphabet9(), 0)
  214.     Call PrintHisto(Alphabet10(), 0)
  215.     Call PrintHisto(Alphabet11(), 0)
  216.     Call PrintHisto(Alphabet12(), 0)
  217.     Call PrintHisto(Alphabet13(), 0)
  218.  
  219.     p2 = MakeGuess(Alphabet2(), 2)
  220.     p3 = MakeGuess(Alphabet3(), 3)
  221.     p4 = MakeGuess(Alphabet4(), 4)
  222.     p5 = MakeGuess(Alphabet5(), 5)
  223.     p6 = MakeGuess(Alphabet6(), 6)
  224.     p7 = MakeGuess(Alphabet7(), 7)
  225.     p8 = MakeGuess(Alphabet8(), 8)
  226.     p9 = MakeGuess(Alphabet9(), 9)
  227.     p10 = MakeGuess(Alphabet10(), 10)
  228.     p11 = MakeGuess(Alphabet11(), 11)
  229.     p12 = MakeGuess(Alphabet12(), 12)
  230.     p13 = MakeGuess(Alphabet13(), 13)
  231.  
  232.     Print
  233.     Print "String ID:"; TheIndex
  234.     Print FingerPrint(1)
  235.     Print
  236.     Print "Thinking:  "; p2; p3; p4; p5; p6; p7; p8; p9; p10; p11; p12; p13
  237.     Print
  238.     Print "Prediction:"; (1 / 4) * (p10 + p11 + p12 + p13)
  239.     Print "Actual:     "; actual
  240.  
  241. Function MakeGuess (arr() As Letter, w As Integer)
  242.     Dim TheReturn As Double
  243.     Dim As Integer k
  244.     For k = 1 To UBound(arr)
  245.         If (Left$(arr(k).Signature, w - 1) = Right$(FingerPrint(1), w - 1)) Then
  246.             Print "..."; arr(k).Signature; arr(k).Count
  247.             TheReturn = Val(Right$(arr(k).Signature, 1))
  248.             If (arr(k).Count = 0) Then TheReturn = .5
  249.             Exit For
  250.         End If
  251.     Next
  252.     MakeGuess = TheReturn
  253.  
  254. Sub CreateHisto (arr() As Letter, w As Integer)
  255.     Dim As Integer m, n, k
  256.     For n = 1 To UBound(arr)
  257.         arr(n).Count = 0
  258.     Next
  259.     For m = 1 To w
  260.         For n = 1 To Len(FingerPrint(m)) - w Step w 'added the -w
  261.             For k = 1 To UBound(arr)
  262.                 If (Mid$(FingerPrint(m), n, w) = arr(k).Signature) Then
  263.                     arr(k).Count = arr(k).Count + 1
  264.                 End If
  265.             Next
  266.         Next
  267.     Next
  268.     Call BubbleSort(arr())
  269.  
  270. Sub NewAlphabet (arrold() As Letter, arrnew() As Letter)
  271.     Dim As Integer n, j, k
  272.     n = 0
  273.     For j = 1 To 2
  274.         For k = 1 To UBound(arrold)
  275.             n = n + 1
  276.             arrnew(n).Signature = arrold(k).Signature
  277.         Next
  278.     Next
  279.     For k = 1 To UBound(arrnew)
  280.         If (k <= UBound(arrnew) / 2) Then
  281.             arrnew(k).Signature = "0" + arrnew(k).Signature
  282.         Else
  283.             arrnew(k).Signature = "1" + arrnew(k).Signature
  284.         End If
  285.     Next
  286.  
  287. Sub PrintHisto (arr() As Letter, w As Integer)
  288.     Dim As Integer n
  289.     If (w > 0) Then
  290.         For n = 1 To w
  291.             Print arr(n).Signature; arr(n).Count
  292.         Next
  293.     End If
  294.  
  295. Sub BubbleSort (arr() As Letter)
  296.     Dim As Integer i, j
  297.     Dim As Integer u, v
  298.     For j = UBound(arr) To 1 Step -1
  299.         For i = 2 To UBound(arr)
  300.             u = arr(i - 1).Count
  301.             v = arr(i).Count
  302.             If (u < v) Then
  303.                 Swap arr(i - 1), arr(i)
  304.             End If
  305.         Next
  306.     Next
Title: Re: Looking for old program or help recreating it
Post by: STxAxTIC on December 09, 2021, 08:39:55 pm
While this reply is still fresh I want to break down a case that my algo did the absolute worst on, and even this is corrected for in the next stroke of precision, so to speak. The screenshot below has everything. Look how ugly and "random" (everyone contain yourselves, i'm using the word colloquially) that string is! My code will eventually decide the answer is 0, but after a long time thinking it was 1. Too much time in this case, leading to a 50/50 result. Oh, I know the "actual" answer to be 0 because there IS a pattern in this string, just a really long one. This is the only uncertain case among the 50-something cases I cooked up originally.

  [ This attachment cannot be displayed inline in 'Print Page' view ]  
Title: Re: Looking for old program or help recreating it
Post by: random1 on December 10, 2021, 12:08:05 am
Results

Hit 34 of 44 for a hit rate of 77%, all values rounded < .5 = 0, >=.5 = 1

Values to the right are the actual values that showed.   

(+) equals a match, (x) = miss
 
01: 0         0 +
02: 0         0 +
03: 0         0 +
04: .125    0 +
05: 0         0 +
06: .125    0 +
07: .875    0 x
08: 0         1 x
09: 0        0 +
10: 0        0 +
11: 0        0 +
12: .875   0 x
13: 0        0 +
14: .5       0 x
15: .125   0 +
16: 0       0 +
17: 0       0 +
18: 0       0 +
19: 0       0 +
20: 1       1 +
21: 0       0 +
22: .25    0 +
23: .125   0 +
24: .75     1 +
25: 0        0 +
26: 0        0 +
27: .125   0 +
28: .125   1 x
29: 0        0 +
30: 0        0 +
31: 1        0 x
32: .75     0 x
33: 0        0 +
34: 0        0 +
35: 0        0 +
36: .125   1 x
37: 0        0 +
38: .75     1 +
39: .125   0 +
40: 0       0 +
41: 0       0 +
42: .75    0 x
43: .125   1 x
44: 0       0 +

R1
Title: Re: Looking for old program or help recreating it
Post by: random1 on December 10, 2021, 12:21:13 am
Once I have my predictor back up and running I will test it against the strings you provided.
As I stated, I removed the predictor code and for testing other parts of the program I have
inserted a PRNG  with a range of 0 to 2.  0&1+2 for wildcard.  This allows me to make sure all
other code functions properly.  I still think it's going to take more than one method and maybe
several to get the job done although the results were impressive for being straight out of the box
playing against actual data.  The strings I provided range from easy to very difficult.  I selected
them to get a better idea how well your predictor works overall.   

R1
Title: Re: Looking for old program or help recreating it
Post by: STxAxTIC on December 10, 2021, 12:55:31 am
On what basis are you assigning me these marks? Are you saying your sequences are deterministic? Or are you saying you just concealed the final digit from your data and then just brought it back in to grade my program? If you did the second thing, that's an extreme fallacy and you can just toss those results no matter how good they look. I kid... kinda... still deciding if that was a dirty move or not but I'll take a 77 anyway. :-)
Title: Re: Looking for old program or help recreating it
Post by: random1 on December 10, 2021, 03:33:11 pm
STxAxTIC
Please read this entire post.

I don't think your reading my post very carefully and just took the prediction idea and ran
with it.  Yes, your first attempt done very well IMHO, however I need to run hundreds of
test using other real data.

Nothing underhanded going on here, I run my programs updater each day which updates
the strings. If the event happened then a 1 is added to the string, if the event did not
happen then a 0 is added.  A type of web-crawler gathers the information, simple as that.

What benefit could I possibly gain by trying to trick you somehow, I want this to work?  I
don't expect to achieve perfect predictions.   My goal is to find which strings out of the 800+
that I use are the most predictable overall. 

The predictor is a small part of a much larger program, over 25K lines as it now stands. The
predictor / forecaster contains several stages which includes formatting the data that's fed to
the actual predictor and another stage that takes the predictors output and turns it into real
world data.  I tried to code it in a manner that allows me to paste prediction code directly into
the program without making any other changes.  This allows for fast turn around time and
also allows me to evaluate the many predictor codes I have came up with over the years.  My
code even allows stacking predictors as a means to compare them against each other or allow
several predictors outputs to be combined for the final prediction.   

The program gathers the information, does all the data processing / formatting and builds the
data strings formatted and ready for the predictor.  The input string variable is named Dat1$. 
Once the predictor is finished processing it prints the predicted value to a string named PV1$,
ie, predicted value.
     
If you want to make it easier for me to test your code then keep these in mind.  The program feeds
the predictor one string at a time, processes the prediction, then adds that value to an array before
moving to the next string where it repeats the process.  Once all the strings have been processed the
program then enters the final stage where the predictions are converted to real world data.

All I need is a program that will try to predict the next value for the string being processed, everything
else is complete.  Input = Dat1$, Output to PV1$.   String data flow is right to left.

I removed my predictor code and replaced it with a simple PRNG that generates a value from
0 to 2.  This was done as a means to test the pre and post processing stages of my code and
provide me a simple easy way to add code posted by others .  A output range of 0 to 2 is used
to produce a 0,1 or 2.  2=the wildcard option, or 50/50, the coin landing on it's side so to say.   

The average PRNG run is around 32% correct, "wildcards removed" from the calculation so the
77% is nothing to scoff at.  I consider it scored very well.  This however is based on a single
event, who knows if may of just been a bad day.

My main program will in the final stages kick out certain predictions based on it's overall past 
performance.  The program only needs 20 to 25 trusted predictions out of the 800+ that it
processes to give me what I need.

Anyway, hope this gives you a better understanding of what I am doing.  Again, 77% is a high
enough score to put this in the keeper box, but it also needs more real world testing to get a
better understanding of how it fairs overall.  It may prove better than a 77% hit rate as it was
only given 44 strings to process.  I spend much more time testing than coding.
 
R1

Edit

The PRNG baseline it taken from the real world, ie, final result where the 77% is gotten from
the string hit rate.  The PRNG taken at the string process averages form 46 to 52%.  On the
other hand the 77% translates to 60% real world, still much higher that the PRNG's 27 to 32%

Just wanted to clear that up.
R1

 
Title: Re: Looking for old program or help recreating it
Post by: STxAxTIC on December 12, 2021, 02:55:34 am
Hey R1,

I read ya carefully m8, you've got a big project on your hands. As soon as your predictor part is working how you like it, we can resume the nitty-gritty. As for my code, I made some effort to make it better in case you are still wanting to use it for testing. Noticeable changes are better layering, more systematic and varied test cases, and overall bugfixes. I also am experimenting with how the guess is calculated. These experiments are subject to tweaking or outright removal.

The code below has over a hundred total test cases, but we start at case 79, skipping my data and going right to yours. I think it still scores a 77 in this form, for what that's worth. I honestly think the answer key has errors, but we can skip worrying about that. :-)

Code: QB64: [Select]
  1.  
  2. ' Version: 6
  3.  
  4. Type LetterBin
  5.     Signature As String
  6.     Count As Integer
  7.  
  8. Dim Shared TestData(1000, 2) As String
  9. Call LoadTestData
  10.  
  11. Dim Shared Alphabet1(2) As LetterBin ' 0 1
  12. Dim Shared Alphabet2(4) As LetterBin ' 00 01 10 11
  13. Dim Shared Alphabet3(8) As LetterBin ' 000 001 010 011 100 101 110 111
  14. Dim Shared Alphabet4(16) As LetterBin ' etc
  15. Dim Shared Alphabet5(32) As LetterBin
  16. Dim Shared Alphabet6(64) As LetterBin
  17. Dim Shared Alphabet7(128) As LetterBin
  18. Dim Shared Alphabet8(256) As LetterBin
  19. Dim Shared Alphabet9(512) As LetterBin
  20. Dim Shared Alphabet10(1024) As LetterBin
  21. Dim Shared Alphabet11(2048) As LetterBin
  22. Dim Shared Alphabet12(4096) As LetterBin
  23. Dim Shared Alphabet13(8192) As LetterBin
  24.  
  25. Alphabet1(1).Signature = "0"
  26. Alphabet1(2).Signature = "1"
  27. Call NewAlphabet(Alphabet1(), Alphabet2())
  28. Call NewAlphabet(Alphabet2(), Alphabet3())
  29. Call NewAlphabet(Alphabet3(), Alphabet4())
  30. Call NewAlphabet(Alphabet4(), Alphabet5())
  31. Call NewAlphabet(Alphabet5(), Alphabet6())
  32. Call NewAlphabet(Alphabet6(), Alphabet7())
  33. Call NewAlphabet(Alphabet7(), Alphabet8())
  34. Call NewAlphabet(Alphabet8(), Alphabet9())
  35. Call NewAlphabet(Alphabet9(), Alphabet10())
  36. Call NewAlphabet(Alphabet10(), Alphabet11())
  37. Call NewAlphabet(Alphabet11(), Alphabet12())
  38. Call NewAlphabet(Alphabet12(), Alphabet13())
  39.  
  40. Dim thestring As String
  41. Dim actual As String
  42.  
  43. m = 79
  44. thestring = ""
  45.  
  46.     ' If analyzing pre-cooked data, load test string into Fingerprint(1).
  47.     If (m > 0) Then
  48.         thestring = TestData(m, 1)
  49.         actual = TestData(m, 2)
  50.     Else
  51.         actual = "?"
  52.     End If
  53.  
  54.     Cls
  55.     For k = 1 To _Width
  56.         Print "-";
  57.     Next
  58.     Print
  59.     Print "Case:"; m
  60.     Print
  61.     Call Analyze(thestring, actual)
  62.     Print
  63.  
  64.  
  65.     If (m > 0) Then
  66.         m = UserInput1(k, m)
  67.     Else
  68.         thestring = UserInput2$(k, thestring)
  69.     End If
  70.  
  71.     _KeyClear
  72.     _Limit 30
  73.  
  74.  
  75. Sub Analyze (TheStringIn As String, ActualIn As String)
  76.     Dim As Integer j, k
  77.     Dim As Double r
  78.     Dim Fingerprint(16) As String
  79.     Dim p(2 To 13) As Double
  80.  
  81.     ' Create shifted versions of string, i.e. ABCD -> BCDA, CDAB, DABC, ABCD, BCDA, etc.
  82.     Fingerprint(1) = TheStringIn
  83.     For k = 2 To UBound(Fingerprint)
  84.         Fingerprint(k) = Right$(Fingerprint(k - 1), Len(Fingerprint(k - 1)) - 1) + Left$(Fingerprint(k - 1), 1)
  85.     Next
  86.  
  87.     ' Initialize partial results.
  88.     For k = LBound(p) To UBound(p)
  89.         p(k) = -999
  90.     Next
  91.  
  92.     Call CreateHisto(Fingerprint(), Alphabet2(), 2)
  93.     Call CreateHisto(Fingerprint(), Alphabet3(), 3)
  94.     Call CreateHisto(Fingerprint(), Alphabet4(), 4)
  95.     Call CreateHisto(Fingerprint(), Alphabet5(), 5)
  96.     Call CreateHisto(Fingerprint(), Alphabet6(), 6)
  97.     Call CreateHisto(Fingerprint(), Alphabet7(), 7)
  98.     Call CreateHisto(Fingerprint(), Alphabet8(), 8)
  99.     Call CreateHisto(Fingerprint(), Alphabet9(), 9)
  100.     Call CreateHisto(Fingerprint(), Alphabet10(), 10)
  101.     Call CreateHisto(Fingerprint(), Alphabet11(), 11)
  102.     Call CreateHisto(Fingerprint(), Alphabet12(), 12)
  103.     Call CreateHisto(Fingerprint(), Alphabet13(), 13)
  104.  
  105.     If (Len(TheStringIn) >= 2) Then Call PrintHisto(Alphabet2(), 0) ' Turn the last number high to print stats for that histogram.
  106.     If (Len(TheStringIn) >= 3) Then Call PrintHisto(Alphabet3(), 0)
  107.     If (Len(TheStringIn) >= 4) Then Call PrintHisto(Alphabet4(), 0)
  108.     If (Len(TheStringIn) >= 5) Then Call PrintHisto(Alphabet5(), 0)
  109.     If (Len(TheStringIn) >= 6) Then Call PrintHisto(Alphabet6(), 0)
  110.     If (Len(TheStringIn) >= 7) Then Call PrintHisto(Alphabet7(), 0)
  111.     If (Len(TheStringIn) >= 8) Then Call PrintHisto(Alphabet8(), 0)
  112.     If (Len(TheStringIn) >= 9) Then Call PrintHisto(Alphabet9(), 0)
  113.     If (Len(TheStringIn) >= 10) Then Call PrintHisto(Alphabet10(), 0)
  114.     If (Len(TheStringIn) >= 11) Then Call PrintHisto(Alphabet11(), 0)
  115.     If (Len(TheStringIn) >= 12) Then Call PrintHisto(Alphabet12(), 0)
  116.     If (Len(TheStringIn) >= 13) Then Call PrintHisto(Alphabet13(), 0)
  117.     Print
  118.  
  119.     If (Len(TheStringIn) >= 2) Then p(2) = MakeGuess(TheStringIn, Alphabet2(), 2, 1) ' Set the last number =1 to print guess for that histogram.
  120.     If (Len(TheStringIn) >= 3) Then p(3) = MakeGuess(TheStringIn, Alphabet3(), 3, 1)
  121.     If (Len(TheStringIn) >= 4) Then p(4) = MakeGuess(TheStringIn, Alphabet4(), 4, 1)
  122.     If (Len(TheStringIn) >= 5) Then p(5) = MakeGuess(TheStringIn, Alphabet5(), 5, 1)
  123.     If (Len(TheStringIn) >= 6) Then p(6) = MakeGuess(TheStringIn, Alphabet6(), 6, 1)
  124.     If (Len(TheStringIn) >= 7) Then p(7) = MakeGuess(TheStringIn, Alphabet7(), 7, 1)
  125.     If (Len(TheStringIn) >= 8) Then p(8) = MakeGuess(TheStringIn, Alphabet8(), 8, 1)
  126.     If (Len(TheStringIn) >= 9) Then p(9) = MakeGuess(TheStringIn, Alphabet9(), 9, 1)
  127.     If (Len(TheStringIn) >= 10) Then p(10) = MakeGuess(TheStringIn, Alphabet10(), 10, 1)
  128.     If (Len(TheStringIn) >= 11) Then p(11) = MakeGuess(TheStringIn, Alphabet11(), 11, 1)
  129.     If (Len(TheStringIn) >= 12) Then p(12) = MakeGuess(TheStringIn, Alphabet12(), 12, 1)
  130.     If (Len(TheStringIn) >= 13) Then p(13) = MakeGuess(TheStringIn, Alphabet13(), 13, 1)
  131.     Print
  132.  
  133.     Print "Analyzing:"
  134.     Print TheStringIn
  135.     Print
  136.     Print "Thinking:";
  137.     For k = LBound(p) To UBound(p)
  138.         If (p(k) <> -999) Then Print p(k); Else Print "_ ";
  139.     Next
  140.     Print: Print
  141.  
  142.     j = 0
  143.     r = 0
  144.     Dim h
  145.     ' the only human disgression allowed is in the next 10 or so lines
  146.     For k = UBound(p) To LBound(p) Step -1
  147.         h = 1 + k - LBound(p)
  148.         h = h * h ' proposed model: later guesses count for more. this line can be commented out or made more elaborate
  149.         If (p(k) <> -999) Then
  150.             ' weighted average calculated here
  151.             r = r + h * p(k)
  152.             j = j + h
  153.         End If
  154.     Next
  155.     If (j <> 0) Then r = r / j
  156.     Print "Predicting:  "; _Trim$(Str$(r))
  157.     If (r > .5) Then
  158.         r = 1
  159.     Else
  160.         r = 0
  161.     End If
  162.     Print
  163.     Print "Rounding to: "; _Trim$(Str$(r))
  164.  
  165.     If (ActualIn <> "?") Then
  166.         Print
  167.         Print "Actual:      "; ActualIn
  168.         If (_Trim$(Str$(r)) <> ActualIn) Then
  169.             'Beep
  170.             Print
  171.             Print "*** MISMATCH ***"
  172.         End If
  173.     End If
  174.  
  175.  
  176. Function MakeGuess (OrigString As String, arralpha() As LetterBin, wid As Integer, p As Integer)
  177.     Dim TheReturn As Double
  178.     Dim As Integer j, k, n
  179.     TheReturn = 0
  180.     j = 1
  181.     k = 0
  182.     For n = 1 To UBound(arralpha)
  183.         If (Left$(arralpha(n).Signature, wid - 1) = Right$(OrigString, wid - 1)) Then
  184.             If (arralpha(n).Count >= j) Then
  185.                 If (p = 1) Then Print "Order "; _Trim$(Str$(wid)); " guess: "; arralpha(n).Signature; " . "; _Trim$(Str$(arralpha(n).Count))
  186.                 TheReturn = TheReturn + Val(Right$(arralpha(n).Signature, 1))
  187.                 k = k + 1
  188.                 j = arralpha(n).Count
  189.             End If
  190.         End If
  191.     Next
  192.     If (k <> 0) Then
  193.         TheReturn = TheReturn / k
  194.     Else
  195.         TheReturn = .5
  196.     End If
  197.     MakeGuess = TheReturn
  198.  
  199. Sub CreateHisto (arrfinger() As String, arralpha() As LetterBin, w As Integer)
  200.     Dim As Integer j, k, n
  201.     For n = 1 To UBound(arralpha)
  202.         arralpha(n).Count = 0
  203.     Next
  204.     For j = 1 To w
  205.         For k = 1 To Len(arrfinger(j)) - 0 Step w 'make the 0 a -w? might not matter at all
  206.             For n = 1 To UBound(arralpha)
  207.                 If (Mid$(arrfinger(j), k, w) = arralpha(n).Signature) Then
  208.                     arralpha(n).Count = arralpha(n).Count + 1
  209.                 End If
  210.             Next
  211.         Next
  212.     Next
  213.     Call QuickSort(arralpha(), 1, UBound(arralpha))
  214.  
  215. Sub PrintHisto (arr() As LetterBin, w As Integer)
  216.     Dim As Integer j, n
  217.     If (w > 0) Then
  218.         If (w > UBound(arr)) Then
  219.             j = UBound(arr)
  220.         Else
  221.             j = w
  222.         End If
  223.         Print "Un-scaled histogram: "; _Trim$(Str$(UBound(arr))); "-letter regroup, showing top "; _Trim$(Str$(w))
  224.         For n = 1 To j
  225.             Print arr(n).Signature; arr(n).Count
  226.         Next
  227.     End If
  228.  
  229. Function UserInput1 (TheKeyIn As Integer, PresentIndexIn As Integer)
  230.     Dim TheReturn As Integer
  231.     Dim As Integer j, k
  232.     k = TheKeyIn
  233.     j = -1
  234.     Select Case k ' Arrows
  235.         Case 19712
  236.             j = PresentIndexIn + 1
  237.         Case 19200
  238.             j = PresentIndexIn - 1
  239.     End Select
  240.     TheReturn = j
  241.     UserInput1 = TheReturn
  242.  
  243. Function UserInput2$ (TheKeyIn As Integer, TheStringIn As String)
  244.     Dim TheReturn As String
  245.     Dim As Integer k
  246.     Dim As String t
  247.     k = TheKeyIn
  248.     t = TheStringIn
  249.     Select Case k ' 0, 1, Backspace
  250.         Case 48
  251.             t = t + "0"
  252.         Case 49
  253.             t = t + "1"
  254.         Case 8
  255.             t = Left$(t, Len(t) - 1)
  256.     End Select
  257.     TheReturn = t
  258.     UserInput2$ = TheReturn
  259.  
  260. Sub NewAlphabet (arrold() As LetterBin, arrnew() As LetterBin)
  261.     Dim As Integer j, k, n
  262.     n = 0
  263.     For k = 1 To 2
  264.         For j = 1 To UBound(arrold)
  265.             n = n + 1
  266.             arrnew(n).Signature = arrold(j).Signature
  267.         Next
  268.     Next
  269.     For j = 1 To UBound(arrnew)
  270.         If (j <= UBound(arrnew) / 2) Then
  271.             arrnew(j).Signature = "0" + arrnew(j).Signature
  272.         Else
  273.             arrnew(j).Signature = "1" + arrnew(j).Signature
  274.         End If
  275.     Next
  276.  
  277. 'Sub BubbleSort (arr() As LetterBin)
  278. '    Dim As Integer i, j
  279. '    Dim As Integer u, v
  280. '    For j = UBound(arr) To 1 Step -1
  281. '        For i = 2 To UBound(arr)
  282. '            u = arr(i - 1).Count
  283. '            v = arr(i).Count
  284. '            If (u < v) Then
  285. '                Swap arr(i - 1), arr(i)
  286. '            End If
  287. '        Next
  288. '    Next
  289. 'End Sub
  290.  
  291. Sub QuickSort (arr() As LetterBin, LowLimit As Long, HighLimit As Long)
  292.     Dim As Long piv
  293.     If (LowLimit < HighLimit) Then
  294.         piv = Partition(arr(), LowLimit, HighLimit)
  295.         Call QuickSort(arr(), LowLimit, piv - 1)
  296.         Call QuickSort(arr(), piv + 1, HighLimit)
  297.     End If
  298.  
  299. Function Partition (arr() As LetterBin, LowLimit As Long, HighLimit As Long)
  300.     Dim As Long i, j
  301.     Dim As Double pivot, tmp
  302.     pivot = arr(HighLimit).Count
  303.     i = LowLimit - 1
  304.     For j = LowLimit To HighLimit - 1
  305.         tmp = arr(j).Count - pivot
  306.         If (tmp >= 0) Then
  307.             i = i + 1
  308.             Swap arr(i), arr(j)
  309.         End If
  310.     Next
  311.     Swap arr(i + 1), arr(HighLimit)
  312.     Partition = i + 1
  313.  
  314. Sub LoadTestData
  315.     Dim n As Integer
  316.     '''
  317.     n = 0
  318.     '''
  319.     ' Test: counting linearly
  320.     n = n + 1: TestData(n, 1) = "000001010011100101110111": TestData(n, 2) = "0" '0 to 7
  321.     n = n + 1: TestData(n, 1) = "0000000100100011010001010110011110001001101010111100110111101111": TestData(n, 2) = "0" '0 to 15
  322.     n = n + 1: TestData(n, 1) = "0000000001000100001100100001010011000111010000100101010010110110001101011100111110000100011001010011101001010110110101111100011001110101101111100111011111011111": TestData(n, 2) = "0" '0 to 31
  323.     '''
  324.     'n = 0
  325.     '''
  326.     ' Test: single-one patterns at stepping frequencies, all phases
  327.     n = n + 1: TestData(n, 1) = "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000": TestData(n, 2) = "0"
  328.     n = n + 1: TestData(n, 1) = "01010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101": TestData(n, 2) = "0"
  329.     n = n + 1: TestData(n, 1) = "10101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010": TestData(n, 2) = "1"
  330.     n = n + 1: TestData(n, 1) = "00100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100": TestData(n, 2) = "1"
  331.     n = n + 1: TestData(n, 1) = "01001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001": TestData(n, 2) = "0"
  332.     n = n + 1: TestData(n, 1) = "10010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010": TestData(n, 2) = "0"
  333.     n = n + 1: TestData(n, 1) = "00010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001": TestData(n, 2) = "0"
  334.     n = n + 1: TestData(n, 1) = "00100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010": TestData(n, 2) = "0"
  335.     n = n + 1: TestData(n, 1) = "01000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100": TestData(n, 2) = "0"
  336.     n = n + 1: TestData(n, 1) = "10001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000": TestData(n, 2) = "1"
  337.     n = n + 1: TestData(n, 1) = "00001000010000100001000010000100001000010000100001000010000100001000010000100001000010000100001000010000100001000010000100001000": TestData(n, 2) = "0"
  338.     n = n + 1: TestData(n, 1) = "00010000100001000010000100001000010000100001000010000100001000010000100001000010000100001000010000100001000010000100001000010000": TestData(n, 2) = "1"
  339.     n = n + 1: TestData(n, 1) = "00100001000010000100001000010000100001000010000100001000010000100001000010000100001000010000100001000010000100001000010000100001": TestData(n, 2) = "0"
  340.     n = n + 1: TestData(n, 1) = "01000010000100001000010000100001000010000100001000010000100001000010000100001000010000100001000010000100001000010000100001000010": TestData(n, 2) = "0"
  341.     n = n + 1: TestData(n, 1) = "10000100001000010000100001000010000100001000010000100001000010000100001000010000100001000010000100001000010000100001000010000100": TestData(n, 2) = "0"
  342.     n = n + 1: TestData(n, 1) = "00000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100": TestData(n, 2) = "0"
  343.     n = n + 1: TestData(n, 1) = "00001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000": TestData(n, 2) = "0"
  344.     n = n + 1: TestData(n, 1) = "00010000010000010000010000010000010000010000010000010000010000010000010000010000010000010000010000010000010000010000010000010000": TestData(n, 2) = "0"
  345.     n = n + 1: TestData(n, 1) = "00100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000": TestData(n, 2) = "1"
  346.     n = n + 1: TestData(n, 1) = "01000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001": TestData(n, 2) = "0"
  347.     n = n + 1: TestData(n, 1) = "10000010000010000010000010000010000010000010000010000010000010000010000010000010000010000010000010000010000010000010000010000010": TestData(n, 2) = "0"
  348.     '''
  349.     'n = 0
  350.     '''
  351.     ' Test: single-one patterns, select phases
  352.     n = n + 1: TestData(n, 1) = "00000010000001000000100000010000001000000100000010000001000000100000010000001000000100000010000001000000100000010000001000000100": TestData(n, 2) = "0"
  353.     n = n + 1: TestData(n, 1) = "00100000010000001000000100000010000001000000100000010000001000000100000010000001000000100000010000001000000100000010000001000000": TestData(n, 2) = "1"
  354.     n = n + 1: TestData(n, 1) = "00000001000000010000000100000001000000010000000100000001000000010000000100000001000000010000000100000001000000010000000100000001": TestData(n, 2) = "0"
  355.     n = n + 1: TestData(n, 1) = "10000000100000001000000010000000100000001000000010000000100000001000000010000000100000001000000010000000100000001000000010000000": TestData(n, 2) = "1"
  356.     '''
  357.     'n = 0
  358.     '''
  359.     ' Test: double-one patterns
  360.     n = n + 1: TestData(n, 1) = "00110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011": TestData(n, 2) = "0"
  361.     n = n + 1: TestData(n, 1) = "01100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110": TestData(n, 2) = "0"
  362.     n = n + 1: TestData(n, 1) = "11001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100": TestData(n, 2) = "1"
  363.     n = n + 1: TestData(n, 1) = "10011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001": TestData(n, 2) = "1"
  364.     n = n + 1: TestData(n, 1) = "00011100011100011100011100011100011100011100011100011100011100011100011100011100011100011100011100011100011100011100011100011100": TestData(n, 2) = "0"
  365.     n = n + 1: TestData(n, 1) = "00111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000": TestData(n, 2) = "1"
  366.     n = n + 1: TestData(n, 1) = "01110001110001110001110001110001110001110001110001110001110001110001110001110001110001110001110001110001110001110001110001110001": TestData(n, 2) = "1"
  367.     n = n + 1: TestData(n, 1) = "11100011100011100011100011100011100011100011100011100011100011100011100011100011100011100011100011100011100011100011100011100011": TestData(n, 2) = "1"
  368.     n = n + 1: TestData(n, 1) = "11000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111": TestData(n, 2) = "0"
  369.     n = n + 1: TestData(n, 1) = "10001110001110001110001110001110001110001110001110001110001110001110001110001110001110001110001110001110001110001110001110001110": TestData(n, 2) = "0"
  370.     '''
  371.     'n = 0
  372.     '''
  373.     ' Test: repeated staggered pattern: 010011000111, all phases
  374.     n = n + 1: TestData(n, 1) = "010011000111010011000111010011000111010011000111010011000111010011000111010011000111010011000111010011000111010011000111010011000111": TestData(n, 2) = "0"
  375.     n = n + 1: TestData(n, 1) = "100110001110100110001110100110001110100110001110100110001110100110001110100110001110100110001110100110001110100110001110100110001110": TestData(n, 2) = "1"
  376.     n = n + 1: TestData(n, 1) = "001100011101001100011101001100011101001100011101001100011101001100011101001100011101001100011101001100011101001100011101001100011101": TestData(n, 2) = "0"
  377.     n = n + 1: TestData(n, 1) = "011000111010011000111010011000111010011000111010011000111010011000111010011000111010011000111010011000111010011000111010011000111010": TestData(n, 2) = "0"
  378.     n = n + 1: TestData(n, 1) = "110001110100110001110100110001110100110001110100110001110100110001110100110001110100110001110100110001110100110001110100110001110100": TestData(n, 2) = "1"
  379.     n = n + 1: TestData(n, 1) = "100011101001100011101001100011101001100011101001100011101001100011101001100011101001100011101001100011101001100011101001100011101001": TestData(n, 2) = "1"
  380.     n = n + 1: TestData(n, 1) = "000111010011000111010011000111010011000111010011000111010011000111010011000111010011000111010011000111010011000111010011000111010011": TestData(n, 2) = "0"
  381.     n = n + 1: TestData(n, 1) = "001110100110001110100110001110100110001110100110001110100110001110100110001110100110001110100110001110100110001110100110001110100110": TestData(n, 2) = "0"
  382.     n = n + 1: TestData(n, 1) = "011101001100011101001100011101001100011101001100011101001100011101001100011101001100011101001100011101001100011101001100011101001100": TestData(n, 2) = "0"
  383.     n = n + 1: TestData(n, 1) = "111010011000111010011000111010011000111010011000111010011000111010011000111010011000111010011000111010011000111010011000111010011000": TestData(n, 2) = "1"
  384.     n = n + 1: TestData(n, 1) = "110100110001110100110001110100110001110100110001110100110001110100110001110100110001110100110001110100110001110100110001110100110001": TestData(n, 2) = "1"
  385.     n = n + 1: TestData(n, 1) = "101001100011101001100011101001100011101001100011101001100011101001100011101001100011101001100011101001100011101001100011101001100011": TestData(n, 2) = "1"
  386.     '''
  387.     'n = 0
  388.     '''
  389.     ' Test: repeated staggered pattern: 0100101010101001010101000111, all phases
  390.     n = n + 1: TestData(n, 1) = "01001010101010010101010001110100101010101001010101000111010010101010100101010100011101001010101010010101010001110100101010101001010101000111": TestData(n, 2) = "0"
  391.     n = n + 1: TestData(n, 1) = "10010101010100101010100011101001010101010010101010001110100101010101001010101000111010010101010100101010100011101001010101010010101010001110": TestData(n, 2) = "1"
  392.     n = n + 1: TestData(n, 1) = "00101010101001010101000111010010101010100101010100011101001010101010010101010001110100101010101001010101000111010010101010100101010100011101": TestData(n, 2) = "0"
  393.     n = n + 1: TestData(n, 1) = "01010101010010101010001110100101010101001010101000111010010101010100101010100011101001010101010010101010001110100101010101001010101000111010": TestData(n, 2) = "0"
  394.     n = n + 1: TestData(n, 1) = "10101010100101010100011101001010101010010101010001110100101010101001010101000111010010101010100101010100011101001010101010010101010001110100": TestData(n, 2) = "1"
  395.     n = n + 1: TestData(n, 1) = "01010101001010101000111010010101010100101010100011101001010101010010101010001110100101010101001010101000111010010101010100101010100011101001": TestData(n, 2) = "0"
  396.     n = n + 1: TestData(n, 1) = "10101010010101010001110100101010101001010101000111010010101010100101010100011101001010101010010101010001110100101010101001010101000111010010": TestData(n, 2) = "1"
  397.     n = n + 1: TestData(n, 1) = "01010100101010100011101001010101010010101010001110100101010101001010101000111010010101010100101010100011101001010101010010101010001110100101": TestData(n, 2) = "0"
  398.     n = n + 1: TestData(n, 1) = "10101001010101000111010010101010100101010100011101001010101010010101010001110100101010101001010101000111010010101010100101010100011101001010": TestData(n, 2) = "1"
  399.     n = n + 1: TestData(n, 1) = "01010010101010001110100101010101001010101000111010010101010100101010100011101001010101010010101010001110100101010101001010101000111010010101": TestData(n, 2) = "0"
  400.     n = n + 1: TestData(n, 1) = "10100101010100011101001010101010010101010001110100101010101001010101000111010010101010100101010100011101001010101010010101010001110100101010": TestData(n, 2) = "1"
  401.     n = n + 1: TestData(n, 1) = "01001010101000111010010101010100101010100011101001010101010010101010001110100101010101001010101000111010010101010100101010100011101001010101": TestData(n, 2) = "0"
  402.     n = n + 1: TestData(n, 1) = "10010101010001110100101010101001010101000111010010101010100101010100011101001010101010010101010001110100101010101001010101000111010010101010": TestData(n, 2) = "1"
  403.     n = n + 1: TestData(n, 1) = "00101010100011101001010101010010101010001110100101010101001010101000111010010101010100101010100011101001010101010010101010001110100101010101": TestData(n, 2) = "0"
  404.     n = n + 1: TestData(n, 1) = "01010101000111010010101010100101010100011101001010101010010101010001110100101010101001010101000111010010101010100101010100011101001010101010": TestData(n, 2) = "0"
  405.     n = n + 1: TestData(n, 1) = "10101010001110100101010101001010101000111010010101010100101010100011101001010101010010101010001110100101010101001010101000111010010101010100": TestData(n, 2) = "1"
  406.     n = n + 1: TestData(n, 1) = "01010100011101001010101010010101010001110100101010101001010101000111010010101010100101010100011101001010101010010101010001110100101010101001": TestData(n, 2) = "0"
  407.     n = n + 1: TestData(n, 1) = "10101000111010010101010100101010100011101001010101010010101010001110100101010101001010101000111010010101010100101010100011101001010101010010": TestData(n, 2) = "1"
  408.     n = n + 1: TestData(n, 1) = "01010001110100101010101001010101000111010010101010100101010100011101001010101010010101010001110100101010101001010101000111010010101010100101": TestData(n, 2) = "0"
  409.     n = n + 1: TestData(n, 1) = "10100011101001010101010010101010001110100101010101001010101000111010010101010100101010100011101001010101010010101010001110100101010101001010": TestData(n, 2) = "1"
  410.     n = n + 1: TestData(n, 1) = "01000111010010101010100101010100011101001010101010010101010001110100101010101001010101000111010010101010100101010100011101001010101010010101": TestData(n, 2) = "0"
  411.     n = n + 1: TestData(n, 1) = "10001110100101010101001010101000111010010101010100101010100011101001010101010010101010001110100101010101001010101000111010010101010100101010": TestData(n, 2) = "1"
  412.     n = n + 1: TestData(n, 1) = "00011101001010101010010101010001110100101010101001010101000111010010101010100101010100011101001010101010010101010001110100101010101001010101": TestData(n, 2) = "0"
  413.     n = n + 1: TestData(n, 1) = "00111010010101010100101010100011101001010101010010101010001110100101010101001010101000111010010101010100101010100011101001010101010010101010": TestData(n, 2) = "0"
  414.     n = n + 1: TestData(n, 1) = "01110100101010101001010101000111010010101010100101010100011101001010101010010101010001110100101010101001010101000111010010101010100101010100": TestData(n, 2) = "0"
  415.     n = n + 1: TestData(n, 1) = "11101001010101010010101010001110100101010101001010101000111010010101010100101010100011101001010101010010101010001110100101010101001010101000": TestData(n, 2) = "1"
  416.     n = n + 1: TestData(n, 1) = "11010010101010100101010100011101001010101010010101010001110100101010101001010101000111010010101010100101010100011101001010101010010101010001": TestData(n, 2) = "1"
  417.     n = n + 1: TestData(n, 1) = "10100101010101001010101000111010010101010100101010100011101001010101010010101010001110100101010101001010101000111010010101010100101010100011": TestData(n, 2) = "1"
  418.     '''
  419.     'n = 0
  420.     '''
  421.     ' Test: r1's custom quiz
  422.     n = n + 1: TestData(n, 1) = "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000": TestData(n, 2) = "0" '1
  423.     n = n + 1: TestData(n, 1) = "00000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000": TestData(n, 2) = "0" '
  424.     n = n + 1: TestData(n, 1) = "00000100000101110000001100010001100001001000000000000000001100000000000000000111001000000000000111100000000100111000000000000010000000001111000000000000000000000000000001010000000000000000010000000000000011000111100001000100000000000000000001101000000000000000001000110110000010000100000011001100001101001000000000000000000010000100001100011000101000000010000000000000000000000000000000000001000000000010000000000000001010000010000000000000000000000000000000000010000100000000000000001011010000000000": TestData(n, 2) = "0" '
  425.     n = n + 1: TestData(n, 1) = "00011101100000000001011100001011101000100111101100011000000011001010101000101000111111011000111000100000000000000110110000000001001001110110100001011011101100000011001010001111111110101100001101100001100011000111101100110000000101101101110000001110110111000011000110000000001101111000110000000011111100110001111000011101111101010011111111101111010011011001111101100010001100101101001011000010100111111101111010111111010110001100011000000100010001100111111001101101111000000010110111110000001011010011": TestData(n, 2) = "0" '
  426.     n = n + 1: TestData(n, 1) = "00000000100000000000110000000000000000010000000000000000010000000000000000001000000000000000000000000000000001000000010000000000000000000000000000000000000000000000000000011000000000000000001000000001000000000000000000000000000000000000000001001011001000000000000110000000000000000000000000000000000100010000000000000000000000000000000000001100000000000000000000000000000000100000000000000000001000000000000000000000000000000000000000000000100000000000000000100000000000000000000000000000000000000000": TestData(n, 2) = "0" '
  427.     n = n + 1: TestData(n, 1) = "01111011010110000100001000011001101101000011000011000000000100110010001010000100010000001110111000001000000000101110101100000000100011100101101110000010110101111001011010100000111011100110100001100100111010111110000010000110010000000100111100110000000101010100111001000000101000100101111001001001000010000100110011011010011011101000110011000000101000000100010000101101000101000110000100010101010111100000000001100000110010000001000011100001001000100000011100000101000001010101000100011010000100010011": TestData(n, 2) = "0" '
  428.     n = n + 1: TestData(n, 1) = "11000110011000111000001101000010001000001110001001110010000110000111010001010001100010101100001111100000111100101100000011000111101101110010101101010000101010000001111100000111110101010000000011011100100110101100111101000000100100101000011010000000010110101010011001110011111000010001100110001111111001100010011100010101001100000101010101100000000001001010000011011100010011001000001001110111100110010010000010000111111101100011010101010101000111010110101000000010001001001011011011100101111110110010": TestData(n, 2) = "0" '
  429.     n = n + 1: TestData(n, 1) = "10101101010001010110010110011111011111111101110100010011101110000000100011010000100111111001110110100011011110011101110001110011110000111011011110111011101100000010100111100010000010100111110010100100010001010101111000111010011101010111001110110000101101110001110010011101010110101110001111000101011001001101001011111101110010110101001100110010111101010111010010000010110100010001101110110101101110000101101010001001101101011000111110100000011101110010101111011110111110100110101001111101110001010110": TestData(n, 2) = "1" '
  430.     n = n + 1: TestData(n, 1) = "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000": TestData(n, 2) = "0" '
  431.     n = n + 1: TestData(n, 1) = "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000001000000000000000000000000000100000000000000000000000000000000000000000000000100000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000": TestData(n, 2) = "0" '10
  432.     n = n + 1: TestData(n, 1) = "00000110110101110000001100100101000001001111101111100000011000000000001001000100011000000000100011100000100000001001000001000010000000010111001101000001100000010101100011010011111000100111010000000000001010001011101110010100000000000010001011101000010000100000101100110100000011111000000001110000010101010000111111110000000110000100111110011000100000010001010100000000000110000000011000100000000111110011110010000100001010000010011100000000010001101010000000000110010000000110000000110011000000000000": TestData(n, 2) = "0" '
  433.     n = n + 1: TestData(n, 1) = "11011001010011000110101011011010000110001001010001001111100111001011110110111010001111010110010100100101011010110010010100111010111001101011100100001010011111111010011100101101000011011011000111011011010110111100110011100010100001101010110101110101110111010111010010011001110100011010011010101111101110100100100111101101001011100001001100100111010101100100101000111111111001001111100111010110111100001000000111101000111000001101011001001110001000010100110011111001001010101001110111010101111001100001": TestData(n, 2) = "0" '
  434.     n = n + 1: TestData(n, 1) = "00000000000000000000010000000001100000000000000000000001010000000000110010000000000000000000000000000000000000000000000000001100000000000111000101000000000000000000000000000100010001000000000000000000000000000000001100010010000000000000000001100000000000000000000000000001000000000000000000000000000000000010000011000000000000010000000000000001000000001000000000000000000000000000000000000100100000000000100000000000000000000000000000000000100000000000000000000000000000000000000000100000000000000000": TestData(n, 2) = "0" '
  435.     n = n + 1: TestData(n, 1) = "11101000011011010000101000100000010001001000000110011110001011010001001101101010001100111000000101001000011000001010010100010011100110101000101000000000010100111001010100010010101010100011000011000001011010000000010000000001011110110111000010000001011011100000000111001110100000110000000011000101100000001001000100110011000100100000100001001000000011010010100000000100100000101001100000110001001001110101010001000000011000000010101000110010000100001011000001101000101010011011001110010110000010000000": TestData(n, 2) = "0" '
  436.     n = n + 1: TestData(n, 1) = "00000010100110101001001000100000010100100100101101010010000001001100000000001011001110011011000010000111111001100010110011000010100110110000000000011010011010010100100011011011001100110001101001110000101001001100100010001101001000001011111100011011100000011001001010111000000000111101111001111001111111101000000000101100011001001011011010010000100001100010011110010000001011000001010111010010011111001001001110111100110010000110100111101000000101110100101010001111001111101100010101001001010101000101": TestData(n, 2) = "0" '
  437.     n = n + 1: TestData(n, 1) = "00111100000000000111001001100000111010010010010011100010001100001100000011011000100010000101110010110100110110011100010001111110011011000110010000001001101111111000011000010001101110011101111010100110100110000111011101001111110011011111100110111000001101101110001001001000011110100110000111110111010000001100100100100111110110100001001011100110111000100011110100100100110010011110011011100011101111010010000110000011101100000111001011000110000010001101111011111011001100000010000101000000000000101110": TestData(n, 2) = "0" '
  438.     n = n + 1: TestData(n, 1) = "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000": TestData(n, 2) = "0" '
  439.     n = n + 1: TestData(n, 1) = "00000000000000000000000000000000000000000100000000000000000000000010000000000000001000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000": TestData(n, 2) = "0" '
  440.     n = n + 1: TestData(n, 1) = "00000000010111101100110000001011000001001011001100000001001100001001000001001100010000111111000011100001000000001111010010000100001000000010001101001011101011011010000101010011110110110001100001000010000010100011000000110001000000011101110001000000000000110000100000101100000001011010000101000000100100011000111111110010110101010100011110100110110000010001101000000000101001000010100110000100010100111000010010100100001000110000000100010100010000000010000100011100010010110100010000010010001001000010": TestData(n, 2) = "0" '
  441.     n = n + 1: TestData(n, 1) = "11111111011001010010001100000100110110101110100011010010111011110100101000100000000101100000000100110010111110111000110101101010111111011101101010011111100100110100010011011001100000001110111110000101000000001100110101011110011111101100001110011101111100111100011100010010110111100001010000010001101001001111000000000101001000100100000110011000101011100100000100111011010110100000010001011010101011010010100111011000100011001000001010001011101010000100001011001011100001001011101110100110110010111100": TestData(n, 2) = "1" '20
  442.     n = n + 1: TestData(n, 1) = "00000000000000000000000000010000000000000000000000000000000100000000100000000000000000000011100000000000000000000000000001000000000000000000000000000011001000000000000100000000000000000000000000010010000000000000000000000000000000000000000000000000000000000000000000000000000010001000000000000000000000000000000000000010000000000000000000000010000000000000000000000000000000000000000000000001001000000000011100000000000000001000000000000000000100000000100010000110100000000000000000000000000000000000": TestData(n, 2) = "0" '
  443.     n = n + 1: TestData(n, 1) = "01011000100010001000011010000010010010000100100101000100011001000010000010110110010110001100010001000010110110000011010100000100100010010011111101111100110010101100000001000000100111010000010000100000000111100110000101110001100100000001000001001100100100010000001001000110000000000100011100110110000101100011100010110100000011001001011000010001001000101010010010000001000000100101100101001110110010010000100010100010000000100111001100000000001000111111010100001000001010000010101010110101101000001100": TestData(n, 2) = "0" '
  444.     n = n + 1: TestData(n, 1) = "00000101000010010110000110001101111110010001110010000010101001111111010000011011100000110000010101101110101111110101001100000100000000100110001000000000000001110011101011011110000001000110101001000000000000010100010010110110000010001100100010011001010011111011001110110000110100010010000010010110011000010110110010101000111000000100000001101100100110010100110111001110110101010001101100000000110010100010000001000101011100000000000111101110101011001011001100100000001101110000001001101010000000111011": TestData(n, 2) = "0" '
  445.     n = n + 1: TestData(n, 1) = "10100010000111100111110001101101100001100111001010011110011001101110100111000111001010100111100010110010101010100100100000101010111100100000010111001000101110010010111000001100011011001011010100101101101110001001111100110000001011100000010110011010001000001101101111001000011101001000110010110111100011111011001100011110100110100111001110000101010001010001101001101001011001111010011001101010000001111010110011100001010100011100110100011011110011100101000001110010010111100111110011001110011111001010": TestData(n, 2) = "1" '
  446.     n = n + 1: TestData(n, 1) = "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000": TestData(n, 2) = "0" '
  447.     n = n + 1: TestData(n, 1) = "00000000000000000000000000000000000000000100000000000001100000000000000000000000000000000000000000010000000000000000000000000000000001000000000000000000000000000000000001000000000000100000000000000000000000000000000000000000000000001100000000000000000000000000000000000000000000000000000000000000000000000000110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000": TestData(n, 2) = "0" '
  448.     n = n + 1: TestData(n, 1) = "00100000011101101100000000000000000000001010001010001010010000000011101000010100001000000110000110100000000010001000111100100100001010110000011000001010110100110011000010001000110101001001100001011000001000000000000010110000100000110000001001000000100000110100100100100001010011000000010101010010100101000000001011100010000000001100000110100010100010000001110000000100000001110010100100001110000001100110000100001000001000000000010000001000001000000001001100000000010011110100000000001010100001111111": TestData(n, 2) = "0" '
  449.     n = n + 1: TestData(n, 1) = "01010110100011101001111011101011111111101001100000010100001001111110010111100011101100011111110001101101111000110011010011010011110000101111110110010001000001010100100100110011010010010110101011100000111111111101111110110011111101010011110000111101000010010011010000011100001000011011000011001101100011011101000101010101111011000100001111010100111001011100011100011011011000000010011010010100110010011001111011010010110011111000101110010111111100100100111110111010101001101011010100000001011010010000": TestData(n, 2) = "1" '
  450.     n = n + 1: TestData(n, 1) = "00000000000000000000000000000000000000000000000000000000000000000000000000000100000001000000000000000000000000000000000000000001000000000000000000000000000000000000000010000000000000010010100000000000001000000000001000100000000000000000000001000000000000000000000000000000010000000010000000000000000000000001000000010000000000000000000000000000000000000000010000000110000000000000000000000001000000000010000100000000000000000100000001000000010000000000000000000000010000000000000000001000000000000000": TestData(n, 2) = "0" '
  451.     n = n + 1: TestData(n, 1) = "00000001100010111010101010001001000011001100000000000000010011000111001101001010110010010010010100101010000001001000111000000010110000010001001110100000000101101001110100010100000101000100000101000000010000110000010011010000100101001111000000011110001000001101101100000001000101000000011001011001110111100010010001000011110011110010010001000001110100100010101001110000010100000010010100000000101001000100101000011000000001001010111010110100000011001100101010000000100100100111111001110101000100000001": TestData(n, 2) = "0" '30
  452.     n = n + 1: TestData(n, 1) = "11010010010101000010000011010000101110111010011001101000101111011101001110000001011110100101101111000100000010110001010101000110100001100000111000111100011110110011101101101111101010100100011101000000010010101110000011011100010010101110101010000001110001001111110011011101000010110000101111000000101100011100101100001001100001111110000101110000010010000001001010000000011011000001000101000100000111101100110011000111010000001000010000000000100101010001100001011000001010001000111111110110101000011111": TestData(n, 2) = "0" '
  453.     n = n + 1: TestData(n, 1) = "11011111000111100000010011111111101111001100100010111010010000011000110100111010011000111101000111010000110110101010011010101011100110011101000001011011111110011100110100001001010000001000010010100101111011000101001000000011110011110001100100100011011001010000101101111110101011011100000111000111000011110101111011101000101010000111011110000111111101011101110110001000011000111011011011111100110000001011011010110101101111011001011000111100101100111010011100110111101100110110100110000010011111110101": TestData(n, 2) = "0" '
  454.     n = n + 1: TestData(n, 1) = "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000": TestData(n, 2) = "0" '
  455.     n = n + 1: TestData(n, 1) = "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000": TestData(n, 2) = "0" '
  456.     n = n + 1: TestData(n, 1) = "00100000000000000011000000000000000000000110000010011111100000000000000001000000001000000000000000010110000110000001100010000000000011110000000001100000000000110011000011000000010000001110000000011000001000010000110100000010000000111101000000000000000000100000000001100000100011000000000100000000000101000000000011010000001100010100000110110010100001010000110000001000000001100000110000001100000000011010000000000000101001100000000000000000100000011010100000000010010000100100010000000000000001111000": TestData(n, 2) = "0" '
  457.     n = n + 1: TestData(n, 1) = "00010100011101010101100000101000001100111001101101000000011001111001100110110111010111111011110001100000000001100000011001111000111001000110011010001110100110011001110111100000101000110001100110100111000111001000001001110101101110000000110000000000011001010101000110011101011001100011001001011001101100011110000101101001100011001010011000001100110000101000001111110110000000001100001100010010101111100101001101010000000110011011111100011111010000000101000000100101100111010110001101111010101010000110": TestData(n, 2) = "1" '
  458.     n = n + 1: TestData(n, 1) = "00000010000000000001100000000000000001000000000000000000000000000000000000000000000001001000000000000000000100000000000000000000010000000000000000100100000101000001000000100001100000000000000000000000000010110000000000000000100001000000000000001000000001100010000000010000010000000000000110000000001000000000001000010000000000010000000000000000000000000000000000000100001000000000000100001000000000000000000100000000000100000000000000000000000001001000000000000000000001000010000000000010000011000000": TestData(n, 2) = "0" '
  459.     n = n + 1: TestData(n, 1) = "11010000111110000000000011000001011000010011010100100000000000110011011101010010100100000000000000010001101001000001001010011000100101101000111011000001000010010000010000010100001000100110100001100100001001001001100011110010011000110111000011000000011000000000100110001000101101100000001000000000000100000000000001001110001110100000010100001011101010110100001001001000000010010100001010100111011111000100001010000011010001000011001101110001101110000011010101101001010100110100010001011100110100110111": TestData(n, 2) = "1" '
  460.     n = n + 1: TestData(n, 1) = "00000000110110001000000011001000100000001110011010100010101101111100101100101000001010000000101101010100101011010000010001001110001001100001110101011010111010000100001011001010010100011001011000010000100001000000000100001111001000101011111110100001110010011000100001101000101001101011110001011111000110111010010101000001001011101101110000001011110000011001100011111001010100010101110011000100110000101101010010110000000000010011001001101101000010000010001110000011111100111101100100110000001000110000": TestData(n, 2) = "0" '
  461.     n = n + 1: TestData(n, 1) = "00101101111001100011001000011101001000000001100000101001000010110101000011001101110010110011000010101100111010101111100101100111000010110111010100000000001010000111111011001000111011100100011111101010010101011111111010010110010001101010100101010110111010111000101111001101001101101111010101010010110001000110110110101000010100001000010011101010011110001000001111001100110001011010100011101011100000100000111001000111001010101111010010010100110111001000100011010110100011111011101001101010111101101010": TestData(n, 2) = "0" '40
  462.     n = n + 1: TestData(n, 1) = "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000": TestData(n, 2) = "0" '
  463.     n = n + 1: TestData(n, 1) = "10000000100000000000000001001001000000100011010001010100000100000000010101100110101000000000000100000101010000000101000000000101100000000000010000001000001011000110100110100010010100010111000100000100001010000000101010001000111001000000010000100100000000000000100000001001000000110001010001001010010000000010101001000111011000100100100000010010000100100000000000001000010010000110010110000110100000000000101001010100000110010001110000111000000110000000000000000000000100101100001010000100000101100010": TestData(n, 2) = "0" '
  464.     n = n + 1: TestData(n, 1) = "00001101011011101101111110010000011011010000101110101011001001111000101010010001010111100001110011011010100011011010101010111010001010100110101100000110110100101001011001010000001010100000111010111011100100110111010101010100000010000010101110001011010011001111011110110000110010001010001000110100101111101100000110111000000000000010001111101001011011010111110110000100101000111000101001110001010011110100010100100011110000001100001011000100100000011110111111100011000011000011100101111010111010010101": TestData(n, 2) = "1" '
  465.     n = n + 1: TestData(n, 1) = "01110011000100111110101110110110101110011100101000000011111010011111101010001000000000111110011010111010001110111000111111010010011101111101100111110001000000011000001000001101101001001000010001011000010001111100010001100111000100111111100011010001101101110110000001010110001111000100101110010001101101010001010110110000100111011001010100101101110000001111001111110111100101101001001001111001011111111011000010101001001001101010001111000011011001111111001011111101111001010010110000100001010000011000": TestData(n, 2) = "0" '
Title: Re: Looking for old program or help recreating it
Post by: random1 on December 12, 2021, 09:42:46 pm
Sounds good, I am making a few changes to your code so that it's more compatible with my
programs existing code.  Once it's in the loop so to say I can automate the testing process 
and use all 800+ strings.  Should be interesting. 

R1             
 
Title: Re: Looking for old program or help recreating it
Post by: STxAxTIC on December 12, 2021, 10:44:39 pm
Hey r1 - without wearing the subject out, I'll forewarn that I am still streamlining the code. Today I realized I had a few variables of the wrong type, which was actually making the guesses too crude. Very hard to notice this, but it was true. Anyway, i'll try to find a sensible place to post the latest code so you always get the best. Good luck in the meantime!
Title: Re: Looking for old program or help recreating it
Post by: random1 on December 13, 2021, 02:49:32 pm
Glad to see I'm not the only one. For me it's mixing variable types, one works for this
but need another for that.  I started storing the product as a string$ then use val($)
in my final calculations.  Maybe not the most efficient method but it helps keep things
straight.  I have a old function I picked up years ago called StrNum$.  Don't remember
the original author.

Code: QB64: [Select]
  1. FUNCTION StrNum$ (n#)
  2. value$ = UCASE$(LTRIM$(STR$(n#)))
  3. XPOS1% = INSTR(value$, "D") + INSTR(value$, "E") 'only D or E can be present
  4. IF XPOS1% THEN
  5. expo% = VAL(MID$(value$, XPOS1% + 1))
  6. IF VAL(value$) < 0 THEN
  7. sign$ = "-": value$ = MID$(value$, 2, XPOS1% - 2)
  8. ELSE value$ = MID$(value$, 1, XPOS1% - 1)
  9. dot% = INSTR(value$, "."): L% = LEN(value$)
  10. IF expo% > 0 THEN ADD$ = STRING$(expo% - (L% - dot%), "0")
  11. IF expo% < 0 THEN min$ = STRING$(ABS(expo%) - (dot% - 1), "0"): DP$ = "."
  12. FOR n = 1 TO L%
  13. IF MID$(value$, n, 1) <> "." THEN num$ = num$ + MID$(value$, n, 1)
  14. ELSE STRNUM$ = value$: EXIT FUNCTION
  15. STRNUM$ = sign$ + DP$ + min$ + num$ + ADD$
Title: Re: Looking for old program or help recreating it
Post by: random1 on December 13, 2021, 03:38:47 pm
P.S.
While your streamlining your code, if you could change it so that it processes a single string, makes
it's prediction then passes that value on, it would be much easier to add to my code.  There is quite
a bit of processing going on before and after each prediction is made.   My program is designed to
cook the data so to say, hand that data to the predictor then take the predicted value and move on. 

I am in the process of editing your code so that it works well with my code.  If there is going to be
several versions / updates then I think you can see the advantages.  I have at least 10 old predictors
that I can add or remove from the main program by simply using copy and paste.  I keep my old
prediction tools thinking some day I might be able to improve them.

R1       


   
Title: Re: Looking for old program or help recreating it
Post by: random1 on December 13, 2021, 05:26:33 pm
I attached another string file.  These strings, show the same data in a different format.

If the string value repeated, ie, the same value (0) or (1) carried over from the previous
event then the value is (1), if not then (0).  This list contains 112 strings 500 values in
length.  The strings flow is right to left.  The strings with  "****"  indicate events that
have been culled from the list but kept in place for later use.

At the bottom of the file is a small set of stats that that show the number of times each
value repeated within each string and the repeat probability.   

This data could be a bit easier to predict, my code is already capable of generating the
data and make all the needed conversions.

R1
Title: Re: Looking for old program or help recreating it
Post by: STxAxTIC on December 13, 2021, 08:54:02 pm
Hey r1,

So a few updates...

(Part I) I made my prediction function into more of a black box so it can be used in isolation. Of course, it still needs to the "alphabet" arrays

Code: QB64: [Select]
  1. Dim Shared Alphabet1(2) As LetterBin ' 0 1
  2. Dim Shared Alphabet2(4) As LetterBin ' 00 01 10 11
  3. Dim Shared Alphabet3(8) As LetterBin ' 000 001 010 011 100 101 110 111
  4. Dim Shared Alphabet4(16) As LetterBin ' etc.
  5.  

defined and filled in order to work. In practice that full chunk of code would go in the BI section, and then all one needs to do is use one line:

Code: QB64: [Select]
  1. prediction = Analyze(thestring, actual, 1)

Pretty simple, the answer "prediction" is a 1 or a 0, the "Analyze" function takes three arguments:
(a) the string to analyze, i.e. "1001101001010101"
(b) the known next digit, if it exists. otherwise, this argument must be a "?"
(c) an optional flag for printing, just set this to zero

...so that should help....

Part (II) is more intersting...

So I looked at the file you provided, and then read what you said about it, and then had to write another program to wrestle your data into a form that my program already uses. Reading a string left-to-right is a little more natural to me, so I reversed all your strings. I also (as kindof a checksum) made sure I could re-derive all of the decimal values you included at the bottom. I unambiguously know exactly where those come from. Inspired by this, I edited my analysis function to calculate those same numbers (for any input string, not just the new ones).

The new results are only mildly interesting, and hardly surprising. Punchline is, using that decimal is a rather crummy way to estimate what number comes next. Case in point would be something like:

0101010101010101010101
versus
1010101010101010101010

Those two strings differ by just a phase but would produce identical decimals. All the reason why an n-gram based approach is much more revealing. But anyway, I ramble. This program is pre-set to analyze your newest data:

Code: QB64: [Select]
  1.  
  2. Screen _NewImage(120, 60)
  3.  
  4. ' Version: 7
  5.  
  6. Type LetterBin
  7.     Signature As String
  8.     Count As Integer
  9.  
  10. Dim Shared TestData(1000, 2) As String
  11. Call LoadTestData
  12.  
  13. Dim Shared Alphabet1(2) As LetterBin ' 0 1
  14. Dim Shared Alphabet2(4) As LetterBin ' 00 01 10 11
  15. Dim Shared Alphabet3(8) As LetterBin ' 000 001 010 011 100 101 110 111
  16. Dim Shared Alphabet4(16) As LetterBin ' etc.
  17. Dim Shared Alphabet5(32) As LetterBin
  18. Dim Shared Alphabet6(64) As LetterBin
  19. Dim Shared Alphabet7(128) As LetterBin
  20. Dim Shared Alphabet8(256) As LetterBin
  21. Dim Shared Alphabet9(512) As LetterBin
  22. Dim Shared Alphabet10(1024) As LetterBin
  23. Dim Shared Alphabet11(2048) As LetterBin
  24. Dim Shared Alphabet12(4096) As LetterBin
  25. Dim Shared Alphabet13(8192) As LetterBin
  26.  
  27. Alphabet1(1).Signature = "0"
  28. Alphabet1(2).Signature = "1"
  29. Call NewAlphabet(Alphabet1(), Alphabet2())
  30. Call NewAlphabet(Alphabet2(), Alphabet3())
  31. Call NewAlphabet(Alphabet3(), Alphabet4())
  32. Call NewAlphabet(Alphabet4(), Alphabet5())
  33. Call NewAlphabet(Alphabet5(), Alphabet6())
  34. Call NewAlphabet(Alphabet6(), Alphabet7())
  35. Call NewAlphabet(Alphabet7(), Alphabet8())
  36. Call NewAlphabet(Alphabet8(), Alphabet9())
  37. Call NewAlphabet(Alphabet9(), Alphabet10())
  38. Call NewAlphabet(Alphabet10(), Alphabet11())
  39. Call NewAlphabet(Alphabet11(), Alphabet12())
  40. Call NewAlphabet(Alphabet12(), Alphabet13())
  41.  
  42. Dim thestring As String
  43. Dim actual As String
  44. Dim prediction As Integer
  45.  
  46. m = 1
  47. thestring = ""
  48.  
  49.     ' If analyzing pre-cooked data, load a test string.
  50.     If (m > 0) Then
  51.         thestring = TestData(m, 1)
  52.         actual = TestData(m, 2)
  53.     Else
  54.         actual = "?"
  55.     End If
  56.  
  57.     Cls
  58.     For k = 1 To _Width
  59.         Print "-";
  60.     Next
  61.     Print
  62.     Print "Case:"; m
  63.     Print
  64.     prediction = Analyze(thestring, actual, 1)
  65.     'Print "("; prediction; ")"
  66.  
  67.  
  68.     If (m > 0) Then
  69.         m = UserInput1(k, m)
  70.     Else
  71.         thestring = UserInput2$(k, thestring)
  72.     End If
  73.  
  74.     '_Delay 1
  75.     'm = m + 1
  76.  
  77.     _KeyClear
  78.     _Limit 30
  79.  
  80.  
  81. Function Analyze (TheStringIn As String, ActualIn As String, pswitch As Integer)
  82.     Dim TheReturn As Integer
  83.     Dim As Integer n
  84.     Dim As Double r, j, k, h
  85.     Dim Fingerprint(16) As String
  86.     Dim p(2 To 13, 2) As Double
  87.  
  88.     ' Create shifted versions of string, i.e. ABCD -> BCDA, CDAB, DABC, ABCD, BCDA, etc.
  89.     Fingerprint(1) = TheStringIn
  90.     For n = 2 To UBound(Fingerprint)
  91.         Fingerprint(n) = Right$(Fingerprint(n - 1), Len(Fingerprint(n - 1)) - 1) + Left$(Fingerprint(n - 1), 1)
  92.     Next
  93.  
  94.     ' Initialize partial results.
  95.     For n = LBound(p) To UBound(p)
  96.         p(n, 1) = -999
  97.     Next
  98.  
  99.     Call CreateHisto(Fingerprint(), Alphabet2(), 2, 0) ' Set the last number =1 to print steps.
  100.     Call CreateHisto(Fingerprint(), Alphabet3(), 3, 0)
  101.     Call CreateHisto(Fingerprint(), Alphabet4(), 4, 0)
  102.     Call CreateHisto(Fingerprint(), Alphabet5(), 5, 0)
  103.     Call CreateHisto(Fingerprint(), Alphabet6(), 6, 0)
  104.     Call CreateHisto(Fingerprint(), Alphabet7(), 7, 0)
  105.     Call CreateHisto(Fingerprint(), Alphabet8(), 8, 0)
  106.     Call CreateHisto(Fingerprint(), Alphabet9(), 9, 0)
  107.     Call CreateHisto(Fingerprint(), Alphabet10(), 10, 0)
  108.     Call CreateHisto(Fingerprint(), Alphabet11(), 11, 0)
  109.     Call CreateHisto(Fingerprint(), Alphabet12(), 12, 0)
  110.     Call CreateHisto(Fingerprint(), Alphabet13(), 13, 0)
  111.  
  112.     If (pswitch = 1) Then
  113.         If (Len(TheStringIn) >= 2) Then Call PrintHisto(Alphabet2(), 3) ' Set the last number >=1 to print stats for that histogram.
  114.         If (Len(TheStringIn) >= 3) Then Call PrintHisto(Alphabet3(), 3)
  115.         If (Len(TheStringIn) >= 4) Then Call PrintHisto(Alphabet4(), 3)
  116.         If (Len(TheStringIn) >= 5) Then Call PrintHisto(Alphabet5(), 3)
  117.         If (Len(TheStringIn) >= 6) Then Call PrintHisto(Alphabet6(), 0)
  118.         If (Len(TheStringIn) >= 7) Then Call PrintHisto(Alphabet7(), 0)
  119.         If (Len(TheStringIn) >= 8) Then Call PrintHisto(Alphabet8(), 0)
  120.         If (Len(TheStringIn) >= 9) Then Call PrintHisto(Alphabet9(), 0)
  121.         If (Len(TheStringIn) >= 10) Then Call PrintHisto(Alphabet10(), 0)
  122.         If (Len(TheStringIn) >= 11) Then Call PrintHisto(Alphabet11(), 0)
  123.         If (Len(TheStringIn) >= 12) Then Call PrintHisto(Alphabet12(), 0)
  124.         If (Len(TheStringIn) >= 13) Then Call PrintHisto(Alphabet13(), 0)
  125.         Print
  126.     End If
  127.  
  128.     If (Len(TheStringIn) >= 2) Then Call MakeGuess(TheStringIn, Alphabet2(), 2, p(), pswitch) ' Set the last number =1 to print guess for that histogram.
  129.     If (Len(TheStringIn) >= 3) Then Call MakeGuess(TheStringIn, Alphabet3(), 3, p(), pswitch)
  130.     If (Len(TheStringIn) >= 4) Then Call MakeGuess(TheStringIn, Alphabet4(), 4, p(), pswitch)
  131.     If (Len(TheStringIn) >= 5) Then Call MakeGuess(TheStringIn, Alphabet5(), 5, p(), pswitch)
  132.     If (Len(TheStringIn) >= 6) Then Call MakeGuess(TheStringIn, Alphabet6(), 6, p(), pswitch)
  133.     If (Len(TheStringIn) >= 7) Then Call MakeGuess(TheStringIn, Alphabet7(), 7, p(), pswitch)
  134.     If (Len(TheStringIn) >= 8) Then Call MakeGuess(TheStringIn, Alphabet8(), 8, p(), pswitch)
  135.     If (Len(TheStringIn) >= 9) Then Call MakeGuess(TheStringIn, Alphabet9(), 9, p(), pswitch)
  136.     If (Len(TheStringIn) >= 10) Then Call MakeGuess(TheStringIn, Alphabet10(), 10, p(), pswitch)
  137.     If (Len(TheStringIn) >= 11) Then Call MakeGuess(TheStringIn, Alphabet11(), 11, p(), pswitch)
  138.     If (Len(TheStringIn) >= 12) Then Call MakeGuess(TheStringIn, Alphabet12(), 12, p(), pswitch)
  139.     If (Len(TheStringIn) >= 13) Then Call MakeGuess(TheStringIn, Alphabet13(), 13, p(), pswitch)
  140.     If (pswitch = 1) Then Print
  141.  
  142.     If (pswitch = 1) Then
  143.         Print "Analyzing:"
  144.         Print TheStringIn
  145.         Print
  146.         Print "Thinking:";
  147.         For k = LBound(p) To UBound(p)
  148.             If (p(k, 1) <> -999) Then
  149.                 Print p(k, 1);
  150.             Else
  151.                 Print "_ ";
  152.             End If
  153.         Next
  154.         Print: Print
  155.     End If
  156.  
  157.     j = 0
  158.     r = 0
  159.  
  160.     For k = UBound(p) To LBound(p) Step -1
  161.         If (p(k, 1) <> -999) Then
  162.  
  163.             ' This is the made-up part of the model:
  164.             ' The variable r contributes to weighted average.
  165.             ' The variable j is used for normalization.
  166.             ' Scaling factor h influences weighted average calculaton.
  167.             ' The factors multiplying h are totally arbitrary. Notes:
  168.             '   setting o(h^2) means the later alphabets count for more.
  169.             '   p(k, 1) euqals the calculated guess at frequency k.
  170.             '   p(k, 2) euqals the peak count of the unscaled histogram.
  171.             '   ...while p(k, 2) is here, it does not seem to help calculations.
  172.  
  173.             h = 1 + k - LBound(p)
  174.  
  175.             h = h ^ 2
  176.  
  177.             ' Standard weighted average:
  178.             r = r + h * p(k, 1)
  179.             j = j + h
  180.  
  181.         End If
  182.     Next
  183.     If (j <> 0) Then
  184.         r = r / j
  185.     End If
  186.  
  187.     If (pswitch = 1) Then Print "Predicting:  "; _Trim$(Str$(r))
  188.  
  189.     If (r > .5) Then
  190.         r = 1
  191.     Else
  192.         r = 0
  193.     End If
  194.  
  195.     If (pswitch = 1) Then
  196.         Print "Rounding to: "; _Trim$(Str$(r))
  197.         If (ActualIn <> "?") Then
  198.             Print
  199.             Print "Actual:      "; ActualIn
  200.             If (_Trim$(Str$(r)) <> ActualIn) Then
  201.                 Beep
  202.                 Print
  203.                 Print "*** MISMATCH ***"
  204.             End If
  205.         Else
  206.             n = Len(TheStringIn)
  207.             h = 0
  208.             For k = 1 To n
  209.                 If Val(Mid$(TheStringIn, k, 1)) = 1 Then h = h + 1
  210.             Next
  211.             h = h / n
  212.             Print
  213.             Print "Naive (dec): "; _Trim$(Str$(h))
  214.             If (h > .5) Then
  215.                 h = 1
  216.             Else
  217.                 h = 0
  218.             End If
  219.             Print "Naive (int): "; _Trim$(Str$(h))
  220.             If (r <> h) Then
  221.                 Beep
  222.                 Print
  223.                 Print "*** MISMATCH ***"
  224.             End If
  225.         End If
  226.     End If
  227.  
  228.     TheReturn = r
  229.     Analyze = TheReturn
  230.  
  231. Sub MakeGuess (OrigString As String, arralpha() As LetterBin, wid As Integer, arrbeta() As Double, pswitch As Integer)
  232.     Dim TheReturn As Double
  233.     Dim As Integer j, k, n
  234.     TheReturn = 0
  235.     j = 1 '0
  236.     k = 0
  237.     For n = 1 To UBound(arralpha)
  238.         If (Left$(arralpha(n).Signature, wid - 1) = Right$(OrigString, wid - 1)) Then
  239.             If (arralpha(n).Count >= j) Then
  240.                 If (pswitch = 1) Then Print "Order-"; Right$("0" + _Trim$(Str$(wid)), 2); " guess: "; arralpha(n).Signature; " . "; _Trim$(Str$(arralpha(n).Count))
  241.                 TheReturn = TheReturn + Val(Right$(arralpha(n).Signature, 1))
  242.                 k = k + 1
  243.                 j = arralpha(n).Count
  244.             End If
  245.         End If
  246.     Next
  247.     If (k <> 0) Then
  248.         TheReturn = TheReturn / k
  249.         arrbeta(wid, 1) = TheReturn
  250.         arrbeta(wid, 2) = j
  251.     Else
  252.         TheReturn = .5
  253.         arrbeta(wid, 1) = TheReturn
  254.         arrbeta(wid, 2) = j
  255.     End If
  256.  
  257. Sub CreateHisto (arrfinger() As String, arralpha() As LetterBin, w As Integer, pswitch As Integer)
  258.     Dim As Integer j, k, n
  259.     For n = 1 To UBound(arralpha)
  260.         arralpha(n).Count = 0
  261.     Next
  262.     For j = 1 To w '1 'w
  263.         For k = 1 To Len(arrfinger(j)) - (Len(arrfinger(j)) Mod w) Step w '- 0 Step 1 'w 'make the 0 a -w? might not matter at all
  264.             If (pswitch = 1) Then Print j; " "; arrfinger(j)
  265.             For n = 1 To UBound(arralpha)
  266.                 If (pswitch = 1) Then
  267.                     Print "@@@"; n; " "; Mid$(arrfinger(j), k, w); " "; arralpha(n).Signature;
  268.                 End If
  269.                 If (Mid$(arrfinger(j), k, w) = arralpha(n).Signature) Then
  270.                     arralpha(n).Count = arralpha(n).Count + 1
  271.                     If (pswitch = 1) Then Print "***";
  272.                 End If
  273.                 If pswitch = 1 Then Print
  274.             Next
  275.         Next
  276.     Next
  277.     Call QuickSort(arralpha(), 1, UBound(arralpha))
  278.  
  279. Sub PrintHisto (arr() As LetterBin, w As Integer)
  280.     Dim As Integer j, n
  281.     If (w > 0) Then
  282.         If (w > UBound(arr)) Then
  283.             j = UBound(arr)
  284.         Else
  285.             j = w
  286.         End If
  287.         Print "Histogram: "; _Trim$(Str$(UBound(arr))); "-letter regroup, showing top "; _Trim$(Str$(w))
  288.         For n = 1 To j
  289.             Print arr(n).Signature; arr(n).Count
  290.         Next
  291.     End If
  292.  
  293. Function UserInput1 (TheKeyIn As Integer, PresentIndexIn As Integer)
  294.     Dim TheReturn As Integer
  295.     Dim As Integer j, k
  296.     k = TheKeyIn
  297.     j = -1
  298.     Select Case k ' Arrows
  299.         Case 19712
  300.             j = PresentIndexIn + 1
  301.         Case 19200
  302.             j = PresentIndexIn - 1
  303.     End Select
  304.     TheReturn = j
  305.     UserInput1 = TheReturn
  306.  
  307. Function UserInput2$ (TheKeyIn As Integer, TheStringIn As String)
  308.     Dim TheReturn As String
  309.     Dim As Integer k
  310.     Dim As String t
  311.     k = TheKeyIn
  312.     t = TheStringIn
  313.     Select Case k ' 0, 1, Backspace
  314.         Case 48
  315.             t = t + "0"
  316.         Case 49
  317.             t = t + "1"
  318.         Case 8
  319.             t = Left$(t, Len(t) - 1)
  320.     End Select
  321.     TheReturn = t
  322.     UserInput2$ = TheReturn
  323.  
  324. Sub NewAlphabet (arrold() As LetterBin, arrnew() As LetterBin)
  325.     Dim As Integer j, k, n
  326.     n = 0
  327.     For k = 1 To 2
  328.         For j = 1 To UBound(arrold)
  329.             n = n + 1
  330.             arrnew(n).Signature = arrold(j).Signature
  331.         Next
  332.     Next
  333.     For j = 1 To UBound(arrnew)
  334.         If (j <= UBound(arrnew) / 2) Then
  335.             arrnew(j).Signature = "0" + arrnew(j).Signature
  336.         Else
  337.             arrnew(j).Signature = "1" + arrnew(j).Signature
  338.         End If
  339.     Next
  340.  
  341. Sub QuickSort (arr() As LetterBin, LowLimit As Long, HighLimit As Long)
  342.     Dim As Long piv
  343.     If (LowLimit < HighLimit) Then
  344.         piv = Partition(arr(), LowLimit, HighLimit)
  345.         Call QuickSort(arr(), LowLimit, piv - 1)
  346.         Call QuickSort(arr(), piv + 1, HighLimit)
  347.     End If
  348.  
  349. Function Partition (arr() As LetterBin, LowLimit As Long, HighLimit As Long)
  350.     Dim As Long i, j
  351.     Dim As Double pivot, tmp
  352.     pivot = arr(HighLimit).Count
  353.     i = LowLimit - 1
  354.     For j = LowLimit To HighLimit - 1
  355.         tmp = arr(j).Count - pivot
  356.         If (tmp >= 0) Then
  357.             i = i + 1
  358.             Swap arr(i), arr(j)
  359.         End If
  360.     Next
  361.     Swap arr(i + 1), arr(HighLimit)
  362.     Partition = i + 1
  363.  
  364. Sub LoadTestData
  365.     Dim n As Integer
  366.     '''
  367.     n = 0
  368.     '''
  369.     ' Test: counting linearly
  370.     n = n + 1: TestData(n, 1) = "000001010011100101110111": TestData(n, 2) = "0" '0 to 7
  371.     n = n + 1: TestData(n, 1) = "0000000100100011010001010110011110001001101010111100110111101111": TestData(n, 2) = "0" '0 to 15
  372.     n = n + 1: TestData(n, 1) = "0000000001000100001100100001010011000111010000100101010010110110001101011100111110000100011001010011101001010110110101111100011001110101101111100111011111011111": TestData(n, 2) = "0" '0 to 31
  373.     '''
  374.     'n = 0
  375.     '''
  376.     ' Test: single-one patterns at stepping frequencies, all phases
  377.     n = n + 1: TestData(n, 1) = "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000": TestData(n, 2) = "0"
  378.     n = n + 1: TestData(n, 1) = "01010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101": TestData(n, 2) = "0"
  379.     n = n + 1: TestData(n, 1) = "10101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010": TestData(n, 2) = "1"
  380.     n = n + 1: TestData(n, 1) = "00100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100": TestData(n, 2) = "1"
  381.     n = n + 1: TestData(n, 1) = "01001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001": TestData(n, 2) = "0"
  382.     n = n + 1: TestData(n, 1) = "10010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010": TestData(n, 2) = "0"
  383.     n = n + 1: TestData(n, 1) = "00010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001": TestData(n, 2) = "0"
  384.     n = n + 1: TestData(n, 1) = "00100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010": TestData(n, 2) = "0"
  385.     n = n + 1: TestData(n, 1) = "01000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100": TestData(n, 2) = "0"
  386.     n = n + 1: TestData(n, 1) = "10001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000": TestData(n, 2) = "1"
  387.     n = n + 1: TestData(n, 1) = "00001000010000100001000010000100001000010000100001000010000100001000010000100001000010000100001000010000100001000010000100001000": TestData(n, 2) = "0"
  388.     n = n + 1: TestData(n, 1) = "00010000100001000010000100001000010000100001000010000100001000010000100001000010000100001000010000100001000010000100001000010000": TestData(n, 2) = "1"
  389.     n = n + 1: TestData(n, 1) = "00100001000010000100001000010000100001000010000100001000010000100001000010000100001000010000100001000010000100001000010000100001": TestData(n, 2) = "0"
  390.     n = n + 1: TestData(n, 1) = "01000010000100001000010000100001000010000100001000010000100001000010000100001000010000100001000010000100001000010000100001000010": TestData(n, 2) = "0"
  391.     n = n + 1: TestData(n, 1) = "10000100001000010000100001000010000100001000010000100001000010000100001000010000100001000010000100001000010000100001000010000100": TestData(n, 2) = "0"
  392.     n = n + 1: TestData(n, 1) = "00000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100": TestData(n, 2) = "0"
  393.     n = n + 1: TestData(n, 1) = "00001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000": TestData(n, 2) = "0"
  394.     n = n + 1: TestData(n, 1) = "00010000010000010000010000010000010000010000010000010000010000010000010000010000010000010000010000010000010000010000010000010000": TestData(n, 2) = "0"
  395.     n = n + 1: TestData(n, 1) = "00100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000": TestData(n, 2) = "1"
  396.     n = n + 1: TestData(n, 1) = "01000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001": TestData(n, 2) = "0"
  397.     n = n + 1: TestData(n, 1) = "10000010000010000010000010000010000010000010000010000010000010000010000010000010000010000010000010000010000010000010000010000010": TestData(n, 2) = "0"
  398.     '''
  399.     'n = 0
  400.     '''
  401.     ' Test: single-one patterns, select phases
  402.     n = n + 1: TestData(n, 1) = "00000010000001000000100000010000001000000100000010000001000000100000010000001000000100000010000001000000100000010000001000000100": TestData(n, 2) = "0"
  403.     n = n + 1: TestData(n, 1) = "00100000010000001000000100000010000001000000100000010000001000000100000010000001000000100000010000001000000100000010000001000000": TestData(n, 2) = "1"
  404.     n = n + 1: TestData(n, 1) = "00000001000000010000000100000001000000010000000100000001000000010000000100000001000000010000000100000001000000010000000100000001": TestData(n, 2) = "0"
  405.     n = n + 1: TestData(n, 1) = "10000000100000001000000010000000100000001000000010000000100000001000000010000000100000001000000010000000100000001000000010000000": TestData(n, 2) = "1"
  406.     '''
  407.     'n = 0
  408.     '''
  409.     ' Test: double-one patterns
  410.     n = n + 1: TestData(n, 1) = "00110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011": TestData(n, 2) = "0"
  411.     n = n + 1: TestData(n, 1) = "01100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110": TestData(n, 2) = "0"
  412.     n = n + 1: TestData(n, 1) = "11001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100": TestData(n, 2) = "1"
  413.     n = n + 1: TestData(n, 1) = "10011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001": TestData(n, 2) = "1"
  414.     n = n + 1: TestData(n, 1) = "00011100011100011100011100011100011100011100011100011100011100011100011100011100011100011100011100011100011100011100011100011100": TestData(n, 2) = "0"
  415.     n = n + 1: TestData(n, 1) = "00111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000": TestData(n, 2) = "1"
  416.     n = n + 1: TestData(n, 1) = "01110001110001110001110001110001110001110001110001110001110001110001110001110001110001110001110001110001110001110001110001110001": TestData(n, 2) = "1"
  417.     n = n + 1: TestData(n, 1) = "11100011100011100011100011100011100011100011100011100011100011100011100011100011100011100011100011100011100011100011100011100011": TestData(n, 2) = "1"
  418.     n = n + 1: TestData(n, 1) = "11000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111": TestData(n, 2) = "0"
  419.     n = n + 1: TestData(n, 1) = "10001110001110001110001110001110001110001110001110001110001110001110001110001110001110001110001110001110001110001110001110001110": TestData(n, 2) = "0"
  420.     '''
  421.     'n = 0
  422.     '''
  423.     ' Test: repeated staggered pattern: 010011000111, all phases
  424.     n = n + 1: TestData(n, 1) = "010011000111010011000111010011000111010011000111010011000111010011000111010011000111010011000111010011000111010011000111010011000111": TestData(n, 2) = "0"
  425.     n = n + 1: TestData(n, 1) = "100110001110100110001110100110001110100110001110100110001110100110001110100110001110100110001110100110001110100110001110100110001110": TestData(n, 2) = "1"
  426.     n = n + 1: TestData(n, 1) = "001100011101001100011101001100011101001100011101001100011101001100011101001100011101001100011101001100011101001100011101001100011101": TestData(n, 2) = "0"
  427.     n = n + 1: TestData(n, 1) = "011000111010011000111010011000111010011000111010011000111010011000111010011000111010011000111010011000111010011000111010011000111010": TestData(n, 2) = "0"
  428.     n = n + 1: TestData(n, 1) = "110001110100110001110100110001110100110001110100110001110100110001110100110001110100110001110100110001110100110001110100110001110100": TestData(n, 2) = "1"
  429.     n = n + 1: TestData(n, 1) = "100011101001100011101001100011101001100011101001100011101001100011101001100011101001100011101001100011101001100011101001100011101001": TestData(n, 2) = "1"
  430.     n = n + 1: TestData(n, 1) = "000111010011000111010011000111010011000111010011000111010011000111010011000111010011000111010011000111010011000111010011000111010011": TestData(n, 2) = "0"
  431.     n = n + 1: TestData(n, 1) = "001110100110001110100110001110100110001110100110001110100110001110100110001110100110001110100110001110100110001110100110001110100110": TestData(n, 2) = "0"
  432.     n = n + 1: TestData(n, 1) = "011101001100011101001100011101001100011101001100011101001100011101001100011101001100011101001100011101001100011101001100011101001100": TestData(n, 2) = "0"
  433.     n = n + 1: TestData(n, 1) = "111010011000111010011000111010011000111010011000111010011000111010011000111010011000111010011000111010011000111010011000111010011000": TestData(n, 2) = "1"
  434.     n = n + 1: TestData(n, 1) = "110100110001110100110001110100110001110100110001110100110001110100110001110100110001110100110001110100110001110100110001110100110001": TestData(n, 2) = "1"
  435.     n = n + 1: TestData(n, 1) = "101001100011101001100011101001100011101001100011101001100011101001100011101001100011101001100011101001100011101001100011101001100011": TestData(n, 2) = "1"
  436.     '''
  437.     'n = 0
  438.     '''
  439.     ' Test: repeated staggered pattern: 0100101010101001010101000111, all phases
  440.     n = n + 1: TestData(n, 1) = "01001010101010010101010001110100101010101001010101000111010010101010100101010100011101001010101010010101010001110100101010101001010101000111": TestData(n, 2) = "0"
  441.     n = n + 1: TestData(n, 1) = "10010101010100101010100011101001010101010010101010001110100101010101001010101000111010010101010100101010100011101001010101010010101010001110": TestData(n, 2) = "1"
  442.     n = n + 1: TestData(n, 1) = "00101010101001010101000111010010101010100101010100011101001010101010010101010001110100101010101001010101000111010010101010100101010100011101": TestData(n, 2) = "0"
  443.     n = n + 1: TestData(n, 1) = "01010101010010101010001110100101010101001010101000111010010101010100101010100011101001010101010010101010001110100101010101001010101000111010": TestData(n, 2) = "0"
  444.     n = n + 1: TestData(n, 1) = "10101010100101010100011101001010101010010101010001110100101010101001010101000111010010101010100101010100011101001010101010010101010001110100": TestData(n, 2) = "1"
  445.     n = n + 1: TestData(n, 1) = "01010101001010101000111010010101010100101010100011101001010101010010101010001110100101010101001010101000111010010101010100101010100011101001": TestData(n, 2) = "0"
  446.     n = n + 1: TestData(n, 1) = "10101010010101010001110100101010101001010101000111010010101010100101010100011101001010101010010101010001110100101010101001010101000111010010": TestData(n, 2) = "1"
  447.     n = n + 1: TestData(n, 1) = "01010100101010100011101001010101010010101010001110100101010101001010101000111010010101010100101010100011101001010101010010101010001110100101": TestData(n, 2) = "0"
  448.     n = n + 1: TestData(n, 1) = "10101001010101000111010010101010100101010100011101001010101010010101010001110100101010101001010101000111010010101010100101010100011101001010": TestData(n, 2) = "1"
  449.     n = n + 1: TestData(n, 1) = "01010010101010001110100101010101001010101000111010010101010100101010100011101001010101010010101010001110100101010101001010101000111010010101": TestData(n, 2) = "0"
  450.     n = n + 1: TestData(n, 1) = "10100101010100011101001010101010010101010001110100101010101001010101000111010010101010100101010100011101001010101010010101010001110100101010": TestData(n, 2) = "1"
  451.     n = n + 1: TestData(n, 1) = "01001010101000111010010101010100101010100011101001010101010010101010001110100101010101001010101000111010010101010100101010100011101001010101": TestData(n, 2) = "0"
  452.     n = n + 1: TestData(n, 1) = "10010101010001110100101010101001010101000111010010101010100101010100011101001010101010010101010001110100101010101001010101000111010010101010": TestData(n, 2) = "1"
  453.     n = n + 1: TestData(n, 1) = "00101010100011101001010101010010101010001110100101010101001010101000111010010101010100101010100011101001010101010010101010001110100101010101": TestData(n, 2) = "0"
  454.     n = n + 1: TestData(n, 1) = "01010101000111010010101010100101010100011101001010101010010101010001110100101010101001010101000111010010101010100101010100011101001010101010": TestData(n, 2) = "0"
  455.     n = n + 1: TestData(n, 1) = "10101010001110100101010101001010101000111010010101010100101010100011101001010101010010101010001110100101010101001010101000111010010101010100": TestData(n, 2) = "1"
  456.     n = n + 1: TestData(n, 1) = "01010100011101001010101010010101010001110100101010101001010101000111010010101010100101010100011101001010101010010101010001110100101010101001": TestData(n, 2) = "0"
  457.     n = n + 1: TestData(n, 1) = "10101000111010010101010100101010100011101001010101010010101010001110100101010101001010101000111010010101010100101010100011101001010101010010": TestData(n, 2) = "1"
  458.     n = n + 1: TestData(n, 1) = "01010001110100101010101001010101000111010010101010100101010100011101001010101010010101010001110100101010101001010101000111010010101010100101": TestData(n, 2) = "0"
  459.     n = n + 1: TestData(n, 1) = "10100011101001010101010010101010001110100101010101001010101000111010010101010100101010100011101001010101010010101010001110100101010101001010": TestData(n, 2) = "1"
  460.     n = n + 1: TestData(n, 1) = "01000111010010101010100101010100011101001010101010010101010001110100101010101001010101000111010010101010100101010100011101001010101010010101": TestData(n, 2) = "0"
  461.     n = n + 1: TestData(n, 1) = "10001110100101010101001010101000111010010101010100101010100011101001010101010010101010001110100101010101001010101000111010010101010100101010": TestData(n, 2) = "1"
  462.     n = n + 1: TestData(n, 1) = "00011101001010101010010101010001110100101010101001010101000111010010101010100101010100011101001010101010010101010001110100101010101001010101": TestData(n, 2) = "0"
  463.     n = n + 1: TestData(n, 1) = "00111010010101010100101010100011101001010101010010101010001110100101010101001010101000111010010101010100101010100011101001010101010010101010": TestData(n, 2) = "0"
  464.     n = n + 1: TestData(n, 1) = "01110100101010101001010101000111010010101010100101010100011101001010101010010101010001110100101010101001010101000111010010101010100101010100": TestData(n, 2) = "0"
  465.     n = n + 1: TestData(n, 1) = "11101001010101010010101010001110100101010101001010101000111010010101010100101010100011101001010101010010101010001110100101010101001010101000": TestData(n, 2) = "1"
  466.     n = n + 1: TestData(n, 1) = "11010010101010100101010100011101001010101010010101010001110100101010101001010101000111010010101010100101010100011101001010101010010101010001": TestData(n, 2) = "1"
  467.     n = n + 1: TestData(n, 1) = "10100101010101001010101000111010010101010100101010100011101001010101010010101010001110100101010101001010101000111010010101010100101010100011": TestData(n, 2) = "1"
  468.     '''
  469.     'n = 0
  470.     '''
  471.     ' Test: r1's custom quiz 1
  472.     n = n + 1: TestData(n, 1) = "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000": TestData(n, 2) = "0" '1
  473.     n = n + 1: TestData(n, 1) = "00000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000": TestData(n, 2) = "0" '
  474.     n = n + 1: TestData(n, 1) = "00000100000101110000001100010001100001001000000000000000001100000000000000000111001000000000000111100000000100111000000000000010000000001111000000000000000000000000000001010000000000000000010000000000000011000111100001000100000000000000000001101000000000000000001000110110000010000100000011001100001101001000000000000000000010000100001100011000101000000010000000000000000000000000000000000001000000000010000000000000001010000010000000000000000000000000000000000010000100000000000000001011010000000000": TestData(n, 2) = "0" '
  475.     n = n + 1: TestData(n, 1) = "00011101100000000001011100001011101000100111101100011000000011001010101000101000111111011000111000100000000000000110110000000001001001110110100001011011101100000011001010001111111110101100001101100001100011000111101100110000000101101101110000001110110111000011000110000000001101111000110000000011111100110001111000011101111101010011111111101111010011011001111101100010001100101101001011000010100111111101111010111111010110001100011000000100010001100111111001101101111000000010110111110000001011010011": TestData(n, 2) = "0" '
  476.     n = n + 1: TestData(n, 1) = "00000000100000000000110000000000000000010000000000000000010000000000000000001000000000000000000000000000000001000000010000000000000000000000000000000000000000000000000000011000000000000000001000000001000000000000000000000000000000000000000001001011001000000000000110000000000000000000000000000000000100010000000000000000000000000000000000001100000000000000000000000000000000100000000000000000001000000000000000000000000000000000000000000000100000000000000000100000000000000000000000000000000000000000": TestData(n, 2) = "0" '
  477.     n = n + 1: TestData(n, 1) = "01111011010110000100001000011001101101000011000011000000000100110010001010000100010000001110111000001000000000101110101100000000100011100101101110000010110101111001011010100000111011100110100001100100111010111110000010000110010000000100111100110000000101010100111001000000101000100101111001001001000010000100110011011010011011101000110011000000101000000100010000101101000101000110000100010101010111100000000001100000110010000001000011100001001000100000011100000101000001010101000100011010000100010011": TestData(n, 2) = "0" '
  478.     n = n + 1: TestData(n, 1) = "11000110011000111000001101000010001000001110001001110010000110000111010001010001100010101100001111100000111100101100000011000111101101110010101101010000101010000001111100000111110101010000000011011100100110101100111101000000100100101000011010000000010110101010011001110011111000010001100110001111111001100010011100010101001100000101010101100000000001001010000011011100010011001000001001110111100110010010000010000111111101100011010101010101000111010110101000000010001001001011011011100101111110110010": TestData(n, 2) = "0" '
  479.     n = n + 1: TestData(n, 1) = "10101101010001010110010110011111011111111101110100010011101110000000100011010000100111111001110110100011011110011101110001110011110000111011011110111011101100000010100111100010000010100111110010100100010001010101111000111010011101010111001110110000101101110001110010011101010110101110001111000101011001001101001011111101110010110101001100110010111101010111010010000010110100010001101110110101101110000101101010001001101101011000111110100000011101110010101111011110111110100110101001111101110001010110": TestData(n, 2) = "1" '
  480.     n = n + 1: TestData(n, 1) = "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000": TestData(n, 2) = "0" '
  481.     n = n + 1: TestData(n, 1) = "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000001000000000000000000000000000100000000000000000000000000000000000000000000000100000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000": TestData(n, 2) = "0" '10
  482.     n = n + 1: TestData(n, 1) = "00000110110101110000001100100101000001001111101111100000011000000000001001000100011000000000100011100000100000001001000001000010000000010111001101000001100000010101100011010011111000100111010000000000001010001011101110010100000000000010001011101000010000100000101100110100000011111000000001110000010101010000111111110000000110000100111110011000100000010001010100000000000110000000011000100000000111110011110010000100001010000010011100000000010001101010000000000110010000000110000000110011000000000000": TestData(n, 2) = "0" '
  483.     n = n + 1: TestData(n, 1) = "11011001010011000110101011011010000110001001010001001111100111001011110110111010001111010110010100100101011010110010010100111010111001101011100100001010011111111010011100101101000011011011000111011011010110111100110011100010100001101010110101110101110111010111010010011001110100011010011010101111101110100100100111101101001011100001001100100111010101100100101000111111111001001111100111010110111100001000000111101000111000001101011001001110001000010100110011111001001010101001110111010101111001100001": TestData(n, 2) = "0" '
  484.     n = n + 1: TestData(n, 1) = "00000000000000000000010000000001100000000000000000000001010000000000110010000000000000000000000000000000000000000000000000001100000000000111000101000000000000000000000000000100010001000000000000000000000000000000001100010010000000000000000001100000000000000000000000000001000000000000000000000000000000000010000011000000000000010000000000000001000000001000000000000000000000000000000000000100100000000000100000000000000000000000000000000000100000000000000000000000000000000000000000100000000000000000": TestData(n, 2) = "0" '
  485.     n = n + 1: TestData(n, 1) = "11101000011011010000101000100000010001001000000110011110001011010001001101101010001100111000000101001000011000001010010100010011100110101000101000000000010100111001010100010010101010100011000011000001011010000000010000000001011110110111000010000001011011100000000111001110100000110000000011000101100000001001000100110011000100100000100001001000000011010010100000000100100000101001100000110001001001110101010001000000011000000010101000110010000100001011000001101000101010011011001110010110000010000000": TestData(n, 2) = "0" '
  486.     n = n + 1: TestData(n, 1) = "00000010100110101001001000100000010100100100101101010010000001001100000000001011001110011011000010000111111001100010110011000010100110110000000000011010011010010100100011011011001100110001101001110000101001001100100010001101001000001011111100011011100000011001001010111000000000111101111001111001111111101000000000101100011001001011011010010000100001100010011110010000001011000001010111010010011111001001001110111100110010000110100111101000000101110100101010001111001111101100010101001001010101000101": TestData(n, 2) = "0" '
  487.     n = n + 1: TestData(n, 1) = "00111100000000000111001001100000111010010010010011100010001100001100000011011000100010000101110010110100110110011100010001111110011011000110010000001001101111111000011000010001101110011101111010100110100110000111011101001111110011011111100110111000001101101110001001001000011110100110000111110111010000001100100100100111110110100001001011100110111000100011110100100100110010011110011011100011101111010010000110000011101100000111001011000110000010001101111011111011001100000010000101000000000000101110": TestData(n, 2) = "0" '
  488.     n = n + 1: TestData(n, 1) = "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000": TestData(n, 2) = "0" '
  489.     n = n + 1: TestData(n, 1) = "00000000000000000000000000000000000000000100000000000000000000000010000000000000001000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000": TestData(n, 2) = "0" '
  490.     n = n + 1: TestData(n, 1) = "00000000010111101100110000001011000001001011001100000001001100001001000001001100010000111111000011100001000000001111010010000100001000000010001101001011101011011010000101010011110110110001100001000010000010100011000000110001000000011101110001000000000000110000100000101100000001011010000101000000100100011000111111110010110101010100011110100110110000010001101000000000101001000010100110000100010100111000010010100100001000110000000100010100010000000010000100011100010010110100010000010010001001000010": TestData(n, 2) = "0" '
  491.     n = n + 1: TestData(n, 1) = "11111111011001010010001100000100110110101110100011010010111011110100101000100000000101100000000100110010111110111000110101101010111111011101101010011111100100110100010011011001100000001110111110000101000000001100110101011110011111101100001110011101111100111100011100010010110111100001010000010001101001001111000000000101001000100100000110011000101011100100000100111011010110100000010001011010101011010010100111011000100011001000001010001011101010000100001011001011100001001011101110100110110010111100": TestData(n, 2) = "1" '20
  492.     n = n + 1: TestData(n, 1) = "00000000000000000000000000010000000000000000000000000000000100000000100000000000000000000011100000000000000000000000000001000000000000000000000000000011001000000000000100000000000000000000000000010010000000000000000000000000000000000000000000000000000000000000000000000000000010001000000000000000000000000000000000000010000000000000000000000010000000000000000000000000000000000000000000000001001000000000011100000000000000001000000000000000000100000000100010000110100000000000000000000000000000000000": TestData(n, 2) = "0" '
  493.     n = n + 1: TestData(n, 1) = "01011000100010001000011010000010010010000100100101000100011001000010000010110110010110001100010001000010110110000011010100000100100010010011111101111100110010101100000001000000100111010000010000100000000111100110000101110001100100000001000001001100100100010000001001000110000000000100011100110110000101100011100010110100000011001001011000010001001000101010010010000001000000100101100101001110110010010000100010100010000000100111001100000000001000111111010100001000001010000010101010110101101000001100": TestData(n, 2) = "0" '
  494.     n = n + 1: TestData(n, 1) = "00000101000010010110000110001101111110010001110010000010101001111111010000011011100000110000010101101110101111110101001100000100000000100110001000000000000001110011101011011110000001000110101001000000000000010100010010110110000010001100100010011001010011111011001110110000110100010010000010010110011000010110110010101000111000000100000001101100100110010100110111001110110101010001101100000000110010100010000001000101011100000000000111101110101011001011001100100000001101110000001001101010000000111011": TestData(n, 2) = "0" '
  495.     n = n + 1: TestData(n, 1) = "10100010000111100111110001101101100001100111001010011110011001101110100111000111001010100111100010110010101010100100100000101010111100100000010111001000101110010010111000001100011011001011010100101101101110001001111100110000001011100000010110011010001000001101101111001000011101001000110010110111100011111011001100011110100110100111001110000101010001010001101001101001011001111010011001101010000001111010110011100001010100011100110100011011110011100101000001110010010111100111110011001110011111001010": TestData(n, 2) = "1" '
  496.     n = n + 1: TestData(n, 1) = "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000": TestData(n, 2) = "0" '
  497.     n = n + 1: TestData(n, 1) = "00000000000000000000000000000000000000000100000000000001100000000000000000000000000000000000000000010000000000000000000000000000000001000000000000000000000000000000000001000000000000100000000000000000000000000000000000000000000000001100000000000000000000000000000000000000000000000000000000000000000000000000110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000": TestData(n, 2) = "0" '
  498.     n = n + 1: TestData(n, 1) = "00100000011101101100000000000000000000001010001010001010010000000011101000010100001000000110000110100000000010001000111100100100001010110000011000001010110100110011000010001000110101001001100001011000001000000000000010110000100000110000001001000000100000110100100100100001010011000000010101010010100101000000001011100010000000001100000110100010100010000001110000000100000001110010100100001110000001100110000100001000001000000000010000001000001000000001001100000000010011110100000000001010100001111111": TestData(n, 2) = "0" '
  499.     n = n + 1: TestData(n, 1) = "01010110100011101001111011101011111111101001100000010100001001111110010111100011101100011111110001101101111000110011010011010011110000101111110110010001000001010100100100110011010010010110101011100000111111111101111110110011111101010011110000111101000010010011010000011100001000011011000011001101100011011101000101010101111011000100001111010100111001011100011100011011011000000010011010010100110010011001111011010010110011111000101110010111111100100100111110111010101001101011010100000001011010010000": TestData(n, 2) = "1" '
  500.     n = n + 1: TestData(n, 1) = "00000000000000000000000000000000000000000000000000000000000000000000000000000100000001000000000000000000000000000000000000000001000000000000000000000000000000000000000010000000000000010010100000000000001000000000001000100000000000000000000001000000000000000000000000000000010000000010000000000000000000000001000000010000000000000000000000000000000000000000010000000110000000000000000000000001000000000010000100000000000000000100000001000000010000000000000000000000010000000000000000001000000000000000": TestData(n, 2) = "0" '
  501.     n = n + 1: TestData(n, 1) = "00000001100010111010101010001001000011001100000000000000010011000111001101001010110010010010010100101010000001001000111000000010110000010001001110100000000101101001110100010100000101000100000101000000010000110000010011010000100101001111000000011110001000001101101100000001000101000000011001011001110111100010010001000011110011110010010001000001110100100010101001110000010100000010010100000000101001000100101000011000000001001010111010110100000011001100101010000000100100100111111001110101000100000001": TestData(n, 2) = "0" '30
  502.     n = n + 1: TestData(n, 1) = "11010010010101000010000011010000101110111010011001101000101111011101001110000001011110100101101111000100000010110001010101000110100001100000111000111100011110110011101101101111101010100100011101000000010010101110000011011100010010101110101010000001110001001111110011011101000010110000101111000000101100011100101100001001100001111110000101110000010010000001001010000000011011000001000101000100000111101100110011000111010000001000010000000000100101010001100001011000001010001000111111110110101000011111": TestData(n, 2) = "0" '
  503.     n = n + 1: TestData(n, 1) = "11011111000111100000010011111111101111001100100010111010010000011000110100111010011000111101000111010000110110101010011010101011100110011101000001011011111110011100110100001001010000001000010010100101111011000101001000000011110011110001100100100011011001010000101101111110101011011100000111000111000011110101111011101000101010000111011110000111111101011101110110001000011000111011011011111100110000001011011010110101101111011001011000111100101100111010011100110111101100110110100110000010011111110101": TestData(n, 2) = "0" '
  504.     n = n + 1: TestData(n, 1) = "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000": TestData(n, 2) = "0" '
  505.     n = n + 1: TestData(n, 1) = "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000": TestData(n, 2) = "0" '
  506.     n = n + 1: TestData(n, 1) = "00100000000000000011000000000000000000000110000010011111100000000000000001000000001000000000000000010110000110000001100010000000000011110000000001100000000000110011000011000000010000001110000000011000001000010000110100000010000000111101000000000000000000100000000001100000100011000000000100000000000101000000000011010000001100010100000110110010100001010000110000001000000001100000110000001100000000011010000000000000101001100000000000000000100000011010100000000010010000100100010000000000000001111000": TestData(n, 2) = "0" '
  507.     n = n + 1: TestData(n, 1) = "00010100011101010101100000101000001100111001101101000000011001111001100110110111010111111011110001100000000001100000011001111000111001000110011010001110100110011001110111100000101000110001100110100111000111001000001001110101101110000000110000000000011001010101000110011101011001100011001001011001101100011110000101101001100011001010011000001100110000101000001111110110000000001100001100010010101111100101001101010000000110011011111100011111010000000101000000100101100111010110001101111010101010000110": TestData(n, 2) = "1" '
  508.     n = n + 1: TestData(n, 1) = "00000010000000000001100000000000000001000000000000000000000000000000000000000000000001001000000000000000000100000000000000000000010000000000000000100100000101000001000000100001100000000000000000000000000010110000000000000000100001000000000000001000000001100010000000010000010000000000000110000000001000000000001000010000000000010000000000000000000000000000000000000100001000000000000100001000000000000000000100000000000100000000000000000000000001001000000000000000000001000010000000000010000011000000": TestData(n, 2) = "0" '
  509.     n = n + 1: TestData(n, 1) = "11010000111110000000000011000001011000010011010100100000000000110011011101010010100100000000000000010001101001000001001010011000100101101000111011000001000010010000010000010100001000100110100001100100001001001001100011110010011000110111000011000000011000000000100110001000101101100000001000000000000100000000000001001110001110100000010100001011101010110100001001001000000010010100001010100111011111000100001010000011010001000011001101110001101110000011010101101001010100110100010001011100110100110111": TestData(n, 2) = "1" '
  510.     n = n + 1: TestData(n, 1) = "00000000110110001000000011001000100000001110011010100010101101111100101100101000001010000000101101010100101011010000010001001110001001100001110101011010111010000100001011001010010100011001011000010000100001000000000100001111001000101011111110100001110010011000100001101000101001101011110001011111000110111010010101000001001011101101110000001011110000011001100011111001010100010101110011000100110000101101010010110000000000010011001001101101000010000010001110000011111100111101100100110000001000110000": TestData(n, 2) = "0" '
  511.     n = n + 1: TestData(n, 1) = "00101101111001100011001000011101001000000001100000101001000010110101000011001101110010110011000010101100111010101111100101100111000010110111010100000000001010000111111011001000111011100100011111101010010101011111111010010110010001101010100101010110111010111000101111001101001101101111010101010010110001000110110110101000010100001000010011101010011110001000001111001100110001011010100011101011100000100000111001000111001010101111010010010100110111001000100011010110100011111011101001101010111101101010": TestData(n, 2) = "0" '40
  512.     n = n + 1: TestData(n, 1) = "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000": TestData(n, 2) = "0" '
  513.     n = n + 1: TestData(n, 1) = "10000000100000000000000001001001000000100011010001010100000100000000010101100110101000000000000100000101010000000101000000000101100000000000010000001000001011000110100110100010010100010111000100000100001010000000101010001000111001000000010000100100000000000000100000001001000000110001010001001010010000000010101001000111011000100100100000010010000100100000000000001000010010000110010110000110100000000000101001010100000110010001110000111000000110000000000000000000000100101100001010000100000101100010": TestData(n, 2) = "0" '
  514.     n = n + 1: TestData(n, 1) = "00001101011011101101111110010000011011010000101110101011001001111000101010010001010111100001110011011010100011011010101010111010001010100110101100000110110100101001011001010000001010100000111010111011100100110111010101010100000010000010101110001011010011001111011110110000110010001010001000110100101111101100000110111000000000000010001111101001011011010111110110000100101000111000101001110001010011110100010100100011110000001100001011000100100000011110111111100011000011000011100101111010111010010101": TestData(n, 2) = "1" '
  515.     n = n + 1: TestData(n, 1) = "01110011000100111110101110110110101110011100101000000011111010011111101010001000000000111110011010111010001110111000111111010010011101111101100111110001000000011000001000001101101001001000010001011000010001111100010001100111000100111111100011010001101101110110000001010110001111000100101110010001101101010001010110110000100111011001010100101101110000001111001111110111100101101001001001111001011111111011000010101001001001101010001111000011011001111111001011111101111001010010110000100001010000011000": TestData(n, 2) = "0" '
  516.     '''
  517.     n = 0
  518.     '''
  519.     ' Test: r1's custom quiz 2
  520.     n = n + 1: TestData(n, 1) = "10000001001000000000000011000000000011010100000100010100010111001001000011100000000000101000000000000000000100000011000011010001000000010000000001001000001000000000000100000100000101001000010000000000100011001101010000000010000100010000001001000000010000010000010000010001100000010010000000000110110110000100110010000000000100000001001111110010011001000011000001101010001111111010101000010111111110000000000101000000000010001010101011000001101001000010000000010110001001000010010100010101000000011101": TestData(n, 2) = "?"
  521.     n = n + 1: TestData(n, 1) = "10001000000000000000000100101000000000001100000000010000100000000000000011100000000010000100000000000101000100000000000011000000000000110000000000000100100000000000000100000011000000000000000000000000000000001001100000000100100100000000000000000100010000000000000000000000000000000000000000000001001000000000000000111000000000000000000000000010001011010010000000000000000100010101001000001000010010000100000001000001000100010000000001000000110000000000000011000000000000000000000100000000000000001000": TestData(n, 2) = "?"
  522.     n = n + 1: TestData(n, 1) = "00001000000000000100000000000000010001000000000000000000000001100011000000000010000000001000101000000101000000000100000110000000001000000000010100000000000000100001010100000000000000000000110000010010000100000101000000000100100000000100010000110000010101000000010000000001000000000100001000000111000100000000000000000100000001000001000000000000000000000000000000000000100010000100000000100000001000000100000000000000100000001010000000000000000101000000000010000100000001100000000000000001000000000001": TestData(n, 2) = "?"
  523.     n = n + 1: TestData(n, 1) = "00001000000000000000000000000000100000000000010010000000000000000000100000001000000001000000000000000000000001100000001100011001010000000000000000000000000100000001000000001001100010000000100000000100000001000000001001000001010000000000000000001000000000011000000000000000001100000000000001000000111000000010000000000000000000000101000000010000000000100000000000001000110100000000001000101000010000000000000000000000000000000000000000101000000000101010000010010000001000001000000000000000000100010000": TestData(n, 2) = "?"
  524.     n = n + 1: TestData(n, 1) = "00001001111110110001110000000100000110000100000001000000100000010000111000001000001101000001001000000000000000101000110000001011100000100000110000001000000000100001100000010010011100000011100001000110001001000011001011000100010110000110000100111110111011001100000000000000000010000000011100000010000000000000000000111001010001000100000000001010001010000000000000000010101000001000011110100010000100010000001100100001000100000000111000011000000000000000000000010101011010001111000101000000100100110000": TestData(n, 2) = "?"
  525.     n = n + 1: TestData(n, 1) = "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000": TestData(n, 2) = "?"
  526.     n = n + 1: TestData(n, 1) = "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000": TestData(n, 2) = "?"
  527.     n = n + 1: TestData(n, 1) = "00000001111000110110101000011001001111110101101100011010111100111010100101001010001001100100000100001011000100000100000110000110110000000100101001110001101001110010001000100010110000000110010010101010001000000110100000001001011100001000000100001011111010011011000000000110111100100000010000100001110000010000000000110001111110001100010111000100100001000011000010101110000001000000001101101001111000000010011000000110001000011100111011011000100100000000110000010010110011010110000110011010000010010110": TestData(n, 2) = "?"
  528.     n = n + 1: TestData(n, 1) = "10001110100010001000100001110001001101100010100100111001000000001001100000001000111000001000001100001110010000000001001111000011110101100111001001111011101010110100001001001100100100001101000111010001111110101010101101000101011011111001010110000001010000000000111100100111011001010110000010001110010000001000111110011101111100111000000001100101000000000101111111100011001100111100101011101010011110000010011110001011110011101100010101110000100000011001000011001001010101110110101100111000000010000100": TestData(n, 2) = "?"
  529.     n = n + 1: TestData(n, 1) = "00111001100110011100000000000000001000100100010100100010001101000111011100100010001111100000000110000001000001111001000100000101010011101000001000110100011111110001000110001101110000000010101100000111000001100110011111110000000000000100100000000110101001010110000000011100000010110100110000000110000000001010000101000001000000100000100010000000000100000011000000000010010100010001101100110010101010000010111100000111111100000001001010001001001000000000111000010011010011000000001101000000000010000011": TestData(n, 2) = "?"
  530.     n = n + 1: TestData(n, 1) = "10000101100000010101000111000110011000100100000101000011001110000010000100000111001001100000011100000101001000000000111100000100011000000010001100111000001001110100100000010000110011110011000000000010100100010111000000000000000010010000010001010010101100110010000000100101000001101001010010000000000010000001110010000011000000010010001010000010011000011111101100000010100000001110011110100000101001011111011001100110001000100000001110001000010000000001110001010010010011100000000100100100110011000010": TestData(n, 2) = "?"
  531.     n = n + 1: TestData(n, 1) = "01011100011100011000100100011010011000010011000011101100110010000000011000001100111001010010001001001101010101100100100011111110110111111111001011111011011001110011011000010001100100101100000111101001000100111110010110110101001000011011110101010010010001111011101111111100110000111110011001001111110111010000010110001001000101001100001101010010000000000110011110100001100000010000011001110110110010011000100000000110001001000001100000011001001100100100100011010001111100011001111101100000111100000000": TestData(n, 2) = "?"
  532.     n = n + 1: TestData(n, 1) = "00110000100010000000100000000101000100000000000000000010000000100000110000101000110000100010000000001000100100000101000010110101001101100010001000100100010000000000000000000000100100011001001010001010000010010000000100001001000010000001010110010000100011010000100011010110110100100100001000000010110100000001010010000001111110000000100100100000001101000110111100011101001110010010001010110000000011110001101000000001110000100010100000010001000010001000100000010000000000000000000010011001011000010100": TestData(n, 2) = "?"
  533.     n = n + 1: TestData(n, 1) = "10110010010010010000110011100101010001001001100011000001000010011000101001100000110110000000100011111000011000000111111000001000011011010111000000010001000101001110010001101101011001010001000110000010000110010100010000011001010000100000101100011100000110001001100111100110000110100010100000011000111100111010010100011000000000011000010111100000100001010100011110100000000000101101110010000000100110100001110000001110001000100000000000010010001100000000111100000001000000000000000000000000001001000000": TestData(n, 2) = "?"
  534.     n = n + 1: TestData(n, 1) = "11010000100101101011010111010110101110101000001101001011100000111001010001100000101100110000010111000100100101110100001101111001011011001100110101111100010010111100010010111111010001111110010011110000110011110011010011010101100001101010011110101001110001100011001110111110011111111101100001100000011000000101101100111100011010001011010101001010000101010011000010011011010110110111011110000001110010100010000000101111101011101111000101010001011111100100101000011001011001101111101100010111010100111001": TestData(n, 2) = "?"
  535.     n = n + 1: TestData(n, 1) = "00000000001110011101011110000001110100101110110111000101111000011010101110010001100110001000111101100010101110100010010110101110110110110001001001010010000011101111010010110010000110001000100001111110100001100000101011011000001100001011110001110100111010101110001011110000001111110101010101100101000001101010101001010010100001001000101000011000111101100111101001001010110010000100111010011010111010000100001011010101111111100100111101011001100111110010011110011100011110001110001001011000011010001101": TestData(n, 2) = "?"
  536.     n = n + 1: TestData(n, 1) = "10001001110000001000010001011011000100011010010101101011010100011001000011010101101100011011000111010111100010110011001001101011100111101101001000100100101111011100001100100100010000001100000010000010011101001010001011100011100001001000010000100010001001111000000010001101000001001110000110011110011100011011001110101000101001111111001010111000111011100110110011111011010111000011100001111110110101010111010110100000110110010110010100011000111110111101110011001111111000011111111001111001001101011111": TestData(n, 2) = "?"
  537.     n = n + 1: TestData(n, 1) = "10010011010111111001010001110000011011100100100110011110011111010011011111111101111001100001100110100100100110011111111100011011100010011011110010010100010100000000010010001111001001110010111100001001010111110010110111111100110001010011010100001111101011100110010111110111110000111100110101001010111001101011001001000101100001000110111100010111001001001001101011000110001011100011100010110000111101111101100100100011101100011011110011110000111100001100001100100011000111110000100000110101100011001011": TestData(n, 2) = "?"
  538.     n = n + 1: TestData(n, 1) = "01111000000111010111111100110100011010111011110101000111000101111000111111100011010010001111001010111100111101101010000101110101000010101100001111010101011110011001011011100001110101101011111001010111001101110001110011111111100011000110100011111101000010100101010001001100101000100001000100000010101100011111001110101101111001111001110100011001101011001100111001100000010111000111000011001000011001000010011101011101110101010010110010111110111111010101100001111110011110011000010011000010010000110000": TestData(n, 2) = "?"
  539.     n = n + 1: TestData(n, 1) = "11100101001100110010000000001111111011001011100100111101110111101000111000110110001100101000101110100101001000011011000111010110011101100010000100111010111010011010010010101110111011110010110110011001110101100111100010100010101000100001000100001000100101010101001111010111110101100101100111010110100100111000010101001101011100010110000000100110111100101111100001010011001100000100010101111111110110010111011011011001010111011100001001110010100100110110110101001101000001011001110111010110100000111010": TestData(n, 2) = "?"
  540.     n = n + 1: TestData(n, 1) = "00101011100010110100010101100110110111001111000100100110011111000001101011100001110110100001110011111101001000100100010111000111110110001101101000101100011111101001010010001000111111110111011001100011011011010110000101101100100100011011101001011010101001100011111101110101111111010001010001001100110100100000011100111101110010011000011001001000001110001001010010101010000110101001011010100100111011010011011110101110110100010001000100100011000011110111111011000011101101100111101111100011000011010111": TestData(n, 2) = "?"
  541.     n = n + 1: TestData(n, 1) = "00000100100101110000110100100011111110100110000101010001100010000000111111000111010011111111111110011000010011010111011010101101011011011010011000100100101100010110111011000111001110011110001111100000101101100001100011111010010100110100111010100101011100100001100111111010001100000001100010001000111110101000010000100100110010101111110011111111001111111101001000111100100100111100001111101000111110011111001111111001110100101001000011100010001010100110101011011001000001111010101100100110001011110111": TestData(n, 2) = "?"
  542.     n = n + 1: TestData(n, 1) = "00000111111000010000101100011100110000100010111111110111011110010011000011110000001110000110001101101011010111010001100011000101100011111100010000010101010111111111010100000110111010001001100110111100011111000100101111111100010100110110100000101110010101000000000010000111111101011111111101110110111110111111111001101110100100110111101110111001100000100011011111010000101110011010111100000110100010110010001101001010100010000000101111110000111000001000010001000100010110011011111011101110100001101010": TestData(n, 2) = "?"
  543.     n = n + 1: TestData(n, 1) = "10101101001001011100001000001110010001110011001011000111110010110110100011111111111001010000101010011110011110110010010001011010011111101000011001111100000011001011011001001110110000101001011000100111100011000111110011100000010011000000101001010011000111100000111000101110110111100001110000101011010001101010101101101110011011111100111001010100011000111011101111011111011101010000100100000100110101111100000101000000001001001110000111100100111011011100101101010110100101110101010111001010110010100011": TestData(n, 2) = "?"
  544.     n = n + 1: TestData(n, 1) = "00111100000001100110111100111110110100001000001111100110011111100111110001100001100100110110000000011111110010111000111000101000000010000101011001010000011010110001111000010010010010000111010100110011000001000011110110110010010010011111111111111001100100010111101010000001100110010000110011000101000100001000001111010010101100001000101010101101001100000000001001101001011110001100100000000001110011111000100110101010000001111111111010001001011000100010000000100001000100011000100000110100101011000010": TestData(n, 2) = "?"
  545.     n = n + 1: TestData(n, 1) = "00001100001100010100000100001111110011001111010000111001001111100010101101011000101100010010101010000011010111100100101100001110011001100000001011000111010000111000001100010000000100100111000100100000010101110100010000101010101110111011101001111000010110111110010000110110001010001111100101100011101010011010100110000101010110010100111101100100011000001011111110111001001101100000000001010011000010100000011001001011110000000000010100000000000100111110001000100101000100000000001000001001110000000000": TestData(n, 2) = "?"
  546.     n = n + 1: TestData(n, 1) = "00010011100000101100010001010000111100001100101110110011000111111001111001111000010001011110111010100110101111100100111110000000001111010001100011100001101110100011010000010001111111000001111111010111001111001111111001000010000101101101000100100000011111011000011100100011001100110010000001000111111110100011111010101011000101111110000011001010101100100001001111001001000011111111010011110000110010100101111100110100111111011000110010010111000000010010001010010000110101100111110100100010011100110010": TestData(n, 2) = "?"
  547.     n = n + 1: TestData(n, 1) = "10011100100001100111000000111010000100000000010000011011000010100001110000110000110100001000001000011001011110010000001001000111000100100001000000111001100000100011000000000000000011000000101011010100101000000010010100010000011000011100000111000010100110101010010111010000010000110000010000000110010001000001100100000001001000110100011010101001000010100100000001001000100010100010111010010100010111100011000001101100000011001110100010010001001100110001000010001010001000010111000010010000111001011000": TestData(n, 2) = "?"
  548.     n = n + 1: TestData(n, 1) = "01001001001000000100101111110000000010011000000110011101110111111001100011100001000000101000000000000110001111001011010010110011101110010000001001001000000000000000000101000000010001111000011000010000000011001100110000000011100100100011001111000100100010011100010010010111110100010010000111001110011110010000110010100000000001001011001111110010001001011110000000011011001111111100100000110111111110000000111001000000000010111010101011000011111001110010000010011010001001110001011100010110000001111101": TestData(n, 2) = "?"
  549.     n = n + 1: TestData(n, 1) = "10011000000000000100000010101001000000001100100000011001100011010001000011101000110010000100001000000000100100000000000011000000000000110000010100010100000000100000010110000011010000000000110000000000000000001001100000000100010000100000000100000100010000000000100010011110100100000000000000000001001001000100000000001000000000000000000000000000001011010010000000011000101000010101001000101000010110000100100101000001100000000000001011000000000010000000000011000111000000000010100100000100000001001000": TestData(n, 2) = "?"
  550.     n = n + 1: TestData(n, 1) = "00001000100000100000000000001100000001000011100111101000000001100011111000001010110000000100101000000000100001000100101110000000001000110000010100001000100000100001110100000000000100000000000001010010011101010101001000000100100000110000110000110000010001000000010000000001000000000100000010001111000111000000000000100100001001000101100000000010000001000000000001000000100010000100000000100000001100000111000000010001110010011010000000000000001101000010000010000100000011110000100000000001000000000001": TestData(n, 2) = "?"
  551.     n = n + 1: TestData(n, 1) = "00001000001011110101000000001000101000100000010110110000000001100000111000001000101001000000000000001100100001100000101100011001000001110000010001001000100100000011110011001000000100000000010001000110000001000101001001001001010000110100000100101110010000011000000000010000001100100000010000000000111000001010000000000100001000000110000100010100001001100000000000001000000100000000001000101000010000000100000001110010000100000000000000011000000001101010000010000000001010001000010010000000100100010000": TestData(n, 2) = "?"
  552.     n = n + 1: TestData(n, 1) = "00001010101000010001100100000100000110111110000001111100000001110000001000000010111101010011000000000010100001110000110010011111100000000000111000011100100000100001100001000010011000000111100001010010011001010011001110001000010000000111010100011001111111111100010000100010000100000000111001000011000000100110000000111000111110000100001000100110100010001001100100001000111000001000011110000111100100011100001000000001000100000110011000011000000001000010000000110011111010111110000101010001110100110000": TestData(n, 2) = "?"
  553.     n = n + 1: TestData(n, 1) = "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000": TestData(n, 2) = "?"
  554.     n = n + 1: TestData(n, 1) = "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000": TestData(n, 2) = "?"
  555.     n = n + 1: TestData(n, 1) = "00000000000000000000000000000000000000000000100100000000010100000000001000000000000010001010000100000000000100000010000000000100000000001101000001010000100000000000010000000000000000000000000000000000000011000000000000100000000000000000000000000000001000000000000000010000100000000000000000000000010000001000000100000000000000000000001000000000001000000000000000000000000100000000000000000000001010000000000000000100010001001000000100100000001100000000000000000000000001000000100000000000000000000100": TestData(n, 2) = "?"
  556.     n = n + 1: TestData(n, 1) = "10000101000000000001000000000010000000001000000000000110100000000010000111100000000000000000000000000000000100000000000000001000110100100000001000001000000000001000001000000000000000000110000010000000000000000000000000100000000000000011000000000000001000000000000000000000000001000000000011000000000100001000000000000000000001000000010000000000001001010000000000000000000000000100100000000000000000000100000000100010001000000000010001000001000000000000100000000000011110011000000000000000100000001000": TestData(n, 2) = "?"
  557.     n = n + 1: TestData(n, 1) = "00000000000000001000000100000000100000000000000000000000000000000000000000110001000110000000101000001000000010010000000000010000000010000000000000000000000000000001000010000000100000100000000000000000000100100000100001000000100000000010000000000000000001000100010010000010000100000000000000000010000000010000000001000000100001000000000000000000000000000000000100100000100010010000000100000000100000000100000000100000000000000100000000010000100001000000000100000000000000000000000000000110000000000000": TestData(n, 2) = "?"
  558.     n = n + 1: TestData(n, 1) = "00000000000000000000000000100000000000000000000000000000110000001000000001000000000000000000000010000000010000000001001000000001100000000000000000000000000100000001000000001000001000000000000000000000000001000000100000000000000000000000000001011000000000000010000000000100000000001001000000001000010110000000100000000000000000000000000000000000000000000000010000000100000010000000001000000100100000000000000000000000000000000000000001000000101000001000100000000010000000001000101000000100000001001000": TestData(n, 2) = "?"
  559.     n = n + 1: TestData(n, 1) = "00000000100000010000000000000000000000000000001011000000010000000001000000000001000100000000010010000000000010000000000001000000010000000010010000100000001010000100010000000001000000000000100000000000000001000000000010010000010000000010101000001000000000000000000000011000000000000000000000000000100000000000000000000000000000001000000101000000000000000000000000000000000000000000000000000000010000000010001000000000000000000000000000000010001010100000000001011000010001001010001010000000000000000000": TestData(n, 2) = "?"
  560.     n = n + 1: TestData(n, 1) = "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000": TestData(n, 2) = "?"
  561.     n = n + 1: TestData(n, 1) = "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000": TestData(n, 2) = "?"
  562.     n = n + 1: TestData(n, 1) = "11110101001000011101011111110011000011111100111111111110011111111111101011101000001110011111001111000011000100000111111111110011110010000001101011111010111001000000010111001111110101111000111001010000110011001111110000100111100100110011111111110011011010011100100111111111110100011110000111001111111111110110110010010000111101011111111111110010011111111111000101111110101111111111111000110111111110000111111111101011000101111001101011000011111111110010000011110110001101110010011100010111100110001101": TestData(n, 2) = "?"
  563.     n = n + 1: TestData(n, 1) = "01000110000100000101000001010000011010010000000000011000010110000001001010010110000000001000010000011010000100000011010010001001000010000010011001001110000000001010010001010000010110001011111111000100000010000000011000010000100100000100000000001000010001000010001010010000100100100001000000000000010100110101001000000111000001001000001000011001001001000010011000000010110110010000100001010110111011000000100000000000100100001100011000000101101001000010110100010010001101010000010011110000000000001100": TestData(n, 2) = "?"
  564.     n = n + 1: TestData(n, 1) = "00101001011000000000110000110100010000100000000011000110110000100000100000100011000101000100001000011000001110000101000100011010110000001110010100000110000011000000000010010011000000000000010000010110000010001000100110110101000000000000000010000000100000100001001001010000010100111000110100000001010000000000011101010001010000000001110000000000001010001001011100000001000100000100100001010001000010111100000000000101100001001000000100000000000000100000000000111000001000001000000001100000110100001001": TestData(n, 2) = "?"
  565.     n = n + 1: TestData(n, 1) = "00101101000010000110000001100000110000000100000000010010000000000100100001001001000000000000000001001000000100000010011000000000000000000001000101100000101100001010001100001000001000110100101001110001011000000000000000101000100111100100000000010001001110001001010010000000000000100011010000011100000001000000001010110100000101000000001000000000011000010011011100000010100100100000000000000000001001001110000001010000100000010000000000000100100110011100100010100010000110001001000101100001001010100010": TestData(n, 2) = "?"
  566.     n = n + 1: TestData(n, 1) = "00000100010110011000000000100100010000000100000001010000111000010100000010001100000010100000110100100100010000011001001001000000001101000000001010101001100001000100010100101001000001001000010000000000100000100100000001010000010101010000000110000101000000000010000001011100000111000100010100000110000011010000100000000001010010100100000010100000011000000010100100011000100000000000000000001000000000001110101101010010000000011000100000000101000010110110110000010001100010000001001100000010011000001000": TestData(n, 2) = "?"
  567.     n = n + 1: TestData(n, 1) = "01000000000000000100001001010000011110101010100001001000000000000100010100000010000100000100000011001000000001101010100001011100000100011100011000000110000100000010010000001000100100000001101001011010000000101000010000000000011010000001101000000010001000000000010110001100000010110001011000000001010100010000000010010100100100100010010000010011000001000000110000101100110010110000000011000000101010000000000011001010000001010110010001000000111010100110000010001001000100100000000001110001100000000000": TestData(n, 2) = "?"
  568.     n = n + 1: TestData(n, 1) = "10000000000100001110001001011001100101100000000100000010000011010001000110010010101011000001000000101001000100000000000000110000000000100000000001001010001010100001000001000100100110100011010000001001000010000000010000000000110101000000000010000000100000000100000100000000010100000000000000000000100011000110111000100000110000001010000100000100010001101101111010000001100000000000000000010001001101000101100000000010100000001001000000000000000000001001000110000000010001000000000111001000001001000100": TestData(n, 2) = "?"
  569.     n = n + 1: TestData(n, 1) = "00010001111000000010010000000001000000101000000100011000010001011001100010110011100000000011001000000100000010010100000001000110010010000000010010011101001001101000000010000001000010011001100101000001000110001010000010010010010100101001010000001000001101000101101100000100100010101010000001000000000000010001000000000000100010010100000000100100001001000001100000011111011100100001000000100000000010000000001001000010001000000010000010101010011110000000000001000001000011000000001000000000000001000001": TestData(n, 2) = "?"
  570.     n = n + 1: TestData(n, 1) = "00000111001100000000100100010000000100000111100100010000100001010110000000000000000000000000000110000100110100010010001000001000000010000001010001101110110100000001000001000001100100101010000001100001110000000000101100000000000000010000001000000000111000000010000010101010001000110000000000000010100110000000000000010010000101010000000000000010010000010101110000100100000000100010100000001101000001010010000000000000001001000101010001100001000001010000000001001000000010110010000010000000010100100010": TestData(n, 2) = "?"
  571.     n = n + 1: TestData(n, 1) = "00000000001100001001010000001000000101011100100101001011110010001001000001011010000010000000100100001010010001111001000100000000000010000000010000000010000000000001010000100000010010100100000001000101010100100000110011100000000010010010001100000000101010100000100000001001110000000100010000100101010101100100011000100100001001000000101110010000010000000000001000000000101010001001010011100000000100010000000000100000101000000100000000011001000100001000000000010000001110001000000000100010011010010110": TestData(n, 2) = "?"
  572.     n = n + 1: TestData(n, 1) = "00010001000000000101011010001010000001000001010100000000001011000010000000000000000001010000100001000101010101100100010011100100100000000000100000001000000000000100010100000000000110000010010000000110000100001100110101110000110001000100110000010000010000011000000010100000100001010100010110001000100000000001000000000000001000110000001001000111010000010100011000000010010000000101000000000011001001101100001000000010000000000000000000000011101000000110000000110010010000110000001000000000100010000001": TestData(n, 2) = "?"
  573.     n = n + 1: TestData(n, 1) = "00000000000110100000100011000000100000100100000000000000011011100000010101100001101010110000000000000000000000111101001001100110001000110001001101000101010000110010010001000000010001000000001000011000000000000000000010000000000001000100000001010010000001000001000101111110000100010010000010011010000000000000100100001001010100001000010100001001000100101000001000000001000000010101000100000010000001110000000000000000001011000011001000010000001110001001000101011110011010000101000000000000000110000000": TestData(n, 2) = "?"
  574.     n = n + 1: TestData(n, 1) = "00010000100010110000000010111001000111010001000000001000100010000100001010010000000001101010000010000001000000000011000010000000010100100100010000110100000100001001100011010010000000011110100010111010110001110000100000100100000100000000010000000000000000110001001010000000000000100100010001110001110000010101010000001010000011101101011010000000001000110000000110110001001100101010000100000001010110001011001100010010000010100011100100001001100000011110000000110001110001100100000100101000101000010000": TestData(n, 2) = "?"
  575.     n = n + 1: TestData(n, 1) = "00110000000000000000000000000010100000000001000000000000000001000000001000111000000100000000100000010001000000000010000010011110010100011110000010000000000000000000000000010010010000000001000000000000000000000000000000010011010000000000110000000001010001010110000000100000000000010010000000000111100000000000010000000000100000001010000000000001000010001110001001010100000000000000000100000000000000001000000010011000000000000000001000011010000000011100000001100000000100110000000100100101011100100100": TestData(n, 2) = "?"
  576.     n = n + 1: TestData(n, 1) = "01000000000000000100000101010000000010010000000110011000010100000001000010001000000000101000000000000010000100000011000010000000000010000000000001001010000000000000000000000000000000001000010000000000000011000000010000000000000100010000000000000000010000000000010010010100100100000000000000000000010100010100000000000000000000001100001000000000001001000010000000000010000110010000000000010000111010000000100000010000000110000010001000000000101000000010000000010010001101010000010000000001000000001100": TestData(n, 2) = "?"
  577.     n = n + 1: TestData(n, 1) = "00000001000000000000000000000010000000000000100000000100000000000010000000000100000100000001000000100000001110000000000000000010000000000000000100000100000000010000000010000101000000000010010000000000000000000000101000000000000000001000000010000000000000000000000000000000000000000001000000000000010000000000000000010001000000000010100000010000001010000000000000100000000100000000000101000000000000000100000000000000000000000000000000000000000000000000000000010000001000000000000000000000000000000101": TestData(n, 2) = "?"
  578.     n = n + 1: TestData(n, 1) = "11100110000000000000100000010010000010000000000000100100000010010000000000000000000000000000000110000000001011000000000000000001000000100000001100000000000000001001000000000100000000000000000000111000000000001000000000000000000000100100010000000000000000000000100100000110000000000000000000000000000000000000000111000001001000000000000000010000001000010000100000000000000000000000000000000000010000101010001000010100000000000000000000000001100100000000000000000000010000000100000100000000000000000000": TestData(n, 2) = "?"
  579.     n = n + 1: TestData(n, 1) = "00000000000000000000011000000000001000000000000000000000011100000100110000000000000000100000000000001000010000000000100000000000000000010000000000100000000000001000000000000001001100000100000010100000010001000000001001000000000000000010000000000000000000000001000000000000011000000010000000000001000000000000000000000000000000000000000000111000000100000001100011000000000000001000000000010000101000000000000101000000000100000100000000001000000000010000010000100000000000000100000000000000000000000010": TestData(n, 2) = "?"
  580.     n = n + 1: TestData(n, 1) = "00000000000010000000000000100000000000000000000000100000000011000000000000000010000000000000000000000001000000010000000000000000001000000000000001100000000000000000010000001001000000000000100000100000000110000000000000010000000000000001000010000000001100000010000000100000000000000010100100000001000000000010001000000010000000000000001000000000000000000000000000000000100000010000000000000000001000100000000000000000001000001000000001000000000000100001000100000000000000000000100000000000000000010000": TestData(n, 2) = "?"
  581.     n = n + 1: TestData(n, 1) = "00010000000000000000000000000000000100000000001000000000000000000000000000010000000000000000000010010000000100001001010010001001000000000000000010000001000000000000000100000000001000000001000000001000000000000000000000010000011010000000000000110001000000001000000000001000000000000100010000000010000000000100000000000100000100000010000100000000000000000000000000000000000100000000000000000000100110000010001010000111000000000000000000000000001000000010001000000000001001000000000000000000000010001000": TestData(n, 2) = "?"
  582.     n = n + 1: TestData(n, 1) = "00000000000100000000000000000000010000100001000001000000000001010000000001000000000000100000000000000000000000000000000000000110000000100000010000000001000000000100000000000000000000000100000001001000000000000000100000000000000000010000000000000000111000000000010000010000001000000000000000001010000000000000000000101001100000000000000100001000000000000000000000000000000000000101010001000100000000000000000100000000010000000000000010000000000000000000000000000100000000000000000000000100000100000000": TestData(n, 2) = "?"
  583.     n = n + 1: TestData(n, 1) = "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000": TestData(n, 2) = "?"
  584.     n = n + 1: TestData(n, 1) = "00000000001000000000000000000010010101001001000000100000000011110001000011001100000100010001000000111001010000010100001001100000000100001000001100000010110000000100100011000000000000000010000101101000100000011000101001110000001000111000100011100010001000001010000000000010000001100000000000011000000000010111000000000100001000000000000000000001000001000001000100010000011100001000001100000001000110101000001010000000000000000000000011000000000000001000000011001000001010000001010101100010010000000100": TestData(n, 2) = "?"
  585.     n = n + 1: TestData(n, 1) = "10000001100110110010010000000000001000000000100011100010000010100101010001100000100010001001001111110010000010000101001100000110000100100000111100000111100101010000101000010000000010000111010000000011000000101100001010000100100000001010101001100001010110001000010100001100100000000110100101000110000101101110010101000011010010100110010000100010110111000010011000000000100111000010110110011110000010010001010011101101101110010011000011110010010011000001100000100000100000000010011011000110010000000000": TestData(n, 2) = "?"
  586.     n = n + 1: TestData(n, 1) = "01001100101100110101101011000000100000111001001011100101010010101101000111100010010110100100001100011111111100111111100001010100100000111110000001000101010110000110010000010100100110010001000001110110010111100101001011111011011000000100000000110001110000010010001010011000010001110001001010111111001100101011010101111100110010001001010100011001000000010010000111100011100100111001100000000000100001111111100000000111111000100010001101101100011100011110011010111101001010010100001011000010100100100011": TestData(n, 2) = "?"
  587.     n = n + 1: TestData(n, 1) = "00100100110010011100000010000100010011110000101011111000110110100000110111000100000100000011110100000011001000010010011110010000110011111010111001101111001001000011000011000000101101000011100000010101001011100000110010010010011000011100000010001000110011000011001111101100011101011010100001101100110000100001010110000001011111011100110000010100000001000010000000000010010000000000011000101011001001101000000010000000100000010001000001100110000101001111000000000011000000100100010010001111100010000100": TestData(n, 2) = "?"
  588.     n = n + 1: TestData(n, 1) = "00000100010010000111111000011000001000001000000010000110111000100100001000000000101010100010101001111011111100010001000000110000000011001100100001000000001000000000000000100000011010100101111000011001001011100011010110010000000000011111101000100000110101011011001100110111101000011010000100001010000000101110110110010100100111100100000000000100010001001000011000000000000010000000100000000000110000001000100000000011000110010000000001100010010000000001000101001111000011010111001001000100000110110110": TestData(n, 2) = "?"
  589.     n = n + 1: TestData(n, 1) = "00010011011010111001011100100100101100010110100111001001100011000011110101001110111001000010011000011001000000001000010100110101010000000111101000100110011111100000000010110000010001110001100101000011100001010011000010000111101110000111000100010110101001110001100010000000010001111000110001110001000001100000110111111110000101110100000101000011110011000101001101101100001000100100000000000001000000000100000101000001001000110110110001010010000001010100001101000010100000000001010001111000011010100101": TestData(n, 2) = "?"
  590.     n = n + 1: TestData(n, 1) = "00000000000000001001100001001000010101000000010001000000000001010000000000001000000000000000000010100001100000100010010000100000000011000001001111000000000101011100000101110001100000001100000100000100000101001000100010000100101110000000010000101101110101000111000010110011000000111010000110100101110001000000001001101000010000010001000010010000100110000011010000100001001000100011000010000000000000100000010000101100100000010000001100000100000000000000000000001000000110100010100110000010001000010000": TestData(n, 2) = "?"
  591.     n = n + 1: TestData(n, 1) = "00100000010001011000001000001010000100100001100111000000010001010001000001001011001011101000001010000001001010001010011100100001011000010100010011010100000000001000010011100000000100000100000110000101011001011100010111000000100011001010011100110111011010100100000000100000000000000001000100010000011001000000001001101000000110001000010011111000101000000000000010000100000000100000000000000000000000001100010000001111100110000101001000110000010000000101000001001000110000001000001100011000010011000000": TestData(n, 2) = "?"
  592.     n = n + 1: TestData(n, 1) = "00100000000000001000111000000010010001100011000011000100111000001100000111000100010000000001010011001000001000000011111000011100100000000000000100001100010010010100000010000011111101010010100101100000001110010010000100000000000001010000000000000001010010010001000000100000011111000011010001001100000000100011101000000001001010000000001101111101011000100000110011000000001001000000010000000000011010000001001001000100000000110110010000110011000000000010010110100000100001001010100000000001000100001000": TestData(n, 2) = "?"
  593.     n = n + 1: TestData(n, 1) = "00001100001100010100000100001111110011001111010000111001001111100010101101011000101100010010101010000011010111100100101100001110011001100000001011000111010000111000001100010000000100100111000100100000010101110100010000101010101110111011101001111000010110111110010000110110001010001111100101100011101010011010100110000101010110010100111101100100011000001011111110111001001101100000000001010011000010100000011001001011110000000000010100000000000100111110001000100101000100000000001000001001110000000000": TestData(n, 2) = "?"
  594.     n = n + 1: TestData(n, 1) = "00001010001000010000010100010010000011000010000110000010101110101011000011000000100101100000010000001100101010000100010000001101001000010001100110000110010000000000101000000000000001101000100000110110000010100110000111100110000000100000000010110000100000011000010000010001000100010001000001100001101000010010001000000110000010100000000010010110100010010011000100100110000111110001000010111000010101100010000001000010010001001001010000010000000010110110011000101001011000011011000100011100100000010010": TestData(n, 2) = "?"
  595.     n = n + 1: TestData(n, 1) = "00100000001000011000000000100010000000001010010000000100000100001000010100001100001000110000100010011101001000010000010000000100001010100100001000000100110000100111010000110000110010000010010000101001011101100010000100000100000000000100000000001011000000000000001100000100000000001010000011000100000110011000010001100000000000001000001000011000001000110011000000000100001010000000011010100000010001000100000100000010100000110100000011001010110000000000000011000000000000000000010100011010001100001101": TestData(n, 2) = "?"
  596.     n = n + 1: TestData(n, 1) = "00110011100000011100111100110011001100001100110110110011010111111001111100110000001001010100001001010111110101100100111110000111111111100111101011100011001111010100100000010001111111001101111111100111001111001111111001110010000101101111001100111000011110011001111100100111010100110010110111010111111110001111111100101011000101111110011011011111001110000001001111001111000011111000001011110000111110011111111101110100111111011001011111110010000010010010000010010000110011110101110101000011111100111110": TestData(n, 2) = "?"
  597.     n = n + 1: TestData(n, 1) = "00100101100100010000001001001010000001110100000101000000001011001000110101000111000110111001000000100001000100100110000000010001001010000010001000000000001000010001000100010100110110110000010100001010010100010100011100000010101110000101000101000000011000110101011100001000000000100011100111010010010000100111000010010000010000101010000001000000100000010000001010100000001000000000001010000000010001010000001101001111001110110010000001000000110100000010001000000000000010001000100100001110000100110010": TestData(n, 2) = "?"
  598.     n = n + 1: TestData(n, 1) = "01100010000100001101011110010000001010011110010010000110000100000001001011000011110000110001111000000000110100000001100000010100001000000001000001010010000000001000011100001010011010010011010001000000110011011001000001000011100001100000000100001110000011111110101000110100001000101000000111000100110110100000010000000011100000110100100010000000101001001100000000001010001010000001100100110000000100000111000001100010000000000000110010001000011001000101000000000000000000000000100000000001100000101000": TestData(n, 2) = "?"
  599.     n = n + 1: TestData(n, 1) = "00100000100001101010000001000100010000001011111101011101011111100010100000000000000010110100100001000000000000001010001000000100111001011010000000101000001001000000110011000101010010001110010000000000010001000100001010100000010010011011001000111010100000000000011000000101010010001100100011111110000110000000011100001100010101000001010101000010001010000000000000100000001011111110000000100000100000010100001010010011010111000011000010101101010010111000000000000001000001001011001010000100000010001010": TestData(n, 2) = "?"
  600.     n = n + 1: TestData(n, 1) = "11100000010000010110100000000110001000000001100000111000010000101001011110000100010000110100000101000011110000000000100100101010111011010000001110000010000110000001100010010000111010001100010001001000010110001000000110111001010001111110000010000100100100000000101110010000001100010110010011101001001001000000100000000000100010001001100110100011000001011100000100000010101000010001001010011000010011100010010100000010000001111000001001110000110011010001100000110001011000000000000101001011000101000000": TestData(n, 2) = "?"
  601.     n = n + 1: TestData(n, 1) = "00110000001110000010001000000100100000010101100000011000110000100100000001110011000001110101000001000000000110000000000001010000111001010000010000000000000000100110100110100000010011011100111000110000011000110000100010100010110000011010010100000000100000110100001000000000000001100100000111101000010000100000000001000000000000100001001100010010110000000011100000010000011100010000000000000101000000001000000001000010000001000000000000100000010010010000000001000011000000010100100000000000010000100000": TestData(n, 2) = "?"
  602.     n = n + 1: TestData(n, 1) = "10011001110100010000011010000011000010011011011001010111100001100010110101001010000001100011000000110000000000000000101101000011101110110000111111111110010000110100001110011001011000110101001100000010111110001010001000011011011001010000000100000110001010010000011110100010100011000101110110100100110000011000100001010100110011001110010000001001110010001100000010100110101111010110000101000111111010000100111000001110000000000000000000110001101000000011110001011110000100000000000100110010000100111000": TestData(n, 2) = "?"
  603.     n = n + 1: TestData(n, 1) = "01111000100000000100000001000001101000000000000101000000001011010001101010111000010011110010000000000000111011000010110011000000001000100110010000000110111000000000000000000100011010000000011001010100010010001100001000000001000011100001000000000100000000000000111000010000001001000000101011010010000000011000000000000000111000000000100011001100010001001100000000100111001000000001000001010001000000011010001000000011100110000110000100000010010001000001000000000010000000111100010000010101011000000111": TestData(n, 2) = "?"
  604.     n = n + 1: TestData(n, 1) = "11010000010110110011000011100001011111011000011110011101100000110000100000010000010001010000111110010110101001000000101110000110001000010001110100000010000001000011101101010000110010001100000100000011101100100001000000001100111001010100000100110001011100010000010111001110000100010010000010001111100000100100100001000110110001100110001101111011000001011001000000011100100101010011001100101011010001100010011010001001000001101101111011011111000011110010011000000000010010110010000000110001000100110111": TestData(n, 2) = "?"
  605.     n = n + 1: TestData(n, 1) = "00000100000010111110001000101100000010001010000000101101111001011001001011100000010101110001111001010110010000111100000010000111100100111101001000001110000110110001000000100011001101000011111101100101100011000100010101001000111111000011100000101010011000100011010000000000001100000001100111000000010111000000000100101000000110001000110000000000001000100001111000000010011001111000000010100000000001010110001101001000101000001100000100000010000011110010110111000011101011111100000110100011001100010000": TestData(n, 2) = "?"
  606.     n = n + 1: TestData(n, 1) = "10101110010100010000010000010000011111110110000001100001001110100001000011000000100100100000011001101101011010010100101000010000100111001010010001001100011000100010110010001111000000101000100001111011000001100000111111100110010011000000100011011000000110000000011100010011000100111111100001000001010001111100000100100100001101100100100000010010100111100101001000110011010111110010000111101000101001010001000101000010011001000111101011100010001000110010010111000011000010010100000000000010001000110010": TestData(n, 2) = "?"
  607.     n = n + 1: TestData(n, 1) = "00000111101011000100000110000011010111110011111001001111011000010000010010010101000001000001100100100000000010000000111110010110001100110000110011000110010001000100110011111000000001111100111111001000001001001110011010010000011001100001010000000011111111110100011111100100001011111111010000001100010100011010100000110010011100111010000011001110000000001101001010000001110011000010011100001000110010100011111100100001111110011100011111100100000110100100100001001001101100000000000110011000001000000010": TestData(n, 2) = "?"
  608.     n = n + 1: TestData(n, 1) = "11111110010011111111100001100100100001111111110110101011110000111101011111111111110011100111111001100111111111111111110010101010111111110011111111110011110010000001111111100111111110111000111111100001100010011001111111111011100010101101000100111111111010110011110011110011100111100001000101111100111001010111001010111111100001111011000100000111111001000111100100111111111000000001000000110110111001111000001010011001111111011011111000000100111110101100000011111111001111100001101100011010001111111100": TestData(n, 2) = "?"
  609.     n = n + 1: TestData(n, 1) = "00111010110000001111101100000000010100000110001000000001010110100100011011110111100001001110000000000000000100001000010101011010001011101000111011010010000000000001101101101001101001100001110000100100100111000110000101101010100000010010001000001100110000001011010000000000100000011010101100001001001101100100010010100001100001001100101000000000000000110010101010000000111001010111100100110001000011001100111111011001101110000010000111101000001100000000000000100010111110100010101000001011100001111001": TestData(n, 2) = "?"
  610.     n = n + 1: TestData(n, 1) = "00000001000011100110011001101000000000001110000001011000100011000001000101111001101110011101101111101110111100100010010110110011001000100000100000000101110010000010100111011110000111101001011001111100000110000110011001010001000000011100001111111101111100101101111011000000000100000000001111011000000001001011100100010001000001001100010000010011001110011000110011101001010110100110001110010000101111111011101101101100000010000100001100001100100011101011110110000110000010100110100010000110100110100100": TestData(n, 2) = "?"
  611.     n = n + 1: TestData(n, 1) = "10111000101111101010011001001100001111110011000111011010000001110001010110100110011010110000011100110011100010100101010010001100010010000111001010111011000110110100000000110010100011001010001100111111111010001111001101000111010111111100100010000011110010011010100100100110001000010010011101010000000000100011001000011111001110010011101100011111110010000111100001001001001000100001000101111001001000111000110011001010101010010101100000010101000011100011001000001000100110000000000000111000001110010001": TestData(n, 2) = "?"
  612.     n = n + 1: TestData(n, 1) = "11111001000101111111100011111101110101111110110001111101010100010000111111111111111110011111001110101111001101011111100010111111110100011100111110101110011001110011111111100101011000000101011100110110111100000101110000100100111110011110000111111111011011111100001100100110011001001101000001000101111001111101011101010110111100011100010011001000010000111110010001011110011111111111111001010111111101011111001110000000101001111010100111111101011000100101000011111001011001010011001101000110000100111111": TestData(n, 2) = "?"
  613.     n = n + 1: TestData(n, 1) = "11001000011100110101111111001111010111100011011111101101101011011101101010011111111010111001110011110011111001000011111111111110001011111100111000011111111111111011000110011100110011001111010000010010011011011111101010011100111111111001111111001100111111101001101111010111110101100111111110011111110101101110010010001101000000011111110000001111111111111100000101000000111100011011001111111110011101110010101011111111000110111010001100100111111111111111111100001110011000011100001100011010001100000111": TestData(n, 2) = "?"
  614.     n = n + 1: TestData(n, 1) = "01110000001111111111110011101001011000011111111111001111111100111111111111010110100011111110101110101001110000111000011111111001000000111100111100111100111101010011100111111110011111111100100111010001111111001100111001111111110011111111111101011111111000011111110100010101111110110111000010011110000100111010110010011111111100100111111111111111101101111100101010011110110110011110000110000001101101111101101111110011111111001111111101101101000100111101011101011111111001001111111111100110011111110010": TestData(n, 2) = "?"
  615.     n = n + 1: TestData(n, 1) = "00100110010011111110100011001111110011100111111111111111111111111100010111101000111111010111111010111010010111111001000011100111111111001111001111111111111100111111111111110101001010111101010010011100101011111000001010110111001100110000111111110011001101010011101010011111111100100110011111110101001111111100100001110011100111111111111111110011111111001110000010111001111001101100010000111111001101001011111111111010110001011111110011111111111001000011100001100110000111111100110010011100101011001111": TestData(n, 2) = "?"
  616.     n = n + 1: TestData(n, 1) = "01111001111110000010111001111101011111111000000101011111111100100111100001111111001101011110011110000111100111111110100101110000100001000010111101110101110000010001001110101111100100111111010010001100111111111111100111111111111111111110011111111110010011111100100001000011001001110011111111111111111111100001111111001000010011111111100111111100100001000011111111111111000000111111111001010110011111100110011001110011100111110011100111110011111010111100111111100000011111111110011110011001001101011100": TestData(n, 2) = "?"
  617.     n = n + 1: TestData(n, 1) = "11111111111101101111111100111001111110010011111000011010111111111110011110011111110010011111111111111100111111111111100111110011111111111001111111110110111111111111000101000011111111111001000011110100010010011111001111110010111010000111110010011111111001001110011111111101010011100000011100111111010100001110011111111111111111110110111100101110111111111010111100111111111111111100001110000110011111111111100100111111111111010111100111111001100111111111100001111111111111101010110111111001111111100001": TestData(n, 2) = "?"
  618.     n = n + 1: TestData(n, 1) = "10111001000011101011111011000110000100101000111000011110110001111100111101101000000001110010100001000111001001111010101011010110011110100110010101101001100001001000000100110000001011011111010000101010001011001011111101001011010110011010100100110101010101011000000111010110101000100111000000010000100111000111000001000101111101011100000011100111000001001011000000000011001011110010110000110001111111010101110110111110101010000001011011101111011100010101001110000111101001010001011001100100110011101111": TestData(n, 2) = "?"
  619.     n = n + 1: TestData(n, 1) = "00011000111110101110110100111010001110101001010110011110000101101100100000101000111000111100001111101110110011110111010010011111011100101001010110000110011110011001111000000100110101010010111100001111101010011101110110000111111100000101111100101011110000010001000111111010111100101010111110010011111100111100111100100000011111100100111101111011010111000110011101110000110011001010110101110001000100000100001001010101010111110001011110000011011111100110011001111110011111011000100110011001100000110100": TestData(n, 2) = "?"
  620.     n = n + 1: TestData(n, 1) = "11111000010101110101001110011110000111001101100000010000110100111100111110101000011100001000001011101001100110100101001100110101101100001111001000101101100010010011110100010000101011010110011011011001100001100111111001011001100101010111000111000010111111101011101011010100001101011010000001010101101011001100111010110011101010010010000100001101010101011101111000010010100110111101101110011101001001011111101000111101011000010001110000110010001100101010101111010111100101100001000000111101101011000010": TestData(n, 2) = "?"
  621.     n = n + 1: TestData(n, 1) = "10000000000101100111000000010100011011010001111000101010111110011101101100011101001101111001000100100100000101111001110010011110010100011010100111111111101000100011000101010011111000011001111000011000000100010001000011100110111000001010111101001101001000100010001011100111111001111010011010010010111011111011001110111000001000110000101011010010010000010001100011100101010101101011111000111011101010101111111010001011000111110011111100010001010011011000100110011010101010110011100011010011111000111011": TestData(n, 2) = "?"
  622.     n = n + 1: TestData(n, 1) = "11010000010011101000010111000000011000011010011110010011001110001001010110110011100111000000101011100110101001110011110000000001110100001010111111111111001011011110000001100111111010100111110101001100010110000010101100110001000010011010100001001100110011101101111100100110110110111010100100010011000110111001101001110111101010010000011011001001110011111111010000011111011100111010111110110101011011110010011010000100101000010001001011100111100110101010101011001011011001100110101001111001010000100010": TestData(n, 2) = "?"
  623.     n = n + 1: TestData(n, 1) = "11010110011010111111001111010011110111100111001110010011101000111010010011001100011110011010000101010110111101011101101011010001111011001111010000011010110000100100011111000001110100110000100110010000111111010010100111000100101110110100110000001010111100010000101000100010100111000111000010000010010110101111001000010010011100111010000111010111011011011000010101100111100110010101001101101101100101100111100110110001101001001001011111001110100010101101110000010101111101010011111000111100000111010110": TestData(n, 2) = "?"
  624.     n = n + 1: TestData(n, 1) = "00000100110111011101011011011101001011000100011001010111110100001100000011011001110010110011101111001111111000100111010101100111001111001101100001001110111110010110110101001001001010001100001100001010101011001100000100011000001010101001100100100100001111010110011101101110100101111100101001101001001010110010001011111111110010111001100000011101111101001101100101100101110101101100111000111010001110000111100100000100011000010110111110011000000101000111111001110011011111000110111101010111100001001101": TestData(n, 2) = "?"
  625.     n = n + 1: TestData(n, 1) = "01111111101101010001101000100100111100001101111000111100011111000111111101101001100100110001101111001100110100010110111100010010111111100001100011010010101111111111001111010010000000100001101101111010011101000110111110101110011111111101001000000000000011100001110101110100010011000111001011111100011110001110001001011001001101010100000101101100100001110110111111111111000100000100111011000111100111111000101110010110101010011010011011110100001011100001110011110111110010010000010100010110101011111010": TestData(n, 2) = "?"
  626.     n = n + 1: TestData(n, 1) = "01010010100000101100110000111011100101010111001101011001101011110001001011001111100011011101011110001100000001111100111010010010101101111101100100000110100010010101111110011111110011001101001001100011101000100010110001011000001111011001100101110001110111101110000011011010101111000001111000011010101101110101001011011111110101100100101100110011000010011101101001110111000011010111001100101100001101001001100101011100111010000010110100000101111111010001110000110101110101000110011001011011011101000110": TestData(n, 2) = "?"
  627.     n = n + 1: TestData(n, 1) = "11001000101011011111101000010000110111111111000011010000010101000000100110111110010000000111110110111111100110101010111110011010001110010110100101000010111111000000111100111000011100100111001100111111110100010110000010010011000111001110001110110100111110101111011010100010000101001001101111111101010101111010111111001001001111111100101011011011101001100000100010111110101010100001110000110011001110101100101000101000111100100101110110011111001101011001100011100101001001100010101010011001010001111101": TestData(n, 2) = "?"
  628.     n = n + 1: TestData(n, 1) = "11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111": TestData(n, 2) = "?"
  629.     n = n + 1: TestData(n, 1) = "00100000000010000000000100000011000110110001001110101010010011010001100000101001000000000000010001110100001001101000001000000000010001101001011000010000000000010000000010011010011001001000000100000100000000001000000001000101001000001110001001000100000000000100000111000011010000000000010001000000110010000000011000000000100100001000001000010001001001110000000010000000100000000000000010000100000010000000101110011000001000100000011010100001010000001000010100000000001000001100000100010010000101100000": TestData(n, 2) = "?"
  630.     n = n + 1: TestData(n, 1) = "11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111": TestData(n, 2) = "?"
  631.     n = n + 1: TestData(n, 1) = "00001101110100101100011001010001001010010110000110000000100001000100100110000000010010100011000100110000110000100010000011001000000000100000001000100100100001100110100000101000101000010001110001111001000101000000100100001000000001110110100010001001000100100000011011000001000000000101000010000100010000110101001010010010001000110010110000000110010000110000001000101010001001101111001000010000101100011000000110001011110000001111001000000000000011110011100000000101010000000101110001000100000000100000": TestData(n, 2) = "?"

p.s.

I dont think I understood

Quote
If the string value repeated, ie, the same value (0) or (1) carried over from the previous
event then the value is (1), if not then (0).
Title: Re: Looking for old program or help recreating it
Post by: random1 on December 13, 2021, 11:28:01 pm
The new strings are built using the originals and based on rather the string value repeats
or changes.

Truth table
0 to 0 =(0) 
1 to 1 =(1)
0 to 1 =(0)
1 to 0 =(0)

It's just a reformatting of the string which can have a smoothing effect on the data which
seems to be somewhat easier to predict.  You don't need to do anything different, as were
still looking at predicting a zero or a one.  My software has a ascending / descending order
for all string option.  Some options require the data be fed in a certain order.

My math skills are lacking when it comes to higher level stuff so most of my tools are based
on statistics and pattern matching, maybe that's why most of them fail.  What I am working
on now is based on the logic used in the video that was posted.  The guy was able to come to
a high confidence level by the end of 20 games, the $100.00 bet.  The difference is that my
data may be too close to random to ever achieve this.  I am continuing to work on solutions
on my own but also using what you post at the same time.  If my post seem to fall outside
what your working on, then they can be safely ignored.

Anyway, thanks for your efforts and I will continue to follow your post as long as it takes
or your willing to address it.   There may not be the solution I'm looking for.  It's not just
a matter of finding the best, if the best falls short of my needs which is a possibility.


R1


   
Title: Re: Looking for old program or help recreating it
Post by: STxAxTIC on December 14, 2021, 09:45:59 am
Hey R1, another day, another update, another summary, really.

So you're doing well by checking out and studying the video Steve linked. It implies a few lessons about n-grams, combinatorics, and other light-duty discrete math stuff. It's not a bad way to start thinking about this problem. Let me do you one better though. Luke clued me in to this website:

Quote
https://www.expunctis.com/2019/03/07/Not-so-random.html

...which does the "short game" version of what we're doing. You try to give the program a random sequence, and it will predict your next action pretty well. Zoom to this morning. I actually read the bottom of the website. Turns out the guy just uses 5-grams, and I thought "dude, this is just a special case of what I'm doing". So I commented a few lines and was able to copy the behavior from the website just about exactly:

  [ This attachment cannot be displayed inline in 'Print Page' view ]  

It's not terribly hard to "act randomly" for a while, but you're eventually caught. I've since modified my code a little since the screenshot, but below I kept the code in "game mode" with a few more experimental switches turned on. Try this out:

Code: QB64: [Select]
  1.  
  2. Screen _NewImage(120, 60)
  3.  
  4. ' Version: 8
  5.  
  6. Type LetterBin
  7.     Signature As String
  8.     Count As Integer
  9.  
  10. Dim Shared TestData(1000, 2) As String
  11. Call LoadTestData
  12.  
  13. Dim Shared Alphabet1(2) As LetterBin ' 0 1
  14. Dim Shared Alphabet2(4) As LetterBin ' 00 01 10 11
  15. Dim Shared Alphabet3(8) As LetterBin ' 000 001 010 011 100 101 110 111
  16. Dim Shared Alphabet4(16) As LetterBin ' etc.
  17. Dim Shared Alphabet5(32) As LetterBin
  18. Dim Shared Alphabet6(64) As LetterBin
  19. Dim Shared Alphabet7(128) As LetterBin
  20. Dim Shared Alphabet8(256) As LetterBin
  21. Dim Shared Alphabet9(512) As LetterBin
  22. Dim Shared Alphabet10(1024) As LetterBin
  23. Dim Shared Alphabet11(2048) As LetterBin
  24. Dim Shared Alphabet12(4096) As LetterBin
  25. Dim Shared Alphabet13(8192) As LetterBin
  26.  
  27. Alphabet1(1).Signature = "0"
  28. Alphabet1(2).Signature = "1"
  29. Call NewAlphabet(Alphabet1(), Alphabet2())
  30. Call NewAlphabet(Alphabet2(), Alphabet3())
  31. Call NewAlphabet(Alphabet3(), Alphabet4())
  32. Call NewAlphabet(Alphabet4(), Alphabet5())
  33. Call NewAlphabet(Alphabet5(), Alphabet6())
  34. Call NewAlphabet(Alphabet6(), Alphabet7())
  35. Call NewAlphabet(Alphabet7(), Alphabet8())
  36. Call NewAlphabet(Alphabet8(), Alphabet9())
  37. Call NewAlphabet(Alphabet9(), Alphabet10())
  38. Call NewAlphabet(Alphabet10(), Alphabet11())
  39. Call NewAlphabet(Alphabet11(), Alphabet12())
  40. Call NewAlphabet(Alphabet12(), Alphabet13())
  41.  
  42. Dim thestring As String
  43. Dim actual As String
  44. Dim prediction As Integer
  45.  
  46. Dim Shared predictedGuess As Double
  47. Dim Shared correctGuesses As Double
  48. Dim Shared totalGuesses As Double
  49.  
  50. predictedGuess = Rnd
  51. correctGuesses = 0
  52. totalGuesses = 0
  53.  
  54. m = -1
  55. thestring = ""
  56.  
  57.     ' If analyzing pre-cooked data, load a test string.
  58.     If (m > 0) Then
  59.         thestring = TestData(m, 1)
  60.         actual = TestData(m, 2)
  61.     Else
  62.         actual = "?"
  63.     End If
  64.  
  65.     Cls
  66.     For k = 1 To _Width
  67.         Print "-";
  68.     Next
  69.  
  70.     If (m > 0) Then
  71.         Print
  72.         Print "Case:"; m
  73.         Print
  74.     Else
  75.         Print
  76.         Print "Press 0 or 1 as randomly as you can. I've already guessed your next input."
  77.         Print
  78.         Print ">"; thestring
  79.         Print
  80.         Print "My previous guess was: "; _Trim$(Str$(predictedGuess))
  81.         Print "I have been correct at a rate of "; _Trim$(Str$(Int(100 * correctGuesses / totalGuesses))); "%"
  82.     End If
  83.  
  84.     prediction = Analyze(thestring, actual, 0)
  85.     predictedGuess = prediction
  86.  
  87.  
  88.     If (m > 0) Then
  89.         'm = UserInput1(k, m)
  90.         _Delay 1
  91.         m = m + 1
  92.     Else
  93.         thestring = UserInput2$(k, thestring)
  94.     End If
  95.  
  96.     _KeyClear
  97.     _Limit 30
  98.  
  99.  
  100. Function Analyze (TheStringIn As String, ActualIn As String, pswitch As Integer)
  101.     Dim TheReturn As Integer
  102.     Dim As Integer n
  103.     Dim As Double r, j, k, h
  104.     Dim Fingerprint(16) As String
  105.     Dim p(2 To 10, 2) As Double
  106.  
  107.     ' Create shifted versions of string, i.e. ABCD -> BCDA, CDAB, DABC, ABCD, BCDA, etc.
  108.     Fingerprint(1) = TheStringIn
  109.     For n = 2 To UBound(Fingerprint)
  110.         Fingerprint(n) = Right$(Fingerprint(n - 1), Len(Fingerprint(n - 1)) - 1) + Left$(Fingerprint(n - 1), 1)
  111.     Next
  112.  
  113.     ' Initialize partial results.
  114.     For n = LBound(p) To UBound(p)
  115.         p(n, 1) = -999
  116.     Next
  117.  
  118.     Call CreateHisto(Fingerprint(), Alphabet2(), 2, 0) ' Set the last number =1 to print steps.
  119.     Call CreateHisto(Fingerprint(), Alphabet3(), 3, 0)
  120.     Call CreateHisto(Fingerprint(), Alphabet4(), 4, 0)
  121.     Call CreateHisto(Fingerprint(), Alphabet5(), 5, 0)
  122.     Call CreateHisto(Fingerprint(), Alphabet6(), 6, 0)
  123.     Call CreateHisto(Fingerprint(), Alphabet7(), 7, 0)
  124.     Call CreateHisto(Fingerprint(), Alphabet8(), 8, 0)
  125.     Call CreateHisto(Fingerprint(), Alphabet9(), 9, 0)
  126.     Call CreateHisto(Fingerprint(), Alphabet10(), 10, 0)
  127.     'Call CreateHisto(Fingerprint(), Alphabet11(), 11, 0)
  128.     'Call CreateHisto(Fingerprint(), Alphabet12(), 12, 0)
  129.     'Call CreateHisto(Fingerprint(), Alphabet13(), 13, 0)
  130.  
  131.     If (pswitch = 1) Then
  132.         If (Len(TheStringIn) >= 2) Then Call PrintHisto(Alphabet2(), 3) ' Set the last number >=1 to print stats for that histogram.
  133.         If (Len(TheStringIn) >= 3) Then Call PrintHisto(Alphabet3(), 3)
  134.         If (Len(TheStringIn) >= 4) Then Call PrintHisto(Alphabet4(), 3)
  135.         If (Len(TheStringIn) >= 5) Then Call PrintHisto(Alphabet5(), 3)
  136.         If (Len(TheStringIn) >= 6) Then Call PrintHisto(Alphabet6(), 0)
  137.         If (Len(TheStringIn) >= 7) Then Call PrintHisto(Alphabet7(), 0)
  138.         If (Len(TheStringIn) >= 8) Then Call PrintHisto(Alphabet8(), 0)
  139.         If (Len(TheStringIn) >= 9) Then Call PrintHisto(Alphabet9(), 0)
  140.         If (Len(TheStringIn) >= 10) Then Call PrintHisto(Alphabet10(), 0)
  141.         'If (Len(TheStringIn) >= 11) Then Call PrintHisto(Alphabet11(), 0)
  142.         'If (Len(TheStringIn) >= 12) Then Call PrintHisto(Alphabet12(), 0)
  143.         'If (Len(TheStringIn) >= 13) Then Call PrintHisto(Alphabet13(), 0)
  144.         Print
  145.     End If
  146.  
  147.     If (Len(TheStringIn) >= 2) Then Call MakeGuess(TheStringIn, Alphabet2(), 2, p(), pswitch) ' Set the last number =1 to print guess for that histogram.
  148.     If (Len(TheStringIn) >= 3) Then Call MakeGuess(TheStringIn, Alphabet3(), 3, p(), pswitch)
  149.     If (Len(TheStringIn) >= 4) Then Call MakeGuess(TheStringIn, Alphabet4(), 4, p(), pswitch)
  150.     If (Len(TheStringIn) >= 5) Then Call MakeGuess(TheStringIn, Alphabet5(), 5, p(), pswitch)
  151.     If (Len(TheStringIn) >= 6) Then Call MakeGuess(TheStringIn, Alphabet6(), 6, p(), pswitch)
  152.     If (Len(TheStringIn) >= 7) Then Call MakeGuess(TheStringIn, Alphabet7(), 7, p(), pswitch)
  153.     If (Len(TheStringIn) >= 8) Then Call MakeGuess(TheStringIn, Alphabet8(), 8, p(), pswitch)
  154.     If (Len(TheStringIn) >= 9) Then Call MakeGuess(TheStringIn, Alphabet9(), 9, p(), pswitch)
  155.     If (Len(TheStringIn) >= 10) Then Call MakeGuess(TheStringIn, Alphabet10(), 10, p(), pswitch)
  156.     'If (Len(TheStringIn) >= 11) Then Call MakeGuess(TheStringIn, Alphabet11(), 11, p(), pswitch)
  157.     'If (Len(TheStringIn) >= 12) Then Call MakeGuess(TheStringIn, Alphabet12(), 12, p(), pswitch)
  158.     'If (Len(TheStringIn) >= 13) Then Call MakeGuess(TheStringIn, Alphabet13(), 13, p(), pswitch)
  159.     If (pswitch = 1) Then Print
  160.  
  161.     If (pswitch = 1) Then
  162.         Print "Analyzing:"
  163.         Print TheStringIn
  164.  
  165.         Print
  166.         Print "Thinking:";
  167.         For k = LBound(p) To UBound(p)
  168.             If (p(k, 1) <> -999) Then
  169.                 Print p(k, 1);
  170.             Else
  171.                 Print "_ ";
  172.             End If
  173.         Next
  174.         Print: Print
  175.     End If
  176.  
  177.     j = 0
  178.     r = 0
  179.  
  180.     For k = UBound(p) To LBound(p) Step -1
  181.         If (p(k, 1) <> -999) Then
  182.  
  183.             ' This is the made-up part of the model:
  184.             ' The variable r contributes to weighted average.
  185.             ' The variable j is used for normalization.
  186.             ' Scaling factor h influences weighted average calculaton.
  187.             ' The factors multiplying h are totally arbitrary. Notes:
  188.             '   setting o(h^2) means the later alphabets count for more.
  189.             '   p(k, 1) euqals the calculated guess at frequency k.
  190.             '   p(k, 2) euqals the peak count of the unscaled histogram.
  191.             '   ...while p(k, 2) is here, it does not seem to help calculations.
  192.  
  193.             h = 1 + k - LBound(p)
  194.  
  195.             h = h ^ 2
  196.  
  197.             ' Standard weighted average:
  198.             r = r + h * p(k, 1)
  199.             j = j + h
  200.  
  201.         End If
  202.     Next
  203.     If (j <> 0) Then
  204.         r = r / j
  205.     End If
  206.  
  207.     If (pswitch = 1) Then Print "Predicting:  "; _Trim$(Str$(r))
  208.  
  209.     If (r > .5) Then
  210.         r = 1
  211.     Else
  212.         r = 0
  213.     End If
  214.  
  215.     If (pswitch = 1) Then
  216.         Print "Rounding to: "; _Trim$(Str$(r))
  217.  
  218.         ' Just for show, do the most naive thing possible by counting 1's.
  219.         n = Len(TheStringIn)
  220.         h = 0
  221.         For k = 1 To n
  222.             If Val(Mid$(TheStringIn, k, 1)) = 1 Then h = h + 1
  223.         Next
  224.         h = h / n
  225.         Print
  226.         Print "Naive (dec): "; _Trim$(Str$(h))
  227.         If (h > .5) Then
  228.             h = 1
  229.         Else
  230.             h = 0
  231.         End If
  232.         Print "Naive (int): "; _Trim$(Str$(h))
  233.  
  234.         ' Compare result to actual/known data if it was specified.
  235.         If (ActualIn <> "?") Then
  236.             Print
  237.             Print "Actual:      "; ActualIn
  238.             If (_Trim$(Str$(r)) <> ActualIn) Then
  239.                 Beep
  240.                 Print
  241.                 Print "*** MISMATCH ***"
  242.             End If
  243.         End If
  244.  
  245.     End If
  246.  
  247.     TheReturn = r
  248.     Analyze = TheReturn
  249.  
  250. Sub MakeGuess (OrigString As String, arralpha() As LetterBin, wid As Integer, arrbeta() As Double, pswitch As Integer)
  251.     Dim TheReturn As Double
  252.     Dim As Integer j, k, n
  253.     TheReturn = 0
  254.     j = 1 '0
  255.     k = 0
  256.     For n = 1 To UBound(arralpha)
  257.         If (Left$(arralpha(n).Signature, wid - 1) = Right$(OrigString, wid - 1)) Then
  258.             If (arralpha(n).Count >= j) Then
  259.                 If (pswitch = 1) Then Print "Order-"; Right$("0" + _Trim$(Str$(wid)), 2); " guess: "; arralpha(n).Signature; " . "; _Trim$(Str$(arralpha(n).Count))
  260.                 TheReturn = TheReturn + Val(Right$(arralpha(n).Signature, 1))
  261.                 k = k + 1
  262.                 j = arralpha(n).Count
  263.             End If
  264.         End If
  265.     Next
  266.     If (k <> 0) Then
  267.         TheReturn = TheReturn / k
  268.         arrbeta(wid, 1) = TheReturn
  269.         arrbeta(wid, 2) = j
  270.     Else
  271.         TheReturn = .5
  272.         arrbeta(wid, 1) = TheReturn
  273.         arrbeta(wid, 2) = j
  274.     End If
  275.  
  276. Sub CreateHisto (arrfinger() As String, arralpha() As LetterBin, w As Integer, pswitch As Integer)
  277.     Dim As Integer j, k, n
  278.     For n = 1 To UBound(arralpha)
  279.         arralpha(n).Count = 0
  280.     Next
  281.     For j = 1 To w '1 'w
  282.         For k = 1 To Len(arrfinger(j)) - (Len(arrfinger(j)) Mod w) Step w '- 0 Step 1 'w 'make the 0 a -w? might not matter at all
  283.             If (pswitch = 1) Then Print j; " "; arrfinger(j)
  284.             For n = 1 To UBound(arralpha)
  285.                 If (pswitch = 1) Then Print "@@@"; n; " "; Mid$(arrfinger(j), k, w); " "; arralpha(n).Signature;
  286.                 If (Mid$(arrfinger(j), k, w) = arralpha(n).Signature) Then
  287.                     arralpha(n).Count = arralpha(n).Count + 1
  288.                     If (pswitch = 1) Then Print "***";
  289.                 End If
  290.                 If (pswitch = 1) Then Print
  291.             Next
  292.         Next
  293.     Next
  294.     Call QuickSort(arralpha(), 1, UBound(arralpha))
  295.  
  296. Sub PrintHisto (arr() As LetterBin, w As Integer)
  297.     Dim As Integer j, n
  298.     If (w > 0) Then
  299.         If (w > UBound(arr)) Then
  300.             j = UBound(arr)
  301.         Else
  302.             j = w
  303.         End If
  304.         Print "Histogram: "; _Trim$(Str$(UBound(arr))); "-letter regroup, showing top "; _Trim$(Str$(w))
  305.         For n = 1 To j
  306.             Print arr(n).Signature; arr(n).Count
  307.         Next
  308.     End If
  309.  
  310. Function UserInput1 (TheKeyIn As Integer, PresentIndexIn As Integer)
  311.     Dim TheReturn As Integer
  312.     Dim As Integer j, k
  313.     k = TheKeyIn
  314.     j = -1
  315.     Select Case k ' Arrows
  316.         Case 19712
  317.             j = PresentIndexIn + 1
  318.         Case 19200
  319.             j = PresentIndexIn - 1
  320.     End Select
  321.     TheReturn = j
  322.     UserInput1 = TheReturn
  323.  
  324. Function UserInput2$ (TheKeyIn As Integer, TheStringIn As String)
  325.     Dim TheReturn As String
  326.     Dim As Integer k
  327.     Dim As String t
  328.     k = TheKeyIn
  329.     t = TheStringIn
  330.     Select Case k ' 0, 1
  331.         Case 48
  332.             t = t + "0"
  333.             If predictedGuess = 0 Then correctGuesses = correctGuesses + 1
  334.             totalGuesses = totalGuesses + 1
  335.         Case 49
  336.             t = t + "1"
  337.             If predictedGuess = 1 Then correctGuesses = correctGuesses + 1
  338.             totalGuesses = totalGuesses + 1
  339.     End Select
  340.     TheReturn = t
  341.     UserInput2$ = TheReturn
  342.  
  343. Sub NewAlphabet (arrold() As LetterBin, arrnew() As LetterBin)
  344.     Dim As Integer j, k, n
  345.     n = 0
  346.     For k = 1 To 2
  347.         For j = 1 To UBound(arrold)
  348.             n = n + 1
  349.             arrnew(n).Signature = arrold(j).Signature
  350.         Next
  351.     Next
  352.     For j = 1 To UBound(arrnew)
  353.         If (j <= UBound(arrnew) / 2) Then
  354.             arrnew(j).Signature = "0" + arrnew(j).Signature
  355.         Else
  356.             arrnew(j).Signature = "1" + arrnew(j).Signature
  357.         End If
  358.     Next
  359.  
  360. Sub QuickSort (arr() As LetterBin, LowLimit As Long, HighLimit As Long)
  361.     Dim As Long piv
  362.     If (LowLimit < HighLimit) Then
  363.         piv = Partition(arr(), LowLimit, HighLimit)
  364.         Call QuickSort(arr(), LowLimit, piv - 1)
  365.         Call QuickSort(arr(), piv + 1, HighLimit)
  366.     End If
  367.  
  368. Function Partition (arr() As LetterBin, LowLimit As Long, HighLimit As Long)
  369.     Dim As Long i, j
  370.     Dim As Double pivot, tmp
  371.     pivot = arr(HighLimit).Count
  372.     i = LowLimit - 1
  373.     For j = LowLimit To HighLimit - 1
  374.         tmp = arr(j).Count - pivot
  375.         If (tmp >= 0) Then
  376.             i = i + 1
  377.             Swap arr(i), arr(j)
  378.         End If
  379.     Next
  380.     Swap arr(i + 1), arr(HighLimit)
  381.     Partition = i + 1
  382.  
  383. Sub LoadTestData
  384.     Dim n As Integer
  385.     '''
  386.     n = 0
  387.     '''
  388.     ' Test: counting linearly
  389.     n = n + 1: TestData(n, 1) = "000001010011100101110111": TestData(n, 2) = "0" '0 to 7
  390.     n = n + 1: TestData(n, 1) = "0000000100100011010001010110011110001001101010111100110111101111": TestData(n, 2) = "0" '0 to 15
  391.     n = n + 1: TestData(n, 1) = "0000000001000100001100100001010011000111010000100101010010110110001101011100111110000100011001010011101001010110110101111100011001110101101111100111011111011111": TestData(n, 2) = "0" '0 to 31
  392.     '''
  393.     'n = 0
  394.     '''
  395.     ' Test: single-one patterns at stepping frequencies, all phases
  396.     n = n + 1: TestData(n, 1) = "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000": TestData(n, 2) = "0"
  397.     n = n + 1: TestData(n, 1) = "01010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101": TestData(n, 2) = "0"
  398.     n = n + 1: TestData(n, 1) = "10101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010": TestData(n, 2) = "1"
  399.     n = n + 1: TestData(n, 1) = "00100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100": TestData(n, 2) = "1"
  400.     n = n + 1: TestData(n, 1) = "01001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001": TestData(n, 2) = "0"
  401.     n = n + 1: TestData(n, 1) = "10010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010": TestData(n, 2) = "0"
  402.     n = n + 1: TestData(n, 1) = "00010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001": TestData(n, 2) = "0"
  403.     n = n + 1: TestData(n, 1) = "00100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010": TestData(n, 2) = "0"
  404.     n = n + 1: TestData(n, 1) = "01000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100": TestData(n, 2) = "0"
  405.     n = n + 1: TestData(n, 1) = "10001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000": TestData(n, 2) = "1"
  406.     n = n + 1: TestData(n, 1) = "00001000010000100001000010000100001000010000100001000010000100001000010000100001000010000100001000010000100001000010000100001000": TestData(n, 2) = "0"
  407.     n = n + 1: TestData(n, 1) = "00010000100001000010000100001000010000100001000010000100001000010000100001000010000100001000010000100001000010000100001000010000": TestData(n, 2) = "1"
  408.     n = n + 1: TestData(n, 1) = "00100001000010000100001000010000100001000010000100001000010000100001000010000100001000010000100001000010000100001000010000100001": TestData(n, 2) = "0"
  409.     n = n + 1: TestData(n, 1) = "01000010000100001000010000100001000010000100001000010000100001000010000100001000010000100001000010000100001000010000100001000010": TestData(n, 2) = "0"
  410.     n = n + 1: TestData(n, 1) = "10000100001000010000100001000010000100001000010000100001000010000100001000010000100001000010000100001000010000100001000010000100": TestData(n, 2) = "0"
  411.     n = n + 1: TestData(n, 1) = "00000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100": TestData(n, 2) = "0"
  412.     n = n + 1: TestData(n, 1) = "00001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000": TestData(n, 2) = "0"
  413.     n = n + 1: TestData(n, 1) = "00010000010000010000010000010000010000010000010000010000010000010000010000010000010000010000010000010000010000010000010000010000": TestData(n, 2) = "0"
  414.     n = n + 1: TestData(n, 1) = "00100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000": TestData(n, 2) = "1"
  415.     n = n + 1: TestData(n, 1) = "01000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001": TestData(n, 2) = "0"
  416.     n = n + 1: TestData(n, 1) = "10000010000010000010000010000010000010000010000010000010000010000010000010000010000010000010000010000010000010000010000010000010": TestData(n, 2) = "0"
  417.     ' Test: inverted version of the above
  418.     n = n + 1: TestData(n, 1) = "11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111": TestData(n, 2) = "1"
  419.     n = n + 1: TestData(n, 1) = "10101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010": TestData(n, 2) = "1"
  420.     n = n + 1: TestData(n, 1) = "01010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101": TestData(n, 2) = "0"
  421.     n = n + 1: TestData(n, 1) = "11011011011011011011011011011011011011011011011011011011011011011011011011011011011011011011011011011011011011011011011011011011": TestData(n, 2) = "0"
  422.     n = n + 1: TestData(n, 1) = "10110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110": TestData(n, 2) = "1"
  423.     n = n + 1: TestData(n, 1) = "01101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101": TestData(n, 2) = "1"
  424.     n = n + 1: TestData(n, 1) = "11101110111011101110111011101110111011101110111011101110111011101110111011101110111011101110111011101110111011101110111011101110": TestData(n, 2) = "1"
  425.     n = n + 1: TestData(n, 1) = "11011101110111011101110111011101110111011101110111011101110111011101110111011101110111011101110111011101110111011101110111011101": TestData(n, 2) = "1"
  426.     n = n + 1: TestData(n, 1) = "10111011101110111011101110111011101110111011101110111011101110111011101110111011101110111011101110111011101110111011101110111011": TestData(n, 2) = "1"
  427.     n = n + 1: TestData(n, 1) = "01110111011101110111011101110111011101110111011101110111011101110111011101110111011101110111011101110111011101110111011101110111": TestData(n, 2) = "0"
  428.     n = n + 1: TestData(n, 1) = "11110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111": TestData(n, 2) = "1"
  429.     n = n + 1: TestData(n, 1) = "11101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111": TestData(n, 2) = "0"
  430.     n = n + 1: TestData(n, 1) = "11011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110": TestData(n, 2) = "1"
  431.     n = n + 1: TestData(n, 1) = "10111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101": TestData(n, 2) = "1"
  432.     n = n + 1: TestData(n, 1) = "01111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011": TestData(n, 2) = "1"
  433.     n = n + 1: TestData(n, 1) = "11111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011": TestData(n, 2) = "1"
  434.     n = n + 1: TestData(n, 1) = "11110111110111110111110111110111110111110111110111110111110111110111110111110111110111110111110111110111110111110111110111110111": TestData(n, 2) = "1"
  435.     n = n + 1: TestData(n, 1) = "11101111101111101111101111101111101111101111101111101111101111101111101111101111101111101111101111101111101111101111101111101111": TestData(n, 2) = "1"
  436.     n = n + 1: TestData(n, 1) = "11011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111": TestData(n, 2) = "0"
  437.     n = n + 1: TestData(n, 1) = "10111110111110111110111110111110111110111110111110111110111110111110111110111110111110111110111110111110111110111110111110111110": TestData(n, 2) = "1"
  438.     n = n + 1: TestData(n, 1) = "01111101111101111101111101111101111101111101111101111101111101111101111101111101111101111101111101111101111101111101111101111101": TestData(n, 2) = "1"
  439.     '''
  440.     'n = 0
  441.     '''
  442.     ' Test: single-one patterns, select phases
  443.     n = n + 1: TestData(n, 1) = "00000010000001000000100000010000001000000100000010000001000000100000010000001000000100000010000001000000100000010000001000000100": TestData(n, 2) = "0"
  444.     n = n + 1: TestData(n, 1) = "00100000010000001000000100000010000001000000100000010000001000000100000010000001000000100000010000001000000100000010000001000000": TestData(n, 2) = "1"
  445.     n = n + 1: TestData(n, 1) = "00000001000000010000000100000001000000010000000100000001000000010000000100000001000000010000000100000001000000010000000100000001": TestData(n, 2) = "0"
  446.     n = n + 1: TestData(n, 1) = "10000000100000001000000010000000100000001000000010000000100000001000000010000000100000001000000010000000100000001000000010000000": TestData(n, 2) = "1"
  447.     ' Test: inverted version of the above
  448.     n = n + 1: TestData(n, 1) = "11111101111110111111011111101111110111111011111101111110111111011111101111110111111011111101111110111111011111101111110111111011": TestData(n, 2) = "1"
  449.     n = n + 1: TestData(n, 1) = "11011111101111110111111011111101111110111111011111101111110111111011111101111110111111011111101111110111111011111101111110111111": TestData(n, 2) = "0"
  450.     n = n + 1: TestData(n, 1) = "11111110111111101111111011111110111111101111111011111110111111101111111011111110111111101111111011111110111111101111111011111110": TestData(n, 2) = "1"
  451.     n = n + 1: TestData(n, 1) = "01111111011111110111111101111111011111110111111101111111011111110111111101111111011111110111111101111111011111110111111101111111": TestData(n, 2) = "0"
  452.     '''
  453.     'n = 0
  454.     '''
  455.     ' Test: double-one patterns
  456.     n = n + 1: TestData(n, 1) = "00110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011": TestData(n, 2) = "0"
  457.     n = n + 1: TestData(n, 1) = "01100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110": TestData(n, 2) = "0"
  458.     n = n + 1: TestData(n, 1) = "11001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100": TestData(n, 2) = "1"
  459.     n = n + 1: TestData(n, 1) = "10011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001": TestData(n, 2) = "1"
  460.     n = n + 1: TestData(n, 1) = "00011100011100011100011100011100011100011100011100011100011100011100011100011100011100011100011100011100011100011100011100011100": TestData(n, 2) = "0"
  461.     n = n + 1: TestData(n, 1) = "00111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000": TestData(n, 2) = "1"
  462.     n = n + 1: TestData(n, 1) = "01110001110001110001110001110001110001110001110001110001110001110001110001110001110001110001110001110001110001110001110001110001": TestData(n, 2) = "1"
  463.     n = n + 1: TestData(n, 1) = "11100011100011100011100011100011100011100011100011100011100011100011100011100011100011100011100011100011100011100011100011100011": TestData(n, 2) = "1"
  464.     n = n + 1: TestData(n, 1) = "11000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111": TestData(n, 2) = "0"
  465.     n = n + 1: TestData(n, 1) = "10001110001110001110001110001110001110001110001110001110001110001110001110001110001110001110001110001110001110001110001110001110": TestData(n, 2) = "0"
  466.     ' Test: inverted version of the above
  467.     n = n + 1: TestData(n, 1) = "11001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100": TestData(n, 2) = "1"
  468.     n = n + 1: TestData(n, 1) = "10011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001": TestData(n, 2) = "1"
  469.     n = n + 1: TestData(n, 1) = "00110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011": TestData(n, 2) = "0"
  470.     n = n + 1: TestData(n, 1) = "01100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110": TestData(n, 2) = "0"
  471.     n = n + 1: TestData(n, 1) = "11100011100011100011100011100011100011100011100011100011100011100011100011100011100011100011100011100011100011100011100011100011": TestData(n, 2) = "1"
  472.     n = n + 1: TestData(n, 1) = "11000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111": TestData(n, 2) = "0"
  473.     n = n + 1: TestData(n, 1) = "10001110001110001110001110001110001110001110001110001110001110001110001110001110001110001110001110001110001110001110001110001110": TestData(n, 2) = "0"
  474.     n = n + 1: TestData(n, 1) = "00011100011100011100011100011100011100011100011100011100011100011100011100011100011100011100011100011100011100011100011100011100": TestData(n, 2) = "0"
  475.     n = n + 1: TestData(n, 1) = "00111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000": TestData(n, 2) = "1"
  476.     n = n + 1: TestData(n, 1) = "01110001110001110001110001110001110001110001110001110001110001110001110001110001110001110001110001110001110001110001110001110001": TestData(n, 2) = "1"
  477.     '''
  478.     'n = 0
  479.     '''
  480.     ' Test: repeated staggered pattern: 010011000111, all phases
  481.     n = n + 1: TestData(n, 1) = "010011000111010011000111010011000111010011000111010011000111010011000111010011000111010011000111010011000111010011000111010011000111": TestData(n, 2) = "0"
  482.     n = n + 1: TestData(n, 1) = "100110001110100110001110100110001110100110001110100110001110100110001110100110001110100110001110100110001110100110001110100110001110": TestData(n, 2) = "1"
  483.     n = n + 1: TestData(n, 1) = "001100011101001100011101001100011101001100011101001100011101001100011101001100011101001100011101001100011101001100011101001100011101": TestData(n, 2) = "0"
  484.     n = n + 1: TestData(n, 1) = "011000111010011000111010011000111010011000111010011000111010011000111010011000111010011000111010011000111010011000111010011000111010": TestData(n, 2) = "0"
  485.     n = n + 1: TestData(n, 1) = "110001110100110001110100110001110100110001110100110001110100110001110100110001110100110001110100110001110100110001110100110001110100": TestData(n, 2) = "1"
  486.     n = n + 1: TestData(n, 1) = "100011101001100011101001100011101001100011101001100011101001100011101001100011101001100011101001100011101001100011101001100011101001": TestData(n, 2) = "1"
  487.     n = n + 1: TestData(n, 1) = "000111010011000111010011000111010011000111010011000111010011000111010011000111010011000111010011000111010011000111010011000111010011": TestData(n, 2) = "0"
  488.     n = n + 1: TestData(n, 1) = "001110100110001110100110001110100110001110100110001110100110001110100110001110100110001110100110001110100110001110100110001110100110": TestData(n, 2) = "0"
  489.     n = n + 1: TestData(n, 1) = "011101001100011101001100011101001100011101001100011101001100011101001100011101001100011101001100011101001100011101001100011101001100": TestData(n, 2) = "0"
  490.     n = n + 1: TestData(n, 1) = "111010011000111010011000111010011000111010011000111010011000111010011000111010011000111010011000111010011000111010011000111010011000": TestData(n, 2) = "1"
  491.     n = n + 1: TestData(n, 1) = "110100110001110100110001110100110001110100110001110100110001110100110001110100110001110100110001110100110001110100110001110100110001": TestData(n, 2) = "1"
  492.     n = n + 1: TestData(n, 1) = "101001100011101001100011101001100011101001100011101001100011101001100011101001100011101001100011101001100011101001100011101001100011": TestData(n, 2) = "1"
  493.     ' Test: inverted version of the above
  494.     n = n + 1: TestData(n, 1) = "101100111000101100111000101100111000101100111000101100111000101100111000101100111000101100111000101100111000101100111000101100111000": TestData(n, 2) = "1"
  495.     n = n + 1: TestData(n, 1) = "011001110001011001110001011001110001011001110001011001110001011001110001011001110001011001110001011001110001011001110001011001110001": TestData(n, 2) = "0"
  496.     n = n + 1: TestData(n, 1) = "110011100010110011100010110011100010110011100010110011100010110011100010110011100010110011100010110011100010110011100010110011100010": TestData(n, 2) = "1"
  497.     n = n + 1: TestData(n, 1) = "100111000101100111000101100111000101100111000101100111000101100111000101100111000101100111000101100111000101100111000101100111000101": TestData(n, 2) = "1"
  498.     n = n + 1: TestData(n, 1) = "001110001011001110001011001110001011001110001011001110001011001110001011001110001011001110001011001110001011001110001011001110001011": TestData(n, 2) = "0"
  499.     n = n + 1: TestData(n, 1) = "011100010110011100010110011100010110011100010110011100010110011100010110011100010110011100010110011100010110011100010110011100010110": TestData(n, 2) = "0"
  500.     n = n + 1: TestData(n, 1) = "111000101100111000101100111000101100111000101100111000101100111000101100111000101100111000101100111000101100111000101100111000101100": TestData(n, 2) = "1"
  501.     n = n + 1: TestData(n, 1) = "110001011001110001011001110001011001110001011001110001011001110001011001110001011001110001011001110001011001110001011001110001011001": TestData(n, 2) = "1"
  502.     n = n + 1: TestData(n, 1) = "100010110011100010110011100010110011100010110011100010110011100010110011100010110011100010110011100010110011100010110011100010110011": TestData(n, 2) = "1"
  503.     n = n + 1: TestData(n, 1) = "000101100111000101100111000101100111000101100111000101100111000101100111000101100111000101100111000101100111000101100111000101100111": TestData(n, 2) = "0"
  504.     n = n + 1: TestData(n, 1) = "001011001110001011001110001011001110001011001110001011001110001011001110001011001110001011001110001011001110001011001110001011001110": TestData(n, 2) = "0"
  505.     n = n + 1: TestData(n, 1) = "010110011100010110011100010110011100010110011100010110011100010110011100010110011100010110011100010110011100010110011100010110011100": TestData(n, 2) = "0"
  506.     '''
  507.     'n = 0
  508.     '''
  509.     ' Test: repeated staggered pattern: 0100101010101001010101000111, all phases
  510.     n = n + 1: TestData(n, 1) = "01001010101010010101010001110100101010101001010101000111010010101010100101010100011101001010101010010101010001110100101010101001010101000111": TestData(n, 2) = "0"
  511.     n = n + 1: TestData(n, 1) = "10010101010100101010100011101001010101010010101010001110100101010101001010101000111010010101010100101010100011101001010101010010101010001110": TestData(n, 2) = "1"
  512.     n = n + 1: TestData(n, 1) = "00101010101001010101000111010010101010100101010100011101001010101010010101010001110100101010101001010101000111010010101010100101010100011101": TestData(n, 2) = "0"
  513.     n = n + 1: TestData(n, 1) = "01010101010010101010001110100101010101001010101000111010010101010100101010100011101001010101010010101010001110100101010101001010101000111010": TestData(n, 2) = "0"
  514.     n = n + 1: TestData(n, 1) = "10101010100101010100011101001010101010010101010001110100101010101001010101000111010010101010100101010100011101001010101010010101010001110100": TestData(n, 2) = "1"
  515.     n = n + 1: TestData(n, 1) = "01010101001010101000111010010101010100101010100011101001010101010010101010001110100101010101001010101000111010010101010100101010100011101001": TestData(n, 2) = "0"
  516.     n = n + 1: TestData(n, 1) = "10101010010101010001110100101010101001010101000111010010101010100101010100011101001010101010010101010001110100101010101001010101000111010010": TestData(n, 2) = "1"
  517.     n = n + 1: TestData(n, 1) = "01010100101010100011101001010101010010101010001110100101010101001010101000111010010101010100101010100011101001010101010010101010001110100101": TestData(n, 2) = "0"
  518.     n = n + 1: TestData(n, 1) = "10101001010101000111010010101010100101010100011101001010101010010101010001110100101010101001010101000111010010101010100101010100011101001010": TestData(n, 2) = "1"
  519.     n = n + 1: TestData(n, 1) = "01010010101010001110100101010101001010101000111010010101010100101010100011101001010101010010101010001110100101010101001010101000111010010101": TestData(n, 2) = "0"
  520.     n = n + 1: TestData(n, 1) = "10100101010100011101001010101010010101010001110100101010101001010101000111010010101010100101010100011101001010101010010101010001110100101010": TestData(n, 2) = "1"
  521.     n = n + 1: TestData(n, 1) = "01001010101000111010010101010100101010100011101001010101010010101010001110100101010101001010101000111010010101010100101010100011101001010101": TestData(n, 2) = "0"
  522.     n = n + 1: TestData(n, 1) = "10010101010001110100101010101001010101000111010010101010100101010100011101001010101010010101010001110100101010101001010101000111010010101010": TestData(n, 2) = "1"
  523.     n = n + 1: TestData(n, 1) = "00101010100011101001010101010010101010001110100101010101001010101000111010010101010100101010100011101001010101010010101010001110100101010101": TestData(n, 2) = "0"
  524.     n = n + 1: TestData(n, 1) = "01010101000111010010101010100101010100011101001010101010010101010001110100101010101001010101000111010010101010100101010100011101001010101010": TestData(n, 2) = "0"
  525.     n = n + 1: TestData(n, 1) = "10101010001110100101010101001010101000111010010101010100101010100011101001010101010010101010001110100101010101001010101000111010010101010100": TestData(n, 2) = "1"
  526.     n = n + 1: TestData(n, 1) = "01010100011101001010101010010101010001110100101010101001010101000111010010101010100101010100011101001010101010010101010001110100101010101001": TestData(n, 2) = "0"
  527.     n = n + 1: TestData(n, 1) = "10101000111010010101010100101010100011101001010101010010101010001110100101010101001010101000111010010101010100101010100011101001010101010010": TestData(n, 2) = "1"
  528.     n = n + 1: TestData(n, 1) = "01010001110100101010101001010101000111010010101010100101010100011101001010101010010101010001110100101010101001010101000111010010101010100101": TestData(n, 2) = "0"
  529.     n = n + 1: TestData(n, 1) = "10100011101001010101010010101010001110100101010101001010101000111010010101010100101010100011101001010101010010101010001110100101010101001010": TestData(n, 2) = "1"
  530.     n = n + 1: TestData(n, 1) = "01000111010010101010100101010100011101001010101010010101010001110100101010101001010101000111010010101010100101010100011101001010101010010101": TestData(n, 2) = "0"
  531.     n = n + 1: TestData(n, 1) = "10001110100101010101001010101000111010010101010100101010100011101001010101010010101010001110100101010101001010101000111010010101010100101010": TestData(n, 2) = "1"
  532.     n = n + 1: TestData(n, 1) = "00011101001010101010010101010001110100101010101001010101000111010010101010100101010100011101001010101010010101010001110100101010101001010101": TestData(n, 2) = "0"
  533.     n = n + 1: TestData(n, 1) = "00111010010101010100101010100011101001010101010010101010001110100101010101001010101000111010010101010100101010100011101001010101010010101010": TestData(n, 2) = "0"
  534.     n = n + 1: TestData(n, 1) = "01110100101010101001010101000111010010101010100101010100011101001010101010010101010001110100101010101001010101000111010010101010100101010100": TestData(n, 2) = "0"
  535.     n = n + 1: TestData(n, 1) = "11101001010101010010101010001110100101010101001010101000111010010101010100101010100011101001010101010010101010001110100101010101001010101000": TestData(n, 2) = "1"
  536.     n = n + 1: TestData(n, 1) = "11010010101010100101010100011101001010101010010101010001110100101010101001010101000111010010101010100101010100011101001010101010010101010001": TestData(n, 2) = "1"
  537.     n = n + 1: TestData(n, 1) = "10100101010101001010101000111010010101010100101010100011101001010101010010101010001110100101010101001010101000111010010101010100101010100011": TestData(n, 2) = "1"
  538.     ' Test: inverted version of the above
  539.     n = n + 1: TestData(n, 1) = "10110101010101101010101110001011010101010110101010111000101101010101011010101011100010110101010101101010101110001011010101010110101010111000": TestData(n, 2) = "1"
  540.     n = n + 1: TestData(n, 1) = "01101010101011010101011100010110101010101101010101110001011010101010110101010111000101101010101011010101011100010110101010101101010101110001": TestData(n, 2) = "0"
  541.     n = n + 1: TestData(n, 1) = "11010101010110101010111000101101010101011010101011100010110101010101101010101110001011010101010110101010111000101101010101011010101011100010": TestData(n, 2) = "1"
  542.     n = n + 1: TestData(n, 1) = "10101010101101010101110001011010101010110101010111000101101010101011010101011100010110101010101101010101110001011010101010110101010111000101": TestData(n, 2) = "1"
  543.     n = n + 1: TestData(n, 1) = "01010101011010101011100010110101010101101010101110001011010101010110101010111000101101010101011010101011100010110101010101101010101110001011": TestData(n, 2) = "0"
  544.     n = n + 1: TestData(n, 1) = "10101010110101010111000101101010101011010101011100010110101010101101010101110001011010101010110101010111000101101010101011010101011100010110": TestData(n, 2) = "1"
  545.     n = n + 1: TestData(n, 1) = "01010101101010101110001011010101010110101010111000101101010101011010101011100010110101010101101010101110001011010101010110101010111000101101": TestData(n, 2) = "0"
  546.     n = n + 1: TestData(n, 1) = "10101011010101011100010110101010101101010101110001011010101010110101010111000101101010101011010101011100010110101010101101010101110001011010": TestData(n, 2) = "1"
  547.     n = n + 1: TestData(n, 1) = "01010110101010111000101101010101011010101011100010110101010101101010101110001011010101010110101010111000101101010101011010101011100010110101": TestData(n, 2) = "0"
  548.     n = n + 1: TestData(n, 1) = "10101101010101110001011010101010110101010111000101101010101011010101011100010110101010101101010101110001011010101010110101010111000101101010": TestData(n, 2) = "1"
  549.     n = n + 1: TestData(n, 1) = "01011010101011100010110101010101101010101110001011010101010110101010111000101101010101011010101011100010110101010101101010101110001011010101": TestData(n, 2) = "0"
  550.     n = n + 1: TestData(n, 1) = "10110101010111000101101010101011010101011100010110101010101101010101110001011010101010110101010111000101101010101011010101011100010110101010": TestData(n, 2) = "1"
  551.     n = n + 1: TestData(n, 1) = "01101010101110001011010101010110101010111000101101010101011010101011100010110101010101101010101110001011010101010110101010111000101101010101": TestData(n, 2) = "0"
  552.     n = n + 1: TestData(n, 1) = "11010101011100010110101010101101010101110001011010101010110101010111000101101010101011010101011100010110101010101101010101110001011010101010": TestData(n, 2) = "1"
  553.     n = n + 1: TestData(n, 1) = "10101010111000101101010101011010101011100010110101010101101010101110001011010101010110101010111000101101010101011010101011100010110101010101": TestData(n, 2) = "1"
  554.     n = n + 1: TestData(n, 1) = "01010101110001011010101010110101010111000101101010101011010101011100010110101010101101010101110001011010101010110101010111000101101010101011": TestData(n, 2) = "0"
  555.     n = n + 1: TestData(n, 1) = "10101011100010110101010101101010101110001011010101010110101010111000101101010101011010101011100010110101010101101010101110001011010101010110": TestData(n, 2) = "1"
  556.     n = n + 1: TestData(n, 1) = "01010111000101101010101011010101011100010110101010101101010101110001011010101010110101010111000101101010101011010101011100010110101010101101": TestData(n, 2) = "0"
  557.     n = n + 1: TestData(n, 1) = "10101110001011010101010110101010111000101101010101011010101011100010110101010101101010101110001011010101010110101010111000101101010101011010": TestData(n, 2) = "1"
  558.     n = n + 1: TestData(n, 1) = "01011100010110101010101101010101110001011010101010110101010111000101101010101011010101011100010110101010101101010101110001011010101010110101": TestData(n, 2) = "0"
  559.     n = n + 1: TestData(n, 1) = "10111000101101010101011010101011100010110101010101101010101110001011010101010110101010111000101101010101011010101011100010110101010101101010": TestData(n, 2) = "1"
  560.     n = n + 1: TestData(n, 1) = "01110001011010101010110101010111000101101010101011010101011100010110101010101101010101110001011010101010110101010111000101101010101011010101": TestData(n, 2) = "0"
  561.     n = n + 1: TestData(n, 1) = "11100010110101010101101010101110001011010101010110101010111000101101010101011010101011100010110101010101101010101110001011010101010110101010": TestData(n, 2) = "1"
  562.     n = n + 1: TestData(n, 1) = "11000101101010101011010101011100010110101010101101010101110001011010101010110101010111000101101010101011010101011100010110101010101101010101": TestData(n, 2) = "1"
  563.     n = n + 1: TestData(n, 1) = "10001011010101010110101010111000101101010101011010101011100010110101010101101010101110001011010101010110101010111000101101010101011010101011": TestData(n, 2) = "1"
  564.     n = n + 1: TestData(n, 1) = "00010110101010101101010101110001011010101010110101010111000101101010101011010101011100010110101010101101010101110001011010101010110101010111": TestData(n, 2) = "0"
  565.     n = n + 1: TestData(n, 1) = "00101101010101011010101011100010110101010101101010101110001011010101010110101010111000101101010101011010101011100010110101010101101010101110": TestData(n, 2) = "0"
  566.     n = n + 1: TestData(n, 1) = "01011010101010110101010111000101101010101011010101011100010110101010101101010101110001011010101010110101010111000101101010101011010101011100": TestData(n, 2) = "0"
  567.     '''
  568.     'n = 0
  569.     '''
  570.     ' Test: r1's custom quiz 1
  571.     n = n + 1: TestData(n, 1) = "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000": TestData(n, 2) = "0" '1
  572.     n = n + 1: TestData(n, 1) = "00000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000": TestData(n, 2) = "0" '
  573.     n = n + 1: TestData(n, 1) = "00000100000101110000001100010001100001001000000000000000001100000000000000000111001000000000000111100000000100111000000000000010000000001111000000000000000000000000000001010000000000000000010000000000000011000111100001000100000000000000000001101000000000000000001000110110000010000100000011001100001101001000000000000000000010000100001100011000101000000010000000000000000000000000000000000001000000000010000000000000001010000010000000000000000000000000000000000010000100000000000000001011010000000000": TestData(n, 2) = "0" '
  574.     n = n + 1: TestData(n, 1) = "00011101100000000001011100001011101000100111101100011000000011001010101000101000111111011000111000100000000000000110110000000001001001110110100001011011101100000011001010001111111110101100001101100001100011000111101100110000000101101101110000001110110111000011000110000000001101111000110000000011111100110001111000011101111101010011111111101111010011011001111101100010001100101101001011000010100111111101111010111111010110001100011000000100010001100111111001101101111000000010110111110000001011010011": TestData(n, 2) = "0" '
  575.     n = n + 1: TestData(n, 1) = "00000000100000000000110000000000000000010000000000000000010000000000000000001000000000000000000000000000000001000000010000000000000000000000000000000000000000000000000000011000000000000000001000000001000000000000000000000000000000000000000001001011001000000000000110000000000000000000000000000000000100010000000000000000000000000000000000001100000000000000000000000000000000100000000000000000001000000000000000000000000000000000000000000000100000000000000000100000000000000000000000000000000000000000": TestData(n, 2) = "0" '
  576.     n = n + 1: TestData(n, 1) = "01111011010110000100001000011001101101000011000011000000000100110010001010000100010000001110111000001000000000101110101100000000100011100101101110000010110101111001011010100000111011100110100001100100111010111110000010000110010000000100111100110000000101010100111001000000101000100101111001001001000010000100110011011010011011101000110011000000101000000100010000101101000101000110000100010101010111100000000001100000110010000001000011100001001000100000011100000101000001010101000100011010000100010011": TestData(n, 2) = "0" '
  577.     n = n + 1: TestData(n, 1) = "11000110011000111000001101000010001000001110001001110010000110000111010001010001100010101100001111100000111100101100000011000111101101110010101101010000101010000001111100000111110101010000000011011100100110101100111101000000100100101000011010000000010110101010011001110011111000010001100110001111111001100010011100010101001100000101010101100000000001001010000011011100010011001000001001110111100110010010000010000111111101100011010101010101000111010110101000000010001001001011011011100101111110110010": TestData(n, 2) = "0" '
  578.     n = n + 1: TestData(n, 1) = "10101101010001010110010110011111011111111101110100010011101110000000100011010000100111111001110110100011011110011101110001110011110000111011011110111011101100000010100111100010000010100111110010100100010001010101111000111010011101010111001110110000101101110001110010011101010110101110001111000101011001001101001011111101110010110101001100110010111101010111010010000010110100010001101110110101101110000101101010001001101101011000111110100000011101110010101111011110111110100110101001111101110001010110": TestData(n, 2) = "1" '
  579.     n = n + 1: TestData(n, 1) = "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000": TestData(n, 2) = "0" '
  580.     n = n + 1: TestData(n, 1) = "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000001000000000000000000000000000100000000000000000000000000000000000000000000000100000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000": TestData(n, 2) = "0" '10
  581.     n = n + 1: TestData(n, 1) = "00000110110101110000001100100101000001001111101111100000011000000000001001000100011000000000100011100000100000001001000001000010000000010111001101000001100000010101100011010011111000100111010000000000001010001011101110010100000000000010001011101000010000100000101100110100000011111000000001110000010101010000111111110000000110000100111110011000100000010001010100000000000110000000011000100000000111110011110010000100001010000010011100000000010001101010000000000110010000000110000000110011000000000000": TestData(n, 2) = "0" '
  582.     n = n + 1: TestData(n, 1) = "11011001010011000110101011011010000110001001010001001111100111001011110110111010001111010110010100100101011010110010010100111010111001101011100100001010011111111010011100101101000011011011000111011011010110111100110011100010100001101010110101110101110111010111010010011001110100011010011010101111101110100100100111101101001011100001001100100111010101100100101000111111111001001111100111010110111100001000000111101000111000001101011001001110001000010100110011111001001010101001110111010101111001100001": TestData(n, 2) = "0" '
  583.     n = n + 1: TestData(n, 1) = "00000000000000000000010000000001100000000000000000000001010000000000110010000000000000000000000000000000000000000000000000001100000000000111000101000000000000000000000000000100010001000000000000000000000000000000001100010010000000000000000001100000000000000000000000000001000000000000000000000000000000000010000011000000000000010000000000000001000000001000000000000000000000000000000000000100100000000000100000000000000000000000000000000000100000000000000000000000000000000000000000100000000000000000": TestData(n, 2) = "0" '
  584.     n = n + 1: TestData(n, 1) = "11101000011011010000101000100000010001001000000110011110001011010001001101101010001100111000000101001000011000001010010100010011100110101000101000000000010100111001010100010010101010100011000011000001011010000000010000000001011110110111000010000001011011100000000111001110100000110000000011000101100000001001000100110011000100100000100001001000000011010010100000000100100000101001100000110001001001110101010001000000011000000010101000110010000100001011000001101000101010011011001110010110000010000000": TestData(n, 2) = "0" '
  585.     n = n + 1: TestData(n, 1) = "00000010100110101001001000100000010100100100101101010010000001001100000000001011001110011011000010000111111001100010110011000010100110110000000000011010011010010100100011011011001100110001101001110000101001001100100010001101001000001011111100011011100000011001001010111000000000111101111001111001111111101000000000101100011001001011011010010000100001100010011110010000001011000001010111010010011111001001001110111100110010000110100111101000000101110100101010001111001111101100010101001001010101000101": TestData(n, 2) = "0" '
  586.     n = n + 1: TestData(n, 1) = "00111100000000000111001001100000111010010010010011100010001100001100000011011000100010000101110010110100110110011100010001111110011011000110010000001001101111111000011000010001101110011101111010100110100110000111011101001111110011011111100110111000001101101110001001001000011110100110000111110111010000001100100100100111110110100001001011100110111000100011110100100100110010011110011011100011101111010010000110000011101100000111001011000110000010001101111011111011001100000010000101000000000000101110": TestData(n, 2) = "0" '
  587.     n = n + 1: TestData(n, 1) = "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000": TestData(n, 2) = "0" '
  588.     n = n + 1: TestData(n, 1) = "00000000000000000000000000000000000000000100000000000000000000000010000000000000001000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000": TestData(n, 2) = "0" '
  589.     n = n + 1: TestData(n, 1) = "00000000010111101100110000001011000001001011001100000001001100001001000001001100010000111111000011100001000000001111010010000100001000000010001101001011101011011010000101010011110110110001100001000010000010100011000000110001000000011101110001000000000000110000100000101100000001011010000101000000100100011000111111110010110101010100011110100110110000010001101000000000101001000010100110000100010100111000010010100100001000110000000100010100010000000010000100011100010010110100010000010010001001000010": TestData(n, 2) = "0" '
  590.     n = n + 1: TestData(n, 1) = "11111111011001010010001100000100110110101110100011010010111011110100101000100000000101100000000100110010111110111000110101101010111111011101101010011111100100110100010011011001100000001110111110000101000000001100110101011110011111101100001110011101111100111100011100010010110111100001010000010001101001001111000000000101001000100100000110011000101011100100000100111011010110100000010001011010101011010010100111011000100011001000001010001011101010000100001011001011100001001011101110100110110010111100": TestData(n, 2) = "1" '20
  591.     n = n + 1: TestData(n, 1) = "00000000000000000000000000010000000000000000000000000000000100000000100000000000000000000011100000000000000000000000000001000000000000000000000000000011001000000000000100000000000000000000000000010010000000000000000000000000000000000000000000000000000000000000000000000000000010001000000000000000000000000000000000000010000000000000000000000010000000000000000000000000000000000000000000000001001000000000011100000000000000001000000000000000000100000000100010000110100000000000000000000000000000000000": TestData(n, 2) = "0" '
  592.     n = n + 1: TestData(n, 1) = "01011000100010001000011010000010010010000100100101000100011001000010000010110110010110001100010001000010110110000011010100000100100010010011111101111100110010101100000001000000100111010000010000100000000111100110000101110001100100000001000001001100100100010000001001000110000000000100011100110110000101100011100010110100000011001001011000010001001000101010010010000001000000100101100101001110110010010000100010100010000000100111001100000000001000111111010100001000001010000010101010110101101000001100": TestData(n, 2) = "0" '
  593.     n = n + 1: TestData(n, 1) = "00000101000010010110000110001101111110010001110010000010101001111111010000011011100000110000010101101110101111110101001100000100000000100110001000000000000001110011101011011110000001000110101001000000000000010100010010110110000010001100100010011001010011111011001110110000110100010010000010010110011000010110110010101000111000000100000001101100100110010100110111001110110101010001101100000000110010100010000001000101011100000000000111101110101011001011001100100000001101110000001001101010000000111011": TestData(n, 2) = "0" '
  594.     n = n + 1: TestData(n, 1) = "10100010000111100111110001101101100001100111001010011110011001101110100111000111001010100111100010110010101010100100100000101010111100100000010111001000101110010010111000001100011011001011010100101101101110001001111100110000001011100000010110011010001000001101101111001000011101001000110010110111100011111011001100011110100110100111001110000101010001010001101001101001011001111010011001101010000001111010110011100001010100011100110100011011110011100101000001110010010111100111110011001110011111001010": TestData(n, 2) = "1" '
  595.     n = n + 1: TestData(n, 1) = "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000": TestData(n, 2) = "0" '
  596.     n = n + 1: TestData(n, 1) = "00000000000000000000000000000000000000000100000000000001100000000000000000000000000000000000000000010000000000000000000000000000000001000000000000000000000000000000000001000000000000100000000000000000000000000000000000000000000000001100000000000000000000000000000000000000000000000000000000000000000000000000110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000": TestData(n, 2) = "0" '
  597.     n = n + 1: TestData(n, 1) = "00100000011101101100000000000000000000001010001010001010010000000011101000010100001000000110000110100000000010001000111100100100001010110000011000001010110100110011000010001000110101001001100001011000001000000000000010110000100000110000001001000000100000110100100100100001010011000000010101010010100101000000001011100010000000001100000110100010100010000001110000000100000001110010100100001110000001100110000100001000001000000000010000001000001000000001001100000000010011110100000000001010100001111111": TestData(n, 2) = "0" '
  598.     n = n + 1: TestData(n, 1) = "01010110100011101001111011101011111111101001100000010100001001111110010111100011101100011111110001101101111000110011010011010011110000101111110110010001000001010100100100110011010010010110101011100000111111111101111110110011111101010011110000111101000010010011010000011100001000011011000011001101100011011101000101010101111011000100001111010100111001011100011100011011011000000010011010010100110010011001111011010010110011111000101110010111111100100100111110111010101001101011010100000001011010010000": TestData(n, 2) = "1" '
  599.     n = n + 1: TestData(n, 1) = "00000000000000000000000000000000000000000000000000000000000000000000000000000100000001000000000000000000000000000000000000000001000000000000000000000000000000000000000010000000000000010010100000000000001000000000001000100000000000000000000001000000000000000000000000000000010000000010000000000000000000000001000000010000000000000000000000000000000000000000010000000110000000000000000000000001000000000010000100000000000000000100000001000000010000000000000000000000010000000000000000001000000000000000": TestData(n, 2) = "0" '
  600.     n = n + 1: TestData(n, 1) = "00000001100010111010101010001001000011001100000000000000010011000111001101001010110010010010010100101010000001001000111000000010110000010001001110100000000101101001110100010100000101000100000101000000010000110000010011010000100101001111000000011110001000001101101100000001000101000000011001011001110111100010010001000011110011110010010001000001110100100010101001110000010100000010010100000000101001000100101000011000000001001010111010110100000011001100101010000000100100100111111001110101000100000001": TestData(n, 2) = "0" '30
  601.     n = n + 1: TestData(n, 1) = "11010010010101000010000011010000101110111010011001101000101111011101001110000001011110100101101111000100000010110001010101000110100001100000111000111100011110110011101101101111101010100100011101000000010010101110000011011100010010101110101010000001110001001111110011011101000010110000101111000000101100011100101100001001100001111110000101110000010010000001001010000000011011000001000101000100000111101100110011000111010000001000010000000000100101010001100001011000001010001000111111110110101000011111": TestData(n, 2) = "0" '
  602.     n = n + 1: TestData(n, 1) = "11011111000111100000010011111111101111001100100010111010010000011000110100111010011000111101000111010000110110101010011010101011100110011101000001011011111110011100110100001001010000001000010010100101111011000101001000000011110011110001100100100011011001010000101101111110101011011100000111000111000011110101111011101000101010000111011110000111111101011101110110001000011000111011011011111100110000001011011010110101101111011001011000111100101100111010011100110111101100110110100110000010011111110101": TestData(n, 2) = "0" '
  603.     n = n + 1: TestData(n, 1) = "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000": TestData(n, 2) = "0" '
  604.     n = n + 1: TestData(n, 1) = "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000": TestData(n, 2) = "0" '
  605.     n = n + 1: TestData(n, 1) = "00100000000000000011000000000000000000000110000010011111100000000000000001000000001000000000000000010110000110000001100010000000000011110000000001100000000000110011000011000000010000001110000000011000001000010000110100000010000000111101000000000000000000100000000001100000100011000000000100000000000101000000000011010000001100010100000110110010100001010000110000001000000001100000110000001100000000011010000000000000101001100000000000000000100000011010100000000010010000100100010000000000000001111000": TestData(n, 2) = "0" '
  606.     n = n + 1: TestData(n, 1) = "00010100011101010101100000101000001100111001101101000000011001111001100110110111010111111011110001100000000001100000011001111000111001000110011010001110100110011001110111100000101000110001100110100111000111001000001001110101101110000000110000000000011001010101000110011101011001100011001001011001101100011110000101101001100011001010011000001100110000101000001111110110000000001100001100010010101111100101001101010000000110011011111100011111010000000101000000100101100111010110001101111010101010000110": TestData(n, 2) = "1" '
  607.     n = n + 1: TestData(n, 1) = "00000010000000000001100000000000000001000000000000000000000000000000000000000000000001001000000000000000000100000000000000000000010000000000000000100100000101000001000000100001100000000000000000000000000010110000000000000000100001000000000000001000000001100010000000010000010000000000000110000000001000000000001000010000000000010000000000000000000000000000000000000100001000000000000100001000000000000000000100000000000100000000000000000000000001001000000000000000000001000010000000000010000011000000": TestData(n, 2) = "0" '
  608.     n = n + 1: TestData(n, 1) = "11010000111110000000000011000001011000010011010100100000000000110011011101010010100100000000000000010001101001000001001010011000100101101000111011000001000010010000010000010100001000100110100001100100001001001001100011110010011000110111000011000000011000000000100110001000101101100000001000000000000100000000000001001110001110100000010100001011101010110100001001001000000010010100001010100111011111000100001010000011010001000011001101110001101110000011010101101001010100110100010001011100110100110111": TestData(n, 2) = "1" '
  609.     n = n + 1: TestData(n, 1) = "00000000110110001000000011001000100000001110011010100010101101111100101100101000001010000000101101010100101011010000010001001110001001100001110101011010111010000100001011001010010100011001011000010000100001000000000100001111001000101011111110100001110010011000100001101000101001101011110001011111000110111010010101000001001011101101110000001011110000011001100011111001010100010101110011000100110000101101010010110000000000010011001001101101000010000010001110000011111100111101100100110000001000110000": TestData(n, 2) = "0" '
  610.     n = n + 1: TestData(n, 1) = "00101101111001100011001000011101001000000001100000101001000010110101000011001101110010110011000010101100111010101111100101100111000010110111010100000000001010000111111011001000111011100100011111101010010101011111111010010110010001101010100101010110111010111000101111001101001101101111010101010010110001000110110110101000010100001000010011101010011110001000001111001100110001011010100011101011100000100000111001000111001010101111010010010100110111001000100011010110100011111011101001101010111101101010": TestData(n, 2) = "0" '40
  611.     n = n + 1: TestData(n, 1) = "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000": TestData(n, 2) = "0" '
  612.     n = n + 1: TestData(n, 1) = "10000000100000000000000001001001000000100011010001010100000100000000010101100110101000000000000100000101010000000101000000000101100000000000010000001000001011000110100110100010010100010111000100000100001010000000101010001000111001000000010000100100000000000000100000001001000000110001010001001010010000000010101001000111011000100100100000010010000100100000000000001000010010000110010110000110100000000000101001010100000110010001110000111000000110000000000000000000000100101100001010000100000101100010": TestData(n, 2) = "0" '
  613.     n = n + 1: TestData(n, 1) = "00001101011011101101111110010000011011010000101110101011001001111000101010010001010111100001110011011010100011011010101010111010001010100110101100000110110100101001011001010000001010100000111010111011100100110111010101010100000010000010101110001011010011001111011110110000110010001010001000110100101111101100000110111000000000000010001111101001011011010111110110000100101000111000101001110001010011110100010100100011110000001100001011000100100000011110111111100011000011000011100101111010111010010101": TestData(n, 2) = "1" '
  614.     n = n + 1: TestData(n, 1) = "01110011000100111110101110110110101110011100101000000011111010011111101010001000000000111110011010111010001110111000111111010010011101111101100111110001000000011000001000001101101001001000010001011000010001111100010001100111000100111111100011010001101101110110000001010110001111000100101110010001101101010001010110110000100111011001010100101101110000001111001111110111100101101001001001111001011111111011000010101001001001101010001111000011011001111111001011111101111001010010110000100001010000011000": TestData(n, 2) = "0" '
  615.     '''
  616.     'n = 0
  617.     '''
  618.     ' Test: r1's custom quiz 2
  619.     n = n + 1: TestData(n, 1) = "10000001001000000000000011000000000011010100000100010100010111001001000011100000000000101000000000000000000100000011000011010001000000010000000001001000001000000000000100000100000101001000010000000000100011001101010000000010000100010000001001000000010000010000010000010001100000010010000000000110110110000100110010000000000100000001001111110010011001000011000001101010001111111010101000010111111110000000000101000000000010001010101011000001101001000010000000010110001001000010010100010101000000011101": TestData(n, 2) = "?"
  620.     n = n + 1: TestData(n, 1) = "10001000000000000000000100101000000000001100000000010000100000000000000011100000000010000100000000000101000100000000000011000000000000110000000000000100100000000000000100000011000000000000000000000000000000001001100000000100100100000000000000000100010000000000000000000000000000000000000000000001001000000000000000111000000000000000000000000010001011010010000000000000000100010101001000001000010010000100000001000001000100010000000001000000110000000000000011000000000000000000000100000000000000001000": TestData(n, 2) = "?"
  621.     n = n + 1: TestData(n, 1) = "00001000000000000100000000000000010001000000000000000000000001100011000000000010000000001000101000000101000000000100000110000000001000000000010100000000000000100001010100000000000000000000110000010010000100000101000000000100100000000100010000110000010101000000010000000001000000000100001000000111000100000000000000000100000001000001000000000000000000000000000000000000100010000100000000100000001000000100000000000000100000001010000000000000000101000000000010000100000001100000000000000001000000000001": TestData(n, 2) = "?"
  622.     n = n + 1: TestData(n, 1) = "00001000000000000000000000000000100000000000010010000000000000000000100000001000000001000000000000000000000001100000001100011001010000000000000000000000000100000001000000001001100010000000100000000100000001000000001001000001010000000000000000001000000000011000000000000000001100000000000001000000111000000010000000000000000000000101000000010000000000100000000000001000110100000000001000101000010000000000000000000000000000000000000000101000000000101010000010010000001000001000000000000000000100010000": TestData(n, 2) = "?"
  623.     n = n + 1: TestData(n, 1) = "00001001111110110001110000000100000110000100000001000000100000010000111000001000001101000001001000000000000000101000110000001011100000100000110000001000000000100001100000010010011100000011100001000110001001000011001011000100010110000110000100111110111011001100000000000000000010000000011100000010000000000000000000111001010001000100000000001010001010000000000000000010101000001000011110100010000100010000001100100001000100000000111000011000000000000000000000010101011010001111000101000000100100110000": TestData(n, 2) = "?"
  624.     n = n + 1: TestData(n, 1) = "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000": TestData(n, 2) = "?"
  625.     n = n + 1: TestData(n, 1) = "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000": TestData(n, 2) = "?"
  626.     n = n + 1: TestData(n, 1) = "00000001111000110110101000011001001111110101101100011010111100111010100101001010001001100100000100001011000100000100000110000110110000000100101001110001101001110010001000100010110000000110010010101010001000000110100000001001011100001000000100001011111010011011000000000110111100100000010000100001110000010000000000110001111110001100010111000100100001000011000010101110000001000000001101101001111000000010011000000110001000011100111011011000100100000000110000010010110011010110000110011010000010010110": TestData(n, 2) = "?"
  627.     n = n + 1: TestData(n, 1) = "10001110100010001000100001110001001101100010100100111001000000001001100000001000111000001000001100001110010000000001001111000011110101100111001001111011101010110100001001001100100100001101000111010001111110101010101101000101011011111001010110000001010000000000111100100111011001010110000010001110010000001000111110011101111100111000000001100101000000000101111111100011001100111100101011101010011110000010011110001011110011101100010101110000100000011001000011001001010101110110101100111000000010000100": TestData(n, 2) = "?"
  628.     n = n + 1: TestData(n, 1) = "00111001100110011100000000000000001000100100010100100010001101000111011100100010001111100000000110000001000001111001000100000101010011101000001000110100011111110001000110001101110000000010101100000111000001100110011111110000000000000100100000000110101001010110000000011100000010110100110000000110000000001010000101000001000000100000100010000000000100000011000000000010010100010001101100110010101010000010111100000111111100000001001010001001001000000000111000010011010011000000001101000000000010000011": TestData(n, 2) = "?"
  629.     n = n + 1: TestData(n, 1) = "10000101100000010101000111000110011000100100000101000011001110000010000100000111001001100000011100000101001000000000111100000100011000000010001100111000001001110100100000010000110011110011000000000010100100010111000000000000000010010000010001010010101100110010000000100101000001101001010010000000000010000001110010000011000000010010001010000010011000011111101100000010100000001110011110100000101001011111011001100110001000100000001110001000010000000001110001010010010011100000000100100100110011000010": TestData(n, 2) = "?"
  630.     n = n + 1: TestData(n, 1) = "01011100011100011000100100011010011000010011000011101100110010000000011000001100111001010010001001001101010101100100100011111110110111111111001011111011011001110011011000010001100100101100000111101001000100111110010110110101001000011011110101010010010001111011101111111100110000111110011001001111110111010000010110001001000101001100001101010010000000000110011110100001100000010000011001110110110010011000100000000110001001000001100000011001001100100100100011010001111100011001111101100000111100000000": TestData(n, 2) = "?"
  631.     n = n + 1: TestData(n, 1) = "00110000100010000000100000000101000100000000000000000010000000100000110000101000110000100010000000001000100100000101000010110101001101100010001000100100010000000000000000000000100100011001001010001010000010010000000100001001000010000001010110010000100011010000100011010110110100100100001000000010110100000001010010000001111110000000100100100000001101000110111100011101001110010010001010110000000011110001101000000001110000100010100000010001000010001000100000010000000000000000000010011001011000010100": TestData(n, 2) = "?"
  632.     n = n + 1: TestData(n, 1) = "10110010010010010000110011100101010001001001100011000001000010011000101001100000110110000000100011111000011000000111111000001000011011010111000000010001000101001110010001101101011001010001000110000010000110010100010000011001010000100000101100011100000110001001100111100110000110100010100000011000111100111010010100011000000000011000010111100000100001010100011110100000000000101101110010000000100110100001110000001110001000100000000000010010001100000000111100000001000000000000000000000000001001000000": TestData(n, 2) = "?"
  633.     n = n + 1: TestData(n, 1) = "11010000100101101011010111010110101110101000001101001011100000111001010001100000101100110000010111000100100101110100001101111001011011001100110101111100010010111100010010111111010001111110010011110000110011110011010011010101100001101010011110101001110001100011001110111110011111111101100001100000011000000101101100111100011010001011010101001010000101010011000010011011010110110111011110000001110010100010000000101111101011101111000101010001011111100100101000011001011001101111101100010111010100111001": TestData(n, 2) = "?"
  634.     n = n + 1: TestData(n, 1) = "00000000001110011101011110000001110100101110110111000101111000011010101110010001100110001000111101100010101110100010010110101110110110110001001001010010000011101111010010110010000110001000100001111110100001100000101011011000001100001011110001110100111010101110001011110000001111110101010101100101000001101010101001010010100001001000101000011000111101100111101001001010110010000100111010011010111010000100001011010101111111100100111101011001100111110010011110011100011110001110001001011000011010001101": TestData(n, 2) = "?"
  635.     n = n + 1: TestData(n, 1) = "10001001110000001000010001011011000100011010010101101011010100011001000011010101101100011011000111010111100010110011001001101011100111101101001000100100101111011100001100100100010000001100000010000010011101001010001011100011100001001000010000100010001001111000000010001101000001001110000110011110011100011011001110101000101001111111001010111000111011100110110011111011010111000011100001111110110101010111010110100000110110010110010100011000111110111101110011001111111000011111111001111001001101011111": TestData(n, 2) = "?"
  636.     n = n + 1: TestData(n, 1) = "10010011010111111001010001110000011011100100100110011110011111010011011111111101111001100001100110100100100110011111111100011011100010011011110010010100010100000000010010001111001001110010111100001001010111110010110111111100110001010011010100001111101011100110010111110111110000111100110101001010111001101011001001000101100001000110111100010111001001001001101011000110001011100011100010110000111101111101100100100011101100011011110011110000111100001100001100100011000111110000100000110101100011001011": TestData(n, 2) = "?"
  637.     n = n + 1: TestData(n, 1) = "01111000000111010111111100110100011010111011110101000111000101111000111111100011010010001111001010111100111101101010000101110101000010101100001111010101011110011001011011100001110101101011111001010111001101110001110011111111100011000110100011111101000010100101010001001100101000100001000100000010101100011111001110101101111001111001110100011001101011001100111001100000010111000111000011001000011001000010011101011101110101010010110010111110111111010101100001111110011110011000010011000010010000110000": TestData(n, 2) = "?"
  638.     n = n + 1: TestData(n, 1) = "11100101001100110010000000001111111011001011100100111101110111101000111000110110001100101000101110100101001000011011000111010110011101100010000100111010111010011010010010101110111011110010110110011001110101100111100010100010101000100001000100001000100101010101001111010111110101100101100111010110100100111000010101001101011100010110000000100110111100101111100001010011001100000100010101111111110110010111011011011001010111011100001001110010100100110110110101001101000001011001110111010110100000111010": TestData(n, 2) = "?"
  639.     n = n + 1: TestData(n, 1) = "00101011100010110100010101100110110111001111000100100110011111000001101011100001110110100001110011111101001000100100010111000111110110001101101000101100011111101001010010001000111111110111011001100011011011010110000101101100100100011011101001011010101001100011111101110101111111010001010001001100110100100000011100111101110010011000011001001000001110001001010010101010000110101001011010100100111011010011011110101110110100010001000100100011000011110111111011000011101101100111101111100011000011010111": TestData(n, 2) = "?"
  640.     n = n + 1: TestData(n, 1) = "00000100100101110000110100100011111110100110000101010001100010000000111111000111010011111111111110011000010011010111011010101101011011011010011000100100101100010110111011000111001110011110001111100000101101100001100011111010010100110100111010100101011100100001100111111010001100000001100010001000111110101000010000100100110010101111110011111111001111111101001000111100100100111100001111101000111110011111001111111001110100101001000011100010001010100110101011011001000001111010101100100110001011110111": TestData(n, 2) = "?"
  641.     n = n + 1: TestData(n, 1) = "00000111111000010000101100011100110000100010111111110111011110010011000011110000001110000110001101101011010111010001100011000101100011111100010000010101010111111111010100000110111010001001100110111100011111000100101111111100010100110110100000101110010101000000000010000111111101011111111101110110111110111111111001101110100100110111101110111001100000100011011111010000101110011010111100000110100010110010001101001010100010000000101111110000111000001000010001000100010110011011111011101110100001101010": TestData(n, 2) = "?"
  642.     n = n + 1: TestData(n, 1) = "10101101001001011100001000001110010001110011001011000111110010110110100011111111111001010000101010011110011110110010010001011010011111101000011001111100000011001011011001001110110000101001011000100111100011000111110011100000010011000000101001010011000111100000111000101110110111100001110000101011010001101010101101101110011011111100111001010100011000111011101111011111011101010000100100000100110101111100000101000000001001001110000111100100111011011100101101010110100101110101010111001010110010100011": TestData(n, 2) = "?"
  643.     n = n + 1: TestData(n, 1) = "00111100000001100110111100111110110100001000001111100110011111100111110001100001100100110110000000011111110010111000111000101000000010000101011001010000011010110001111000010010010010000111010100110011000001000011110110110010010010011111111111111001100100010111101010000001100110010000110011000101000100001000001111010010101100001000101010101101001100000000001001101001011110001100100000000001110011111000100110101010000001111111111010001001011000100010000000100001000100011000100000110100101011000010": TestData(n, 2) = "?"
  644.     n = n + 1: TestData(n, 1) = "00001100001100010100000100001111110011001111010000111001001111100010101101011000101100010010101010000011010111100100101100001110011001100000001011000111010000111000001100010000000100100111000100100000010101110100010000101010101110111011101001111000010110111110010000110110001010001111100101100011101010011010100110000101010110010100111101100100011000001011111110111001001101100000000001010011000010100000011001001011110000000000010100000000000100111110001000100101000100000000001000001001110000000000": TestData(n, 2) = "?"
  645.     n = n + 1: TestData(n, 1) = "00010011100000101100010001010000111100001100101110110011000111111001111001111000010001011110111010100110101111100100111110000000001111010001100011100001101110100011010000010001111111000001111111010111001111001111111001000010000101101101000100100000011111011000011100100011001100110010000001000111111110100011111010101011000101111110000011001010101100100001001111001001000011111111010011110000110010100101111100110100111111011000110010010111000000010010001010010000110101100111110100100010011100110010": TestData(n, 2) = "?"
  646.     n = n + 1: TestData(n, 1) = "10011100100001100111000000111010000100000000010000011011000010100001110000110000110100001000001000011001011110010000001001000111000100100001000000111001100000100011000000000000000011000000101011010100101000000010010100010000011000011100000111000010100110101010010111010000010000110000010000000110010001000001100100000001001000110100011010101001000010100100000001001000100010100010111010010100010111100011000001101100000011001110100010010001001100110001000010001010001000010111000010010000111001011000": TestData(n, 2) = "?"
  647.     n = n + 1: TestData(n, 1) = "01001001001000000100101111110000000010011000000110011101110111111001100011100001000000101000000000000110001111001011010010110011101110010000001001001000000000000000000101000000010001111000011000010000000011001100110000000011100100100011001111000100100010011100010010010111110100010010000111001110011110010000110010100000000001001011001111110010001001011110000000011011001111111100100000110111111110000000111001000000000010111010101011000011111001110010000010011010001001110001011100010110000001111101": TestData(n, 2) = "?"
  648.     n = n + 1: TestData(n, 1) = "10011000000000000100000010101001000000001100100000011001100011010001000011101000110010000100001000000000100100000000000011000000000000110000010100010100000000100000010110000011010000000000110000000000000000001001100000000100010000100000000100000100010000000000100010011110100100000000000000000001001001000100000000001000000000000000000000000000001011010010000000011000101000010101001000101000010110000100100101000001100000000000001011000000000010000000000011000111000000000010100100000100000001001000": TestData(n, 2) = "?"
  649.     n = n + 1: TestData(n, 1) = "00001000100000100000000000001100000001000011100111101000000001100011111000001010110000000100101000000000100001000100101110000000001000110000010100001000100000100001110100000000000100000000000001010010011101010101001000000100100000110000110000110000010001000000010000000001000000000100000010001111000111000000000000100100001001000101100000000010000001000000000001000000100010000100000000100000001100000111000000010001110010011010000000000000001101000010000010000100000011110000100000000001000000000001": TestData(n, 2) = "?"
  650.     n = n + 1: TestData(n, 1) = "00001000001011110101000000001000101000100000010110110000000001100000111000001000101001000000000000001100100001100000101100011001000001110000010001001000100100000011110011001000000100000000010001000110000001000101001001001001010000110100000100101110010000011000000000010000001100100000010000000000111000001010000000000100001000000110000100010100001001100000000000001000000100000000001000101000010000000100000001110010000100000000000000011000000001101010000010000000001010001000010010000000100100010000": TestData(n, 2) = "?"
  651.     n = n + 1: TestData(n, 1) = "00001010101000010001100100000100000110111110000001111100000001110000001000000010111101010011000000000010100001110000110010011111100000000000111000011100100000100001100001000010011000000111100001010010011001010011001110001000010000000111010100011001111111111100010000100010000100000000111001000011000000100110000000111000111110000100001000100110100010001001100100001000111000001000011110000111100100011100001000000001000100000110011000011000000001000010000000110011111010111110000101010001110100110000": TestData(n, 2) = "?"
  652.     n = n + 1: TestData(n, 1) = "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000": TestData(n, 2) = "?"
  653.     n = n + 1: TestData(n, 1) = "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000": TestData(n, 2) = "?"
  654.     n = n + 1: TestData(n, 1) = "00000000000000000000000000000000000000000000100100000000010100000000001000000000000010001010000100000000000100000010000000000100000000001101000001010000100000000000010000000000000000000000000000000000000011000000000000100000000000000000000000000000001000000000000000010000100000000000000000000000010000001000000100000000000000000000001000000000001000000000000000000000000100000000000000000000001010000000000000000100010001001000000100100000001100000000000000000000000001000000100000000000000000000100": TestData(n, 2) = "?"
  655.     n = n + 1: TestData(n, 1) = "10000101000000000001000000000010000000001000000000000110100000000010000111100000000000000000000000000000000100000000000000001000110100100000001000001000000000001000001000000000000000000110000010000000000000000000000000100000000000000011000000000000001000000000000000000000000001000000000011000000000100001000000000000000000001000000010000000000001001010000000000000000000000000100100000000000000000000100000000100010001000000000010001000001000000000000100000000000011110011000000000000000100000001000": TestData(n, 2) = "?"
  656.     n = n + 1: TestData(n, 1) = "00000000000000001000000100000000100000000000000000000000000000000000000000110001000110000000101000001000000010010000000000010000000010000000000000000000000000000001000010000000100000100000000000000000000100100000100001000000100000000010000000000000000001000100010010000010000100000000000000000010000000010000000001000000100001000000000000000000000000000000000100100000100010010000000100000000100000000100000000100000000000000100000000010000100001000000000100000000000000000000000000000110000000000000": TestData(n, 2) = "?"
  657.     n = n + 1: TestData(n, 1) = "00000000000000000000000000100000000000000000000000000000110000001000000001000000000000000000000010000000010000000001001000000001100000000000000000000000000100000001000000001000001000000000000000000000000001000000100000000000000000000000000001011000000000000010000000000100000000001001000000001000010110000000100000000000000000000000000000000000000000000000010000000100000010000000001000000100100000000000000000000000000000000000000001000000101000001000100000000010000000001000101000000100000001001000": TestData(n, 2) = "?"
  658.     n = n + 1: TestData(n, 1) = "00000000100000010000000000000000000000000000001011000000010000000001000000000001000100000000010010000000000010000000000001000000010000000010010000100000001010000100010000000001000000000000100000000000000001000000000010010000010000000010101000001000000000000000000000011000000000000000000000000000100000000000000000000000000000001000000101000000000000000000000000000000000000000000000000000000010000000010001000000000000000000000000000000010001010100000000001011000010001001010001010000000000000000000": TestData(n, 2) = "?"
  659.     n = n + 1: TestData(n, 1) = "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000": TestData(n, 2) = "?"
  660.     n = n + 1: TestData(n, 1) = "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000": TestData(n, 2) = "?"
  661.     n = n + 1: TestData(n, 1) = "11110101001000011101011111110011000011111100111111111110011111111111101011101000001110011111001111000011000100000111111111110011110010000001101011111010111001000000010111001111110101111000111001010000110011001111110000100111100100110011111111110011011010011100100111111111110100011110000111001111111111110110110010010000111101011111111111110010011111111111000101111110101111111111111000110111111110000111111111101011000101111001101011000011111111110010000011110110001101110010011100010111100110001101": TestData(n, 2) = "?"
  662.     n = n + 1: TestData(n, 1) = "01000110000100000101000001010000011010010000000000011000010110000001001010010110000000001000010000011010000100000011010010001001000010000010011001001110000000001010010001010000010110001011111111000100000010000000011000010000100100000100000000001000010001000010001010010000100100100001000000000000010100110101001000000111000001001000001000011001001001000010011000000010110110010000100001010110111011000000100000000000100100001100011000000101101001000010110100010010001101010000010011110000000000001100": TestData(n, 2) = "?"
  663.     n = n + 1: TestData(n, 1) = "00101001011000000000110000110100010000100000000011000110110000100000100000100011000101000100001000011000001110000101000100011010110000001110010100000110000011000000000010010011000000000000010000010110000010001000100110110101000000000000000010000000100000100001001001010000010100111000110100000001010000000000011101010001010000000001110000000000001010001001011100000001000100000100100001010001000010111100000000000101100001001000000100000000000000100000000000111000001000001000000001100000110100001001": TestData(n, 2) = "?"
  664.     n = n + 1: TestData(n, 1) = "00101101000010000110000001100000110000000100000000010010000000000100100001001001000000000000000001001000000100000010011000000000000000000001000101100000101100001010001100001000001000110100101001110001011000000000000000101000100111100100000000010001001110001001010010000000000000100011010000011100000001000000001010110100000101000000001000000000011000010011011100000010100100100000000000000000001001001110000001010000100000010000000000000100100110011100100010100010000110001001000101100001001010100010": TestData(n, 2) = "?"
  665.     n = n + 1: TestData(n, 1) = "00000100010110011000000000100100010000000100000001010000111000010100000010001100000010100000110100100100010000011001001001000000001101000000001010101001100001000100010100101001000001001000010000000000100000100100000001010000010101010000000110000101000000000010000001011100000111000100010100000110000011010000100000000001010010100100000010100000011000000010100100011000100000000000000000001000000000001110101101010010000000011000100000000101000010110110110000010001100010000001001100000010011000001000": TestData(n, 2) = "?"
  666.     n = n + 1: TestData(n, 1) = "01000000000000000100001001010000011110101010100001001000000000000100010100000010000100000100000011001000000001101010100001011100000100011100011000000110000100000010010000001000100100000001101001011010000000101000010000000000011010000001101000000010001000000000010110001100000010110001011000000001010100010000000010010100100100100010010000010011000001000000110000101100110010110000000011000000101010000000000011001010000001010110010001000000111010100110000010001001000100100000000001110001100000000000": TestData(n, 2) = "?"
  667.     n = n + 1: TestData(n, 1) = "10000000000100001110001001011001100101100000000100000010000011010001000110010010101011000001000000101001000100000000000000110000000000100000000001001010001010100001000001000100100110100011010000001001000010000000010000000000110101000000000010000000100000000100000100000000010100000000000000000000100011000110111000100000110000001010000100000100010001101101111010000001100000000000000000010001001101000101100000000010100000001001000000000000000000001001000110000000010001000000000111001000001001000100": TestData(n, 2) = "?"
  668.     n = n + 1: TestData(n, 1) = "00010001111000000010010000000001000000101000000100011000010001011001100010110011100000000011001000000100000010010100000001000110010010000000010010011101001001101000000010000001000010011001100101000001000110001010000010010010010100101001010000001000001101000101101100000100100010101010000001000000000000010001000000000000100010010100000000100100001001000001100000011111011100100001000000100000000010000000001001000010001000000010000010101010011110000000000001000001000011000000001000000000000001000001": TestData(n, 2) = "?"
  669.     n = n + 1: TestData(n, 1) = "00000111001100000000100100010000000100000111100100010000100001010110000000000000000000000000000110000100110100010010001000001000000010000001010001101110110100000001000001000001100100101010000001100001110000000000101100000000000000010000001000000000111000000010000010101010001000110000000000000010100110000000000000010010000101010000000000000010010000010101110000100100000000100010100000001101000001010010000000000000001001000101010001100001000001010000000001001000000010110010000010000000010100100010": TestData(n, 2) = "?"
  670.     n = n + 1: TestData(n, 1) = "00000000001100001001010000001000000101011100100101001011110010001001000001011010000010000000100100001010010001111001000100000000000010000000010000000010000000000001010000100000010010100100000001000101010100100000110011100000000010010010001100000000101010100000100000001001110000000100010000100101010101100100011000100100001001000000101110010000010000000000001000000000101010001001010011100000000100010000000000100000101000000100000000011001000100001000000000010000001110001000000000100010011010010110": TestData(n, 2) = "?"
  671.     n = n + 1: TestData(n, 1) = "00010001000000000101011010001010000001000001010100000000001011000010000000000000000001010000100001000101010101100100010011100100100000000000100000001000000000000100010100000000000110000010010000000110000100001100110101110000110001000100110000010000010000011000000010100000100001010100010110001000100000000001000000000000001000110000001001000111010000010100011000000010010000000101000000000011001001101100001000000010000000000000000000000011101000000110000000110010010000110000001000000000100010000001": TestData(n, 2) = "?"
  672.     n = n + 1: TestData(n, 1) = "00000000000110100000100011000000100000100100000000000000011011100000010101100001101010110000000000000000000000111101001001100110001000110001001101000101010000110010010001000000010001000000001000011000000000000000000010000000000001000100000001010010000001000001000101111110000100010010000010011010000000000000100100001001010100001000010100001001000100101000001000000001000000010101000100000010000001110000000000000000001011000011001000010000001110001001000101011110011010000101000000000000000110000000": TestData(n, 2) = "?"
  673.     n = n + 1: TestData(n, 1) = "00010000100010110000000010111001000111010001000000001000100010000100001010010000000001101010000010000001000000000011000010000000010100100100010000110100000100001001100011010010000000011110100010111010110001110000100000100100000100000000010000000000000000110001001010000000000000100100010001110001110000010101010000001010000011101101011010000000001000110000000110110001001100101010000100000001010110001011001100010010000010100011100100001001100000011110000000110001110001100100000100101000101000010000": TestData(n, 2) = "?"
  674.     n = n + 1: TestData(n, 1) = "00110000000000000000000000000010100000000001000000000000000001000000001000111000000100000000100000010001000000000010000010011110010100011110000010000000000000000000000000010010010000000001000000000000000000000000000000010011010000000000110000000001010001010110000000100000000000010010000000000111100000000000010000000000100000001010000000000001000010001110001001010100000000000000000100000000000000001000000010011000000000000000001000011010000000011100000001100000000100110000000100100101011100100100": TestData(n, 2) = "?"
  675.     n = n + 1: TestData(n, 1) = "01000000000000000100000101010000000010010000000110011000010100000001000010001000000000101000000000000010000100000011000010000000000010000000000001001010000000000000000000000000000000001000010000000000000011000000010000000000000100010000000000000000010000000000010010010100100100000000000000000000010100010100000000000000000000001100001000000000001001000010000000000010000110010000000000010000111010000000100000010000000110000010001000000000101000000010000000010010001101010000010000000001000000001100": TestData(n, 2) = "?"
  676.     n = n + 1: TestData(n, 1) = "00000001000000000000000000000010000000000000100000000100000000000010000000000100000100000001000000100000001110000000000000000010000000000000000100000100000000010000000010000101000000000010010000000000000000000000101000000000000000001000000010000000000000000000000000000000000000000001000000000000010000000000000000010001000000000010100000010000001010000000000000100000000100000000000101000000000000000100000000000000000000000000000000000000000000000000000000010000001000000000000000000000000000000101": TestData(n, 2) = "?"
  677.     n = n + 1: TestData(n, 1) = "11100110000000000000100000010010000010000000000000100100000010010000000000000000000000000000000110000000001011000000000000000001000000100000001100000000000000001001000000000100000000000000000000111000000000001000000000000000000000100100010000000000000000000000100100000110000000000000000000000000000000000000000111000001001000000000000000010000001000010000100000000000000000000000000000000000010000101010001000010100000000000000000000000001100100000000000000000000010000000100000100000000000000000000": TestData(n, 2) = "?"
  678.     n = n + 1: TestData(n, 1) = "00000000000000000000011000000000001000000000000000000000011100000100110000000000000000100000000000001000010000000000100000000000000000010000000000100000000000001000000000000001001100000100000010100000010001000000001001000000000000000010000000000000000000000001000000000000011000000010000000000001000000000000000000000000000000000000000000111000000100000001100011000000000000001000000000010000101000000000000101000000000100000100000000001000000000010000010000100000000000000100000000000000000000000010": TestData(n, 2) = "?"
  679.     n = n + 1: TestData(n, 1) = "00000000000010000000000000100000000000000000000000100000000011000000000000000010000000000000000000000001000000010000000000000000001000000000000001100000000000000000010000001001000000000000100000100000000110000000000000010000000000000001000010000000001100000010000000100000000000000010100100000001000000000010001000000010000000000000001000000000000000000000000000000000100000010000000000000000001000100000000000000000001000001000000001000000000000100001000100000000000000000000100000000000000000010000": TestData(n, 2) = "?"
  680.     n = n + 1: TestData(n, 1) = "00010000000000000000000000000000000100000000001000000000000000000000000000010000000000000000000010010000000100001001010010001001000000000000000010000001000000000000000100000000001000000001000000001000000000000000000000010000011010000000000000110001000000001000000000001000000000000100010000000010000000000100000000000100000100000010000100000000000000000000000000000000000100000000000000000000100110000010001010000111000000000000000000000000001000000010001000000000001001000000000000000000000010001000": TestData(n, 2) = "?"
  681.     n = n + 1: TestData(n, 1) = "00000000000100000000000000000000010000100001000001000000000001010000000001000000000000100000000000000000000000000000000000000110000000100000010000000001000000000100000000000000000000000100000001001000000000000000100000000000000000010000000000000000111000000000010000010000001000000000000000001010000000000000000000101001100000000000000100001000000000000000000000000000000000000101010001000100000000000000000100000000010000000000000010000000000000000000000000000100000000000000000000000100000100000000": TestData(n, 2) = "?"
  682.     n = n + 1: TestData(n, 1) = "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000": TestData(n, 2) = "?"
  683.     n = n + 1: TestData(n, 1) = "00000000001000000000000000000010010101001001000000100000000011110001000011001100000100010001000000111001010000010100001001100000000100001000001100000010110000000100100011000000000000000010000101101000100000011000101001110000001000111000100011100010001000001010000000000010000001100000000000011000000000010111000000000100001000000000000000000001000001000001000100010000011100001000001100000001000110101000001010000000000000000000000011000000000000001000000011001000001010000001010101100010010000000100": TestData(n, 2) = "?"
  684.     n = n + 1: TestData(n, 1) = "10000001100110110010010000000000001000000000100011100010000010100101010001100000100010001001001111110010000010000101001100000110000100100000111100000111100101010000101000010000000010000111010000000011000000101100001010000100100000001010101001100001010110001000010100001100100000000110100101000110000101101110010101000011010010100110010000100010110111000010011000000000100111000010110110011110000010010001010011101101101110010011000011110010010011000001100000100000100000000010011011000110010000000000": TestData(n, 2) = "?"
  685.     n = n + 1: TestData(n, 1) = "01001100101100110101101011000000100000111001001011100101010010101101000111100010010110100100001100011111111100111111100001010100100000111110000001000101010110000110010000010100100110010001000001110110010111100101001011111011011000000100000000110001110000010010001010011000010001110001001010111111001100101011010101111100110010001001010100011001000000010010000111100011100100111001100000000000100001111111100000000111111000100010001101101100011100011110011010111101001010010100001011000010100100100011": TestData(n, 2) = "?"
  686.     n = n + 1: TestData(n, 1) = "00100100110010011100000010000100010011110000101011111000110110100000110111000100000100000011110100000011001000010010011110010000110011111010111001101111001001000011000011000000101101000011100000010101001011100000110010010010011000011100000010001000110011000011001111101100011101011010100001101100110000100001010110000001011111011100110000010100000001000010000000000010010000000000011000101011001001101000000010000000100000010001000001100110000101001111000000000011000000100100010010001111100010000100": TestData(n, 2) = "?"
  687.     n = n + 1: TestData(n, 1) = "00000100010010000111111000011000001000001000000010000110111000100100001000000000101010100010101001111011111100010001000000110000000011001100100001000000001000000000000000100000011010100101111000011001001011100011010110010000000000011111101000100000110101011011001100110111101000011010000100001010000000101110110110010100100111100100000000000100010001001000011000000000000010000000100000000000110000001000100000000011000110010000000001100010010000000001000101001111000011010111001001000100000110110110": TestData(n, 2) = "?"
  688.     n = n + 1: TestData(n, 1) = "00010011011010111001011100100100101100010110100111001001100011000011110101001110111001000010011000011001000000001000010100110101010000000111101000100110011111100000000010110000010001110001100101000011100001010011000010000111101110000111000100010110101001110001100010000000010001111000110001110001000001100000110111111110000101110100000101000011110011000101001101101100001000100100000000000001000000000100000101000001001000110110110001010010000001010100001101000010100000000001010001111000011010100101": TestData(n, 2) = "?"
  689.     n = n + 1: TestData(n, 1) = "00000000000000001001100001001000010101000000010001000000000001010000000000001000000000000000000010100001100000100010010000100000000011000001001111000000000101011100000101110001100000001100000100000100000101001000100010000100101110000000010000101101110101000111000010110011000000111010000110100101110001000000001001101000010000010001000010010000100110000011010000100001001000100011000010000000000000100000010000101100100000010000001100000100000000000000000000001000000110100010100110000010001000010000": TestData(n, 2) = "?"
  690.     n = n + 1: TestData(n, 1) = "00100000010001011000001000001010000100100001100111000000010001010001000001001011001011101000001010000001001010001010011100100001011000010100010011010100000000001000010011100000000100000100000110000101011001011100010111000000100011001010011100110111011010100100000000100000000000000001000100010000011001000000001001101000000110001000010011111000101000000000000010000100000000100000000000000000000000001100010000001111100110000101001000110000010000000101000001001000110000001000001100011000010011000000": TestData(n, 2) = "?"
  691.     n = n + 1: TestData(n, 1) = "00100000000000001000111000000010010001100011000011000100111000001100000111000100010000000001010011001000001000000011111000011100100000000000000100001100010010010100000010000011111101010010100101100000001110010010000100000000000001010000000000000001010010010001000000100000011111000011010001001100000000100011101000000001001010000000001101111101011000100000110011000000001001000000010000000000011010000001001001000100000000110110010000110011000000000010010110100000100001001010100000000001000100001000": TestData(n, 2) = "?"
  692.     n = n + 1: TestData(n, 1) = "00001100001100010100000100001111110011001111010000111001001111100010101101011000101100010010101010000011010111100100101100001110011001100000001011000111010000111000001100010000000100100111000100100000010101110100010000101010101110111011101001111000010110111110010000110110001010001111100101100011101010011010100110000101010110010100111101100100011000001011111110111001001101100000000001010011000010100000011001001011110000000000010100000000000100111110001000100101000100000000001000001001110000000000": TestData(n, 2) = "?"
  693.     n = n + 1: TestData(n, 1) = "00001010001000010000010100010010000011000010000110000010101110101011000011000000100101100000010000001100101010000100010000001101001000010001100110000110010000000000101000000000000001101000100000110110000010100110000111100110000000100000000010110000100000011000010000010001000100010001000001100001101000010010001000000110000010100000000010010110100010010011000100100110000111110001000010111000010101100010000001000010010001001001010000010000000010110110011000101001011000011011000100011100100000010010": TestData(n, 2) = "?"
  694.     n = n + 1: TestData(n, 1) = "00100000001000011000000000100010000000001010010000000100000100001000010100001100001000110000100010011101001000010000010000000100001010100100001000000100110000100111010000110000110010000010010000101001011101100010000100000100000000000100000000001011000000000000001100000100000000001010000011000100000110011000010001100000000000001000001000011000001000110011000000000100001010000000011010100000010001000100000100000010100000110100000011001010110000000000000011000000000000000000010100011010001100001101": TestData(n, 2) = "?"
  695.     n = n + 1: TestData(n, 1) = "00110011100000011100111100110011001100001100110110110011010111111001111100110000001001010100001001010111110101100100111110000111111111100111101011100011001111010100100000010001111111001101111111100111001111001111111001110010000101101111001100111000011110011001111100100111010100110010110111010111111110001111111100101011000101111110011011011111001110000001001111001111000011111000001011110000111110011111111101110100111111011001011111110010000010010010000010010000110011110101110101000011111100111110": TestData(n, 2) = "?"
  696.     n = n + 1: TestData(n, 1) = "00100101100100010000001001001010000001110100000101000000001011001000110101000111000110111001000000100001000100100110000000010001001010000010001000000000001000010001000100010100110110110000010100001010010100010100011100000010101110000101000101000000011000110101011100001000000000100011100111010010010000100111000010010000010000101010000001000000100000010000001010100000001000000000001010000000010001010000001101001111001110110010000001000000110100000010001000000000000010001000100100001110000100110010": TestData(n, 2) = "?"
  697.     n = n + 1: TestData(n, 1) = "01100010000100001101011110010000001010011110010010000110000100000001001011000011110000110001111000000000110100000001100000010100001000000001000001010010000000001000011100001010011010010011010001000000110011011001000001000011100001100000000100001110000011111110101000110100001000101000000111000100110110100000010000000011100000110100100010000000101001001100000000001010001010000001100100110000000100000111000001100010000000000000110010001000011001000101000000000000000000000000100000000001100000101000": TestData(n, 2) = "?"
  698.     n = n + 1: TestData(n, 1) = "00100000100001101010000001000100010000001011111101011101011111100010100000000000000010110100100001000000000000001010001000000100111001011010000000101000001001000000110011000101010010001110010000000000010001000100001010100000010010011011001000111010100000000000011000000101010010001100100011111110000110000000011100001100010101000001010101000010001010000000000000100000001011111110000000100000100000010100001010010011010111000011000010101101010010111000000000000001000001001011001010000100000010001010": TestData(n, 2) = "?"
  699.     n = n + 1: TestData(n, 1) = "11100000010000010110100000000110001000000001100000111000010000101001011110000100010000110100000101000011110000000000100100101010111011010000001110000010000110000001100010010000111010001100010001001000010110001000000110111001010001111110000010000100100100000000101110010000001100010110010011101001001001000000100000000000100010001001100110100011000001011100000100000010101000010001001010011000010011100010010100000010000001111000001001110000110011010001100000110001011000000000000101001011000101000000": TestData(n, 2) = "?"
  700.     n = n + 1: TestData(n, 1) = "00110000001110000010001000000100100000010101100000011000110000100100000001110011000001110101000001000000000110000000000001010000111001010000010000000000000000100110100110100000010011011100111000110000011000110000100010100010110000011010010100000000100000110100001000000000000001100100000111101000010000100000000001000000000000100001001100010010110000000011100000010000011100010000000000000101000000001000000001000010000001000000000000100000010010010000000001000011000000010100100000000000010000100000": TestData(n, 2) = "?"
  701.     n = n + 1: TestData(n, 1) = "10011001110100010000011010000011000010011011011001010111100001100010110101001010000001100011000000110000000000000000101101000011101110110000111111111110010000110100001110011001011000110101001100000010111110001010001000011011011001010000000100000110001010010000011110100010100011000101110110100100110000011000100001010100110011001110010000001001110010001100000010100110101111010110000101000111111010000100111000001110000000000000000000110001101000000011110001011110000100000000000100110010000100111000": TestData(n, 2) = "?"
  702.     n = n + 1: TestData(n, 1) = "01111000100000000100000001000001101000000000000101000000001011010001101010111000010011110010000000000000111011000010110011000000001000100110010000000110111000000000000000000100011010000000011001010100010010001100001000000001000011100001000000000100000000000000111000010000001001000000101011010010000000011000000000000000111000000000100011001100010001001100000000100111001000000001000001010001000000011010001000000011100110000110000100000010010001000001000000000010000000111100010000010101011000000111": TestData(n, 2) = "?"
  703.     n = n + 1: TestData(n, 1) = "11010000010110110011000011100001011111011000011110011101100000110000100000010000010001010000111110010110101001000000101110000110001000010001110100000010000001000011101101010000110010001100000100000011101100100001000000001100111001010100000100110001011100010000010111001110000100010010000010001111100000100100100001000110110001100110001101111011000001011001000000011100100101010011001100101011010001100010011010001001000001101101111011011111000011110010011000000000010010110010000000110001000100110111": TestData(n, 2) = "?"
  704.     n = n + 1: TestData(n, 1) = "00000100000010111110001000101100000010001010000000101101111001011001001011100000010101110001111001010110010000111100000010000111100100111101001000001110000110110001000000100011001101000011111101100101100011000100010101001000111111000011100000101010011000100011010000000000001100000001100111000000010111000000000100101000000110001000110000000000001000100001111000000010011001111000000010100000000001010110001101001000101000001100000100000010000011110010110111000011101011111100000110100011001100010000": TestData(n, 2) = "?"
  705.     n = n + 1: TestData(n, 1) = "10101110010100010000010000010000011111110110000001100001001110100001000011000000100100100000011001101101011010010100101000010000100111001010010001001100011000100010110010001111000000101000100001111011000001100000111111100110010011000000100011011000000110000000011100010011000100111111100001000001010001111100000100100100001101100100100000010010100111100101001000110011010111110010000111101000101001010001000101000010011001000111101011100010001000110010010111000011000010010100000000000010001000110010": TestData(n, 2) = "?"
  706.     n = n + 1: TestData(n, 1) = "00000111101011000100000110000011010111110011111001001111011000010000010010010101000001000001100100100000000010000000111110010110001100110000110011000110010001000100110011111000000001111100111111001000001001001110011010010000011001100001010000000011111111110100011111100100001011111111010000001100010100011010100000110010011100111010000011001110000000001101001010000001110011000010011100001000110010100011111100100001111110011100011111100100000110100100100001001001101100000000000110011000001000000010": TestData(n, 2) = "?"
  707.     n = n + 1: TestData(n, 1) = "11111110010011111111100001100100100001111111110110101011110000111101011111111111110011100111111001100111111111111111110010101010111111110011111111110011110010000001111111100111111110111000111111100001100010011001111111111011100010101101000100111111111010110011110011110011100111100001000101111100111001010111001010111111100001111011000100000111111001000111100100111111111000000001000000110110111001111000001010011001111111011011111000000100111110101100000011111111001111100001101100011010001111111100": TestData(n, 2) = "?"
  708.     n = n + 1: TestData(n, 1) = "00111010110000001111101100000000010100000110001000000001010110100100011011110111100001001110000000000000000100001000010101011010001011101000111011010010000000000001101101101001101001100001110000100100100111000110000101101010100000010010001000001100110000001011010000000000100000011010101100001001001101100100010010100001100001001100101000000000000000110010101010000000111001010111100100110001000011001100111111011001101110000010000111101000001100000000000000100010111110100010101000001011100001111001": TestData(n, 2) = "?"
  709.     n = n + 1: TestData(n, 1) = "00000001000011100110011001101000000000001110000001011000100011000001000101111001101110011101101111101110111100100010010110110011001000100000100000000101110010000010100111011110000111101001011001111100000110000110011001010001000000011100001111111101111100101101111011000000000100000000001111011000000001001011100100010001000001001100010000010011001110011000110011101001010110100110001110010000101111111011101101101100000010000100001100001100100011101011110110000110000010100110100010000110100110100100": TestData(n, 2) = "?"
  710.     n = n + 1: TestData(n, 1) = "10111000101111101010011001001100001111110011000111011010000001110001010110100110011010110000011100110011100010100101010010001100010010000111001010111011000110110100000000110010100011001010001100111111111010001111001101000111010111111100100010000011110010011010100100100110001000010010011101010000000000100011001000011111001110010011101100011111110010000111100001001001001000100001000101111001001000111000110011001010101010010101100000010101000011100011001000001000100110000000000000111000001110010001": TestData(n, 2) = "?"
  711.     n = n + 1: TestData(n, 1) = "11111001000101111111100011111101110101111110110001111101010100010000111111111111111110011111001110101111001101011111100010111111110100011100111110101110011001110011111111100101011000000101011100110110111100000101110000100100111110011110000111111111011011111100001100100110011001001101000001000101111001111101011101010110111100011100010011001000010000111110010001011110011111111111111001010111111101011111001110000000101001111010100111111101011000100101000011111001011001010011001101000110000100111111": TestData(n, 2) = "?"
  712.     n = n + 1: TestData(n, 1) = "11001000011100110101111111001111010111100011011111101101101011011101101010011111111010111001110011110011111001000011111111111110001011111100111000011111111111111011000110011100110011001111010000010010011011011111101010011100111111111001111111001100111111101001101111010111110101100111111110011111110101101110010010001101000000011111110000001111111111111100000101000000111100011011001111111110011101110010101011111111000110111010001100100111111111111111111100001110011000011100001100011010001100000111": TestData(n, 2) = "?"
  713.     n = n + 1: TestData(n, 1) = "01110000001111111111110011101001011000011111111111001111111100111111111111010110100011111110101110101001110000111000011111111001000000111100111100111100111101010011100111111110011111111100100111010001111111001100111001111111110011111111111101011111111000011111110100010101111110110111000010011110000100111010110010011111111100100111111111111111101101111100101010011110110110011110000110000001101101111101101111110011111111001111111101101101000100111101011101011111111001001111111111100110011111110010": TestData(n, 2) = "?"
  714.     n = n + 1: TestData(n, 1) = "00100110010011111110100011001111110011100111111111111111111111111100010111101000111111010111111010111010010111111001000011100111111111001111001111111111111100111111111111110101001010111101010010011100101011111000001010110111001100110000111111110011001101010011101010011111111100100110011111110101001111111100100001110011100111111111111111110011111111001110000010111001111001101100010000111111001101001011111111111010110001011111110011111111111001000011100001100110000111111100110010011100101011001111": TestData(n, 2) = "?"
  715.     n = n + 1: TestData(n, 1) = "01111001111110000010111001111101011111111000000101011111111100100111100001111111001101011110011110000111100111111110100101110000100001000010111101110101110000010001001110101111100100111111010010001100111111111111100111111111111111111110011111111110010011111100100001000011001001110011111111111111111111100001111111001000010011111111100111111100100001000011111111111111000000111111111001010110011111100110011001110011100111110011100111110011111010111100111111100000011111111110011110011001001101011100": TestData(n, 2) = "?"
  716.     n = n + 1: TestData(n, 1) = "11111111111101101111111100111001111110010011111000011010111111111110011110011111110010011111111111111100111111111111100111110011111111111001111111110110111111111111000101000011111111111001000011110100010010011111001111110010111010000111110010011111111001001110011111111101010011100000011100111111010100001110011111111111111111110110111100101110111111111010111100111111111111111100001110000110011111111111100100111111111111010111100111111001100111111111100001111111111111101010110111111001111111100001": TestData(n, 2) = "?"
  717.     n = n + 1: TestData(n, 1) = "10111001000011101011111011000110000100101000111000011110110001111100111101101000000001110010100001000111001001111010101011010110011110100110010101101001100001001000000100110000001011011111010000101010001011001011111101001011010110011010100100110101010101011000000111010110101000100111000000010000100111000111000001000101111101011100000011100111000001001011000000000011001011110010110000110001111111010101110110111110101010000001011011101111011100010101001110000111101001010001011001100100110011101111": TestData(n, 2) = "?"
  718.     n = n + 1: TestData(n, 1) = "00011000111110101110110100111010001110101001010110011110000101101100100000101000111000111100001111101110110011110111010010011111011100101001010110000110011110011001111000000100110101010010111100001111101010011101110110000111111100000101111100101011110000010001000111111010111100101010111110010011111100111100111100100000011111100100111101111011010111000110011101110000110011001010110101110001000100000100001001010101010111110001011110000011011111100110011001111110011111011000100110011001100000110100": TestData(n, 2) = "?"
  719.     n = n + 1: TestData(n, 1) = "11111000010101110101001110011110000111001101100000010000110100111100111110101000011100001000001011101001100110100101001100110101101100001111001000101101100010010011110100010000101011010110011011011001100001100111111001011001100101010111000111000010111111101011101011010100001101011010000001010101101011001100111010110011101010010010000100001101010101011101111000010010100110111101101110011101001001011111101000111101011000010001110000110010001100101010101111010111100101100001000000111101101011000010": TestData(n, 2) = "?"
  720.     n = n + 1: TestData(n, 1) = "10000000000101100111000000010100011011010001111000101010111110011101101100011101001101111001000100100100000101111001110010011110010100011010100111111111101000100011000101010011111000011001111000011000000100010001000011100110111000001010111101001101001000100010001011100111111001111010011010010010111011111011001110111000001000110000101011010010010000010001100011100101010101101011111000111011101010101111111010001011000111110011111100010001010011011000100110011010101010110011100011010011111000111011": TestData(n, 2) = "?"
  721.     n = n + 1: TestData(n, 1) = "11010000010011101000010111000000011000011010011110010011001110001001010110110011100111000000101011100110101001110011110000000001110100001010111111111111001011011110000001100111111010100111110101001100010110000010101100110001000010011010100001001100110011101101111100100110110110111010100100010011000110111001101001110111101010010000011011001001110011111111010000011111011100111010111110110101011011110010011010000100101000010001001011100111100110101010101011001011011001100110101001111001010000100010": TestData(n, 2) = "?"
  722.     n = n + 1: TestData(n, 1) = "11010110011010111111001111010011110111100111001110010011101000111010010011001100011110011010000101010110111101011101101011010001111011001111010000011010110000100100011111000001110100110000100110010000111111010010100111000100101110110100110000001010111100010000101000100010100111000111000010000010010110101111001000010010011100111010000111010111011011011000010101100111100110010101001101101101100101100111100110110001101001001001011111001110100010101101110000010101111101010011111000111100000111010110": TestData(n, 2) = "?"
  723.     n = n + 1: TestData(n, 1) = "00000100110111011101011011011101001011000100011001010111110100001100000011011001110010110011101111001111111000100111010101100111001111001101100001001110111110010110110101001001001010001100001100001010101011001100000100011000001010101001100100100100001111010110011101101110100101111100101001101001001010110010001011111111110010111001100000011101111101001101100101100101110101101100111000111010001110000111100100000100011000010110111110011000000101000111111001110011011111000110111101010111100001001101": TestData(n, 2) = "?"
  724.     n = n + 1: TestData(n, 1) = "01111111101101010001101000100100111100001101111000111100011111000111111101101001100100110001101111001100110100010110111100010010111111100001100011010010101111111111001111010010000000100001101101111010011101000110111110101110011111111101001000000000000011100001110101110100010011000111001011111100011110001110001001011001001101010100000101101100100001110110111111111111000100000100111011000111100111111000101110010110101010011010011011110100001011100001110011110111110010010000010100010110101011111010": TestData(n, 2) = "?"
  725.     n = n + 1: TestData(n, 1) = "01010010100000101100110000111011100101010111001101011001101011110001001011001111100011011101011110001100000001111100111010010010101101111101100100000110100010010101111110011111110011001101001001100011101000100010110001011000001111011001100101110001110111101110000011011010101111000001111000011010101101110101001011011111110101100100101100110011000010011101101001110111000011010111001100101100001101001001100101011100111010000010110100000101111111010001110000110101110101000110011001011011011101000110": TestData(n, 2) = "?"
  726.     n = n + 1: TestData(n, 1) = "11001000101011011111101000010000110111111111000011010000010101000000100110111110010000000111110110111111100110101010111110011010001110010110100101000010111111000000111100111000011100100111001100111111110100010110000010010011000111001110001110110100111110101111011010100010000101001001101111111101010101111010111111001001001111111100101011011011101001100000100010111110101010100001110000110011001110101100101000101000111100100101110110011111001101011001100011100101001001100010101010011001010001111101": TestData(n, 2) = "?"
  727.     n = n + 1: TestData(n, 1) = "11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111": TestData(n, 2) = "?"
  728.     n = n + 1: TestData(n, 1) = "00100000000010000000000100000011000110110001001110101010010011010001100000101001000000000000010001110100001001101000001000000000010001101001011000010000000000010000000010011010011001001000000100000100000000001000000001000101001000001110001001000100000000000100000111000011010000000000010001000000110010000000011000000000100100001000001000010001001001110000000010000000100000000000000010000100000010000000101110011000001000100000011010100001010000001000010100000000001000001100000100010010000101100000": TestData(n, 2) = "?"
  729.     n = n + 1: TestData(n, 1) = "11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111": TestData(n, 2) = "?"
  730.     n = n + 1: TestData(n, 1) = "00001101110100101100011001010001001010010110000110000000100001000100100110000000010010100011000100110000110000100010000011001000000000100000001000100100100001100110100000101000101000010001110001111001000101000000100100001000000001110110100010001001000100100000011011000001000000000101000010000100010000110101001010010010001000110010110000000110010000110000001000101010001001101111001000010000101100011000000110001011110000001111001000000000000011110011100000000101010000000101110001000100000000100000": TestData(n, 2) = "?"


Title: Re: Looking for old program or help recreating it
Post by: random1 on December 14, 2021, 11:42:53 pm
STxAxTIC

I added your latest code to my main program and everything seems to be working as expected.
I'm not getting quite the results I had hoped for but I have not had time to run enough test to
really tell one way or the other.   

One question I do have has to do with my process bar.  Where would be the best place to put
a counter so that it closely approximates the overall number of iterations each prediction takes?
Nothing big, just thought you might have good idea where to place it.     

R1
Title: Re: Looking for old program or help recreating it
Post by: STxAxTIC on December 15, 2021, 02:30:16 am
Hey R1,

Good question. I'll think about where precisely to inject some kind of percentage counter that gives a sense of how long an iteration takes.

So as usual, I updated the code again, and it's now a factor of about 100 times more productive than it ever was. (Almost literally 100 more answers per second compared to the old versions.) It occurred to me that its silly to do *one* test per entire string all the way at the end. So instead, we still feed it big random strings, but instead the program gives a new prediction every for every character in the string. I commented out the order 11,12,13 alphabets, so the thing is so fast now it needs a delay to watch. If i ever feel it lacks accuracy we can just bring the bigger alphabets back.

Even better too: it's been tested with real data generated by different humans and different RNGs. The results are nothing but pleasing. I'll resume this tomorrow, but I wanted you to have the latest:

Code: QB64: [Select]
  1.  
  2. Screen _NewImage(100, 30)
  3.  
  4. ' Version: 11
  5.  
  6. Type LetterBin
  7.     Signature As String
  8.     Count As Integer
  9.  
  10. Dim Shared Alphabet1(2) As LetterBin ' 0 1
  11. Dim Shared Alphabet2(4) As LetterBin ' 00 01 10 11
  12. Dim Shared Alphabet3(8) As LetterBin ' 000 001 010 011 100 101 110 111
  13. Dim Shared Alphabet4(16) As LetterBin ' etc.
  14. Dim Shared Alphabet5(32) As LetterBin
  15. Dim Shared Alphabet6(64) As LetterBin
  16. Dim Shared Alphabet7(128) As LetterBin
  17. Dim Shared Alphabet8(256) As LetterBin
  18. Dim Shared Alphabet9(512) As LetterBin
  19. Dim Shared Alphabet10(1024) As LetterBin
  20. Dim Shared Alphabet11(2048) As LetterBin
  21. Dim Shared Alphabet12(4096) As LetterBin
  22. Dim Shared Alphabet13(8192) As LetterBin
  23.  
  24. Alphabet1(1).Signature = "0"
  25. Alphabet1(2).Signature = "1"
  26. Call NewAlphabet(Alphabet1(), Alphabet2())
  27. Call NewAlphabet(Alphabet2(), Alphabet3())
  28. Call NewAlphabet(Alphabet3(), Alphabet4())
  29. Call NewAlphabet(Alphabet4(), Alphabet5())
  30. Call NewAlphabet(Alphabet5(), Alphabet6())
  31. Call NewAlphabet(Alphabet6(), Alphabet7())
  32. Call NewAlphabet(Alphabet7(), Alphabet8())
  33. Call NewAlphabet(Alphabet8(), Alphabet9())
  34. Call NewAlphabet(Alphabet9(), Alphabet10())
  35. Call NewAlphabet(Alphabet10(), Alphabet11())
  36. Call NewAlphabet(Alphabet11(), Alphabet12())
  37. Call NewAlphabet(Alphabet12(), Alphabet13())
  38.  
  39. '''
  40.  
  41. Dim TheString As String
  42. Dim predictedGuess As Integer
  43. Dim correctGuesses As Double
  44. Dim totalGuesses As Double
  45. Dim progressReport(1 To _Width) As Double
  46.  
  47. 'TheString = "110111001100010110010011101011100111010101100001100101011010101111110000111100010101110000010010110001" ' Wolfram 30
  48. 'TheString = "001100000000001111111111111110110000000010111000000000111111111011111111100000000000110000000011111111110100011111100000000110110000110100111111111001101110100000000101000001100101110011111101001111000000000000000010000111001110011111111110111110000000000000000001100110001000011001011110000000000000000000000000000000000110101111100000000000000001100000000000000001111101111000000000000010000000000000011110111111111111000000000001100111110000111101111111111111100000000111110111110001111011111111111101110000000011111111000000000000000111111111111000000111100000000000000000000111110011110001010111100000110000000000000011110111110001111011110000000000010000000111100111111111111110000000000000110000001111001111100011111111110000000000000000000111111010110011111111110000000011000110000111110001010001111101111000000000011110001110110011010000110001111110000000111000011111000001010000111001111100000000000000111110011111001000000100111110011000000111111111111111111000000001111111111111111111111111111111000011000000100001110111111111111111111110100000000000111000111101111011111111111111000000000001111100111110000000011111111110000000100000001111011110000001111111111111110011010001111111111111000011111111111111110101101111111111011111001001111111111111" ' Chia
  49. 'TheString = "101000110111011000000001110011010010101011111010100110010111010000011110101101100001010110110000011001001001010101011011111111100100010010101110100001111001100000010011110000110011100011110010000000011101001101001100111110100001001110111100001110001101011010110100011110111110010110010000010111101100110110000011101100000100111100011000000111010110010101010000101001000111000011110011000101000100100010001100101110111000001000000111001011111101000111100001101010011010011001010100001101100001010111011011110000101111111000001011111000010001100010101011011110100010111110010100111001101001001001110100111010011100110101100110110110101101011000010000010101110111100010100001110111011101111100001010001110000011001110010100010001110111000111101000100100111110000011001111011000001111100101011100000111001110110011010011001111110110001100000100001010011100100011111001011111011101011100101000111010110011111011111100010101011001100011100000100111111010001010001010010010001101101001001001111011001100011100001000001010100000000011001111010011101101010111101101010011010000001011000010111100110011100101011011011101111110011000010000000001111001000111011101010000101001010001100110001010110100000100110101110001000110110110011001001100010111110111100010000010001010101110100010000001110011010111101010101101000000110000000110100111101011100101001100001111100100101010101010101101000111100000101011101100011010110010110101011101011010111101100110101010111100000100100100001011000100001100001010100010100011101011100111000101010101001000000010001010111100111001101011111110011100001000110110001001001101000100011111100011101010010111110101100101101110000111000100001101110101111010000011001110000000100111100001011010100101010010011100011101000110000110000111001001011100010010100110001101110001110010010101010001110011001111011101011000110101000110101011100100110011001100010010011100000110100100000010000001011110000110101011001011011111100000101100100110010101010010011101100011111111010001011000011111101010011100100010011101110010" ' Cobalt 3k
  50. 'TheString = "1011001010010100100100110010101010101001010101010101011010010101001010101001010010100110101011010101010101011010101101010101010101010010110101010101100101010101010110101101011010010101010010100110101101001010110101011010010101101010110100101111010101010011011011010010110101010010110100101101010100101011010010101001010101010001011101011010010101011100111010010001101011110010011010001011100110101010010011010101001001010010000101010110001" ' loudar
  51. 'TheString = "11111011110100101011111111110100000011011110101100111100111111110111101110100111100110011111110101111111010111101111100111110111111111111011100111110111111110010000101011111001110101101010110111110" ' Spriggs 2
  52. 'TheString = "1010001101110110000000011100110100101010111110101001100101110100000111101011011000010101101100000110010010010101010110111111111001000100101011101000011110011000000100111100001100111000111100100000000111010011010011001111101000010011101111000011100011010110101101000111101111100101100100000101111011001101100000111011000001001111000110000001110101100101" ' Coalt legit
  53. 'TheString = "01001111011010000010110000100000010010010010000001110111011011110110111001100100011001010111001000100000011010000110111101110111001000000110100101110100001000000111011101101001011011000110110000100000011001000110111100100000011101110110100101110100011010000010000001110011011101000111010101100110011001100010000001101100011010010110101101100101001000000110001101101111011011100111011001100101011100100111010001101001011011100110011100100000011011100110111101110010011011010110000101101100001000000111010001100101011110000111010000100000011101000110111100100000011000100110100101101110011000010111001001111001" ' Zach binary thing
  54. 'TheString = "1000000111011011110101111000000010101111000111011001111101010001010001100100110101111000001000000111010111100101101110111011001001100101000101001100011010000010101011100100101000011010010011011100100000110000000100001011110000010011111101011111101110001011011011111100110011100101010101000000000000101001100110111111100000001101000000110010001011111010011101100101100011001101001110101101100010100001100110101010001010010101011011101001011010000110110011111001101010001111100010100111101011100110101111001100001011000000110010110010010011110111001101111111110010111010001100000011000110111101011111000000000111010011000101101010001101101000001010110010100110101101010010001101101000000000001011101011110111110101000000010101001010001111110100101101001111010111000001011110101010011100100011101000101101100101101100111010100011100100100001010100110011111010000100100101010110100110101011011100011101110111011011100011101010111010010001000001001000110011110101011001010111000011101010101011011010100100001110010001100010001111010100000000011011110100101001011111001001100011110110010100100101111101111010001111011011110101111000010101111001011101010011101001000010110110101011110110000000001010101100111101000001101011001101100110100110110000000100001001001111100111111110010111011001000000100110011010110011110100011000000011101101010111001101101110011010001010110010010100001111001011000001010001111110100011101010101110011111100010101110100001101000011010111011111010101101111110110000010010010000101001011001000001011101000111101110010001000101011001010000011101110101010110100001000111100000011100110011111111011111100111000001010010011101111001110101001111001011011101101010101001101100110010010100101100110101100011000001000100110010100101111011011100110110001010011000011001110110100110110011111110110111011100010110010110011110101111001110011011010001001111010000111001001110001110001111101101111000000101001011001101110110100100001111100010001101111011000101101001110101010101001001111111011100001101110011000100011100011111011111001010010110001010111010101100010010101101100111110000010000110110110000101001111001110111001101100010111011110110001101101000011011111001111101100011100101010100001010000101111001101010000001000010100001111110110100100101011110000100001000001100110111010001110100011111101100001111000001011010011011111110110011010011011100001010100011001110100001001101111111110000100101011111010011111010111111110101111100101001011001001101011011101001000011101100100001100010000111011000100111101010011010100010110101001111101011101010000111100100011010001011011001010010111001001010100000101001111000101001011111011101011101001010000100111110111011110010010100101111000010001101100010010111111000110000110011010011110000101011011101001100101010000001010001111000110110011000110000010001010110110001011111001100100000110100100011110001010110011110010001000000100101111000111110101100011001010000110101001001010000100000101100010001011001110100010110100101010100010110110000100101000011111010000011110101010100100110101000001001110100101000010110100011111000110011111010010010000111101110111001111110000010110101101010010101011101001010001010101111110001101001101010010001011101011100101101010110001101010101101011101100111101110101111110011101110010100110111100101011110100110111111100110101011011111000100000100100011100111011111010111100111100111110100000010001011110111011000100101111100100100101000100110000110110111101010111001011011010000111000111111111001011000101011011000001011111000100001001011001111011011011101101011111000000000100110010011111000000111000110100010110101101001010110110100001100000011110011100110000101000101101010000010011011110000011001010111001011100000101111011110110100100010011100111000001001000110110111010101001011100010111010000101010001010001000001110011100001101010011001100011101010001111011111101001001010000010000011100110110001110000000100111010011111110011100111101000000011011000101101001011001110000110010001100000111101110010010100000101110010111110111000100001110011111111001111100101010110000110101101000000100110111000000110111001011110101100111100110101011000100000110110101100001000111010111101100000000100110101101101000101010100001110110010101011110010011100001010010100011010111110001010111001111011111001000110110001001100000010001001110001011000101101010111011101101110111100100000101011110000011001001110100111111010001001010000110010001111110000000010001011111000001001101101010111110111100011011011001000101100110010010100110110011110111110110101010010011000100101110011101010100010011110011001011100010101100000101011000111001111100010101010000100100110010110011001110111100100000001010001101111010011100110010101011101001110100111110100001111000111111101000110000001010001010010010111110011011011011010101000100101010011111100011111110101010101110001011110100100110001011011100100000010111010001010111101101100100111001001110101010000111010111111110000010011100101110101110010111100101010100001110100000111110010111111001110011101110001101100000011011110000111100101111100101111101010101001110110011010111110110011100000000010101001000000011100001111000011000110101001010101100110100110111001001010101001110010111000111111111101001111001101100001000010110000000100110110010001110000110001001111000011111110111011010111101001000010001110010101110000000100011100110101110111011000101100010100000101010110100111010010000111110011111100110010110111101010011000000101001001001100111010001001101101111010101110000010000111000101011111100010010101000110001010011101001111101110010110101110101011110011001001100011001011111100011011001000010101101100010110010011010111011111111110011011010111000100011011110100100111111110010100100100100010001000001111100100010011001101000100010110111001111100001010001010110100111111101110000000010100001111101000100011101110000100111011101100100111101110011011011000100010000100001111111011010010001001101000111000000100011011111101110100001100010000111110001110100111011010001001000111000010101100001101001000101001000111100100101000011111110001011011101110010011000110111100110000110111010111111001010100001010001110010100101001001001101111001000010010000111011011010000100111111100011111110100110111001111011001111011010000010001111010100000111010010011110000010011111111001100001010100110001111010001010110101100000010001101000101001110001100111111000101111011000001111110110001011110000001011010001110010011001001011110101001111010011000110001101111101000011110111011000000011100101011101100010010001101101011100000100000000101000101011101100011011100011001101010110011111100010011001110001010010011010110011111111111001010100110100101111001010100001010001001100101110110100111101100101010100000111110000011110001011000010110101110110001001100110011111111010101100100000100110010101000001001110101101100001000100110111011101011110100100110101010000110011111000101001011110111111010100000010000111010110110010001100001011100001100001001000001001011111011111011011100100100101001101110010101000111111000000100001101101010011110111000001000010100110111100100111110101111000110111110111000010110100110000001110110010000001111011000100110101010000100010110100101110010011001110100010111011100101100111011101110000011101100111010001010010100001011101010101101000111100100100110010010110001100010100101001010100111111010001100111111111001110001011101000101011101010110010101100011111101100010000000001111000011100010010001100100100001010000000000011100000001101110101111111110001011001101000101101000101001001000110000101110100000110001010011001001010100100111001110111001101010101101111000001011000100000001101000011000001001011001110101110101010010000100011100011010010001000100001011101000100101001111100010110001110101001011000101110010011101000001001111100110001000101010011011001111101101011111011010110101101101001001100100011001010001001011101000101000101110001101101110110010110011010000100000010101110111100001100111101111111110000001010111111001110100101010010100000110001001011111110001100011110101001011110000010111110000010000101110111000011001010011100010010101011101101110111001001110110101110110111011110001100010100101101011111111010011110000011010100111111001101010000101001000111000011110011000101000100100010001100101110111000001000000111001011111101000111100001101010011010011001010100001101100001010111011011110000101111111000001011111000010001100010101011011110100010111110010100111001101001001001110100111010011100110101100110110110101101011000010000010101110111100010100001110111011101111100001010001110000011001110010100010001110111000111101000100100111110000011001111011000001111100101011100000111001110110011010011001111110110001100000100001010011100100011111001011111011101011100101000111010110011111011111100010101011001100011100000100111111010001010001010010010001101101001001001111011001100011100001000001010100000000011001111010011101101010111101101010011010000001011000010111100110011100101011011011101111110011000010000000001111001000111011101010000101001010001100110001010110100000100110101110001000110110110011001001100010111110111100010000010001010101110100010000001110011010111101010101101000000110000000110100111101011100101001100001111100100101010101010101101000111100000101011101100011010110010110101011101011010111101100110101010111100000100100100001011000100001100001010100010100011101011100111000101010101001000000010001010111100111001101011111110011100001000110110001001001101000100011111100011101010010111110101100101101110000111000100001101110101111010000011001110000000100111100001011010100101010010011100011101000110000110000111001001011100010010100110001101110001110010010101010001110011001111011101011000110101000110101011100100110011001100010010011100000110100100000010000001011110000110101011001011011111100000101100100110010101010010011101100011111111010001011000011111101010011100100010011101110010101110101111011111001010010000100110101110011000100001010110011111001011010000100011011110001000101011100001100011001111000111111010" ' Cobol
  55. TheString = "10111010101010101010101001010101010101001010101001010101010101010101010101010101010101010101010101010101001010100100100101010101010101001010100101010101010100101010100101010101010101010101001010010110010101010010101010101010101010101010100101001001001010101010101010101010101001010101001001101010010" ' Spriggs hand
  56. 'TheString = "01100101001010001100001101101111011010010101010110110101001000001111001111110101000101111011010101111101010101101010101001010101011000010101010101001011010100110100110100110011010101010101110101010111111101011010100000001101111000010111000110111001000010100001101010110100000111101011111100001011001010110010110" ' Luke 50
  57. 'TheString = "010101111010111100110000001001100100101100000101110001100101000010001001111101111111111100011110000011011110011000100011100100001101110011001001011001000011110010001000111100011100011110010110011110111010110100001000110000010000111000111011100110011010101111111100100010001111111100010100001011000011" 'Spriggs
  58. 'TheString = "10101010101011101000011101010111010101010101100111001010100111100001011011110101000001111010101101010000001111110011111110111101110111001110110010000100010101010101010100101011010110101010101010101001000000001111110000011110101010101010100010101110101010101101111111111111111111101010101010101000000" ' 63
  59. 'TheString = "11100101110011011010110100110011111011010110100100000110000100101001001010011100111101101110000001000000011011100101110000000111100100011101000000101000110100001000000001111010101011000010001110111110001001110101011000010101001111010100100000011100110110110000111010001010000011010000101111101011000" ' using RND function
  60. 'TheString = "00101010001100101010010101010100101010010100101010010101010100100000101011110101001010010101010010000011101010100101010101001010010101010101010110101001010100101010101001010100101010100101010100101010101001010010101010010101010101010100101010101010101010101001010101010100101010101001010101001101010" ' 78
  61. 'TheString = "11100101010011001001001010101001010000101001000010100010110111010101010011010100100100110101010010010110100101001001010010101010010010100101001010010100100101001001010010010110010010101010101001010101001010101010010101001001010101001010101010101010101010101010101010010101001010010100101001010101001" ' 68
  62. 'TheString = "10101011100101100101010101010101010101010101010101010101010010011010100000000011111111111001011001101010101010110010101010101010101010101010100101100101010101010110011101011110101010101010101101101010101111010101100101001011010010101010101011010101001110101010111101110011010011001101001101011000101" ' 68
  63. 'TheString = "10101101000110101000101010101010101010100101010101010100101110010101001001010100101010101001001010101001010000010010001010010010101010100110010101010101010101010110010101010010100101010010101010101001010101010101010010101010101010101010010101010101010101010101010010101001001010010100101010101010101" ' 76
  64.  
  65. For j = 1 To Len(TheString)
  66.     Cls
  67.     Locate 1, 1
  68.     Print "Analyzing:"
  69.     Print
  70.     Print Left$(TheString, j) + "["; Right$(TheString, Len(TheString) - j); "]"
  71.     Print
  72.  
  73.     ' Main prediction call:
  74.     predictedGuess = Analyze(Left$(TheString, j), 0)
  75.  
  76.     Print "Prediction: "; _Trim$(Str$(predictedGuess))
  77.     Print "Actual:     "; _Trim$(Mid$(TheString, j + 1, 1))
  78.     If (predictedGuess = Val(Mid$(TheString, j + 1, 1))) Then
  79.         correctGuesses = correctGuesses + 1
  80.     End If
  81.     totalGuesses = totalGuesses + 1
  82.     Print "I have been correct for "; _Trim$(Str$(Int(100 * correctGuesses / totalGuesses))); "% of "; _Trim$(Str$(totalGuesses)); " guesses."
  83.  
  84.     f = (_Width - 1) / Int(Len(TheString))
  85.     If (f > 1) Then f = 1 / f
  86.     progressReport(1 + Int(j * f)) = correctGuesses / totalGuesses
  87.  
  88.     For k = 1 To 1 + Int(j * (_Width - 1) / Int(Len(TheString)))
  89.         Locate 25 - Int(10 * progressReport(1 + Int(k * f))), k: Print "*"
  90.     Next
  91.  
  92.     _Delay .05
  93.     _Display
  94.  
  95.  
  96. Function Analyze (TheStringIn As String, pswitch As Integer)
  97.     Dim TheReturn As Integer
  98.     Dim As Integer n
  99.     Dim As Double r, j, k, h
  100.     Dim Fingerprint(16) As String
  101.     Dim p(2 To 10, 2) As Double ' Change the upper bound to a higer number for more accuracy.
  102.  
  103.     ' Create shifted versions of string, i.e. ABCD -> BCDA, CDAB, DABC, ABCD, BCDA, etc.
  104.     Fingerprint(1) = TheStringIn
  105.     For n = 2 To UBound(Fingerprint)
  106.         Fingerprint(n) = Right$(Fingerprint(n - 1), Len(Fingerprint(n - 1)) - 1) + Left$(Fingerprint(n - 1), 1)
  107.     Next
  108.  
  109.     ' Initialize partial results.
  110.     For n = LBound(p) To UBound(p)
  111.         p(n, 1) = -999
  112.     Next
  113.  
  114.     Call CreateHisto(Fingerprint(), Alphabet2(), 2)
  115.     Call CreateHisto(Fingerprint(), Alphabet3(), 3)
  116.     Call CreateHisto(Fingerprint(), Alphabet4(), 4)
  117.     Call CreateHisto(Fingerprint(), Alphabet5(), 5)
  118.     Call CreateHisto(Fingerprint(), Alphabet6(), 6)
  119.     Call CreateHisto(Fingerprint(), Alphabet7(), 7)
  120.     Call CreateHisto(Fingerprint(), Alphabet8(), 8)
  121.     Call CreateHisto(Fingerprint(), Alphabet9(), 9)
  122.     Call CreateHisto(Fingerprint(), Alphabet10(), 10)
  123.     'Call CreateHisto(Fingerprint(), Alphabet11(), 11)
  124.     'Call CreateHisto(Fingerprint(), Alphabet12(), 12)
  125.     'Call CreateHisto(Fingerprint(), Alphabet13(), 13)
  126.  
  127.     If (pswitch = 1) Then
  128.         For n = 1 To _Width
  129.             Print "-";
  130.         Next
  131.         Print
  132.     End If
  133.  
  134.     If (pswitch = 1) Then
  135.         If (Len(TheStringIn) >= 2) Then Call PrintHisto(Alphabet2(), 3) ' Set the last number >=1 to print stats for that histogram.
  136.         If (Len(TheStringIn) >= 3) Then Call PrintHisto(Alphabet3(), 3)
  137.         If (Len(TheStringIn) >= 4) Then Call PrintHisto(Alphabet4(), 0)
  138.         If (Len(TheStringIn) >= 5) Then Call PrintHisto(Alphabet5(), 0)
  139.         If (Len(TheStringIn) >= 6) Then Call PrintHisto(Alphabet6(), 0)
  140.         If (Len(TheStringIn) >= 7) Then Call PrintHisto(Alphabet7(), 0)
  141.         If (Len(TheStringIn) >= 8) Then Call PrintHisto(Alphabet8(), 0)
  142.         If (Len(TheStringIn) >= 9) Then Call PrintHisto(Alphabet9(), 0)
  143.         If (Len(TheStringIn) >= 10) Then Call PrintHisto(Alphabet10(), 0)
  144.         'If (Len(TheStringIn) >= 11) Then Call PrintHisto(Alphabet11(), 0)
  145.         'If (Len(TheStringIn) >= 12) Then Call PrintHisto(Alphabet12(), 0)
  146.         'If (Len(TheStringIn) >= 13) Then Call PrintHisto(Alphabet13(), 0)
  147.         Print
  148.     End If
  149.  
  150.     If (Len(TheStringIn) >= 2) Then Call MakeGuess(TheStringIn, Alphabet2(), 2, p(), pswitch) ' Set the last number =1 to print guess for that histogram.
  151.     If (Len(TheStringIn) >= 3) Then Call MakeGuess(TheStringIn, Alphabet3(), 3, p(), pswitch)
  152.     If (Len(TheStringIn) >= 4) Then Call MakeGuess(TheStringIn, Alphabet4(), 4, p(), 0)
  153.     If (Len(TheStringIn) >= 5) Then Call MakeGuess(TheStringIn, Alphabet5(), 5, p(), 0)
  154.     If (Len(TheStringIn) >= 6) Then Call MakeGuess(TheStringIn, Alphabet6(), 6, p(), 0)
  155.     If (Len(TheStringIn) >= 7) Then Call MakeGuess(TheStringIn, Alphabet7(), 7, p(), 0)
  156.     If (Len(TheStringIn) >= 8) Then Call MakeGuess(TheStringIn, Alphabet8(), 8, p(), 0)
  157.     If (Len(TheStringIn) >= 9) Then Call MakeGuess(TheStringIn, Alphabet9(), 9, p(), 0)
  158.     If (Len(TheStringIn) >= 10) Then Call MakeGuess(TheStringIn, Alphabet10(), 10, p(), 0)
  159.     'If (Len(TheStringIn) >= 11) Then Call MakeGuess(TheStringIn, Alphabet11(), 11, p(), 0)
  160.     'If (Len(TheStringIn) >= 12) Then Call MakeGuess(TheStringIn, Alphabet12(), 12, p(), 0)
  161.     'If (Len(TheStringIn) >= 13) Then Call MakeGuess(TheStringIn, Alphabet13(), 13, p(), 0)
  162.     If (pswitch = 1) Then Print
  163.  
  164.     If (pswitch = 1) Then
  165.         Print "Analyzing:"
  166.         Print TheStringIn
  167.  
  168.         Print
  169.         Print "Thinking:";
  170.         For k = LBound(p) To UBound(p)
  171.             If (p(k, 1) <> -999) Then
  172.                 Print p(k, 1);
  173.             Else
  174.                 Print "_ ";
  175.             End If
  176.         Next
  177.         Print
  178.     End If
  179.  
  180.     j = 0
  181.     r = 0
  182.  
  183.     For k = UBound(p) To LBound(p) Step -1
  184.         If (p(k, 1) <> -999) Then
  185.  
  186.             ' This is the made-up part of the model:
  187.             ' The variable r contributes to weighted average.
  188.             ' The variable j is used for normalization.
  189.             ' Scaling factor h influences weighted average calculaton.
  190.             ' The factors multiplying h are totally arbitrary. Notes:
  191.             '   setting o(h^2) means the later alphabets count for more.
  192.             '   p(k, 1) euqals the calculated guess at frequency k.
  193.             '   p(k, 2) euqals the peak count of the unscaled histogram.
  194.             '   ...while p(k, 2) is here, it does not seem to help calculations.
  195.  
  196.             h = 1 + k - LBound(p)
  197.  
  198.             h = h ^ 2
  199.  
  200.             ' Standard weighted average:
  201.             r = r + h * p(k, 1)
  202.             j = j + h
  203.  
  204.         End If
  205.     Next
  206.     If (j <> 0) Then
  207.         r = r / j
  208.     End If
  209.  
  210.     If (pswitch = 1) Then Print "Predicting:  "; _Trim$(Str$(r))
  211.  
  212.     If (r > .5) Then
  213.         r = 1
  214.     Else
  215.         r = 0
  216.     End If
  217.  
  218.     If (pswitch = 1) Then
  219.         Print "Rounding to: "; _Trim$(Str$(r))
  220.     End If
  221.  
  222.     TheReturn = r
  223.     Analyze = TheReturn
  224.  
  225. Sub MakeGuess (OrigString As String, arralpha() As LetterBin, wid As Integer, arrbeta() As Double, pswitch As Integer)
  226.     Dim TheReturn As Double
  227.     Dim As Integer j, k, n
  228.     TheReturn = 0
  229.     j = 1 '0
  230.     k = 0
  231.     For n = 1 To UBound(arralpha)
  232.         If (Left$(arralpha(n).Signature, wid - 1) = Right$(OrigString, wid - 1)) Then
  233.             If (arralpha(n).Count >= j) Then
  234.                 If (pswitch = 1) Then Print "Order-"; Right$("0" + _Trim$(Str$(wid)), 2); " guess: "; arralpha(n).Signature; " . "; _Trim$(Str$(arralpha(n).Count))
  235.                 TheReturn = TheReturn + Val(Right$(arralpha(n).Signature, 1))
  236.                 k = k + 1
  237.                 j = arralpha(n).Count
  238.             End If
  239.         End If
  240.     Next
  241.     If (k <> 0) Then
  242.         TheReturn = TheReturn / k
  243.         arrbeta(wid, 1) = TheReturn
  244.         arrbeta(wid, 2) = j
  245.     Else
  246.         TheReturn = .5
  247.         arrbeta(wid, 1) = TheReturn
  248.         arrbeta(wid, 2) = j
  249.     End If
  250.  
  251. Sub CreateHisto (arrfinger() As String, arralpha() As LetterBin, w As Integer)
  252.     Dim As Integer j, k, n
  253.     For n = 1 To UBound(arralpha)
  254.         arralpha(n).Count = 0
  255.     Next
  256.     For j = 1 To w
  257.         For k = 1 To Len(arrfinger(j)) - (Len(arrfinger(j)) Mod w) Step w '- 0 Step 1 'w 'make the 0 a -w? might not matter at all
  258.             For n = 1 To UBound(arralpha)
  259.                 If (Mid$(arrfinger(j), k, w) = arralpha(n).Signature) Then
  260.                     arralpha(n).Count = arralpha(n).Count + 1
  261.                 End If
  262.             Next
  263.         Next
  264.     Next
  265.     Call QuickSort(arralpha(), 1, UBound(arralpha))
  266.  
  267. Sub PrintHisto (arr() As LetterBin, w As Integer)
  268.     Dim As Integer j, n
  269.     If (w > 0) Then
  270.         If (w > UBound(arr)) Then
  271.             j = UBound(arr)
  272.         Else
  273.             j = w
  274.         End If
  275.         Print "Histogram: "; _Trim$(Str$(UBound(arr))); "-letter regroup, showing top "; _Trim$(Str$(w))
  276.         For n = 1 To j
  277.             Print arr(n).Signature; arr(n).Count
  278.         Next
  279.     End If
  280.  
  281. Sub NewAlphabet (arrold() As LetterBin, arrnew() As LetterBin)
  282.     Dim As Integer j, k, n
  283.     n = 0
  284.     For k = 1 To 2
  285.         For j = 1 To UBound(arrold)
  286.             n = n + 1
  287.             arrnew(n).Signature = arrold(j).Signature
  288.         Next
  289.     Next
  290.     For j = 1 To UBound(arrnew)
  291.         If (j <= UBound(arrnew) / 2) Then
  292.             arrnew(j).Signature = "0" + arrnew(j).Signature
  293.         Else
  294.             arrnew(j).Signature = "1" + arrnew(j).Signature
  295.         End If
  296.     Next
  297.  
  298. Sub QuickSort (arr() As LetterBin, LowLimit As Long, HighLimit As Long)
  299.     Dim As Long piv
  300.     If (LowLimit < HighLimit) Then
  301.         piv = Partition(arr(), LowLimit, HighLimit)
  302.         Call QuickSort(arr(), LowLimit, piv - 1)
  303.         Call QuickSort(arr(), piv + 1, HighLimit)
  304.     End If
  305.  
  306. Function Partition (arr() As LetterBin, LowLimit As Long, HighLimit As Long)
  307.     Dim As Long i, j
  308.     Dim As Double pivot, tmp
  309.     pivot = arr(HighLimit).Count
  310.     i = LowLimit - 1
  311.     For j = LowLimit To HighLimit - 1
  312.         tmp = arr(j).Count - pivot
  313.         If (tmp >= 0) Then
  314.             i = i + 1
  315.             Swap arr(i), arr(j)
  316.         End If
  317.     Next
  318.     Swap arr(i + 1), arr(HighLimit)
  319.     Partition = i + 1
  320.  
Title: Re: Looking for old program or help recreating it
Post by: STxAxTIC on December 15, 2021, 12:32:32 pm
Hey r1, know what occurs to me? The progress indictor thing is already here, the answer was on screen the whole time and I wasn't noticing.

Just to get it out of the way, updated code:

Code: QB64: [Select]
  1.  
  2. Screen _NewImage(100, 30)
  3.  
  4. ' Version: 12
  5.  
  6. Type LetterBin
  7.     Signature As String
  8.     Count As Integer
  9.  
  10. Dim Shared Alphabet1(2) As LetterBin ' 0 1
  11. Dim Shared Alphabet2(4) As LetterBin ' 00 01 10 11
  12. Dim Shared Alphabet3(8) As LetterBin ' 000 001 010 011 100 101 110 111
  13. Dim Shared Alphabet4(16) As LetterBin ' etc.
  14. Dim Shared Alphabet5(32) As LetterBin
  15. Dim Shared Alphabet6(64) As LetterBin
  16. Dim Shared Alphabet7(128) As LetterBin
  17. Dim Shared Alphabet8(256) As LetterBin
  18. Dim Shared Alphabet9(512) As LetterBin
  19. Dim Shared Alphabet10(1024) As LetterBin
  20. Dim Shared Alphabet11(2048) As LetterBin
  21. Dim Shared Alphabet12(4096) As LetterBin
  22. Dim Shared Alphabet13(8192) As LetterBin
  23.  
  24. Alphabet1(1).Signature = "0"
  25. Alphabet1(2).Signature = "1"
  26. Call NewAlphabet(Alphabet1(), Alphabet2())
  27. Call NewAlphabet(Alphabet2(), Alphabet3())
  28. Call NewAlphabet(Alphabet3(), Alphabet4())
  29. Call NewAlphabet(Alphabet4(), Alphabet5())
  30. Call NewAlphabet(Alphabet5(), Alphabet6())
  31. Call NewAlphabet(Alphabet6(), Alphabet7())
  32. Call NewAlphabet(Alphabet7(), Alphabet8())
  33. Call NewAlphabet(Alphabet8(), Alphabet9())
  34. Call NewAlphabet(Alphabet9(), Alphabet10())
  35. Call NewAlphabet(Alphabet10(), Alphabet11())
  36. Call NewAlphabet(Alphabet11(), Alphabet12())
  37. Call NewAlphabet(Alphabet12(), Alphabet13())
  38.  
  39. '''
  40. Dim TheString As String
  41.  
  42. Dim predictedGuess As Integer
  43. Dim correctGuesses As Double
  44. Dim totalGuesses As Double
  45. Dim streakGuess As Integer
  46.  
  47. Dim ProgressGraph(1 To _Width) As Double
  48.  
  49. 'TheString = "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
  50. 'TheString = "11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111"
  51. 'TheString = "01010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101"
  52. 'TheString = "00000010000001000000100000010000001000000100000010000001000000100000010000001000000100000010000001000000100000010000001000000100"
  53. TheString = "01010111000101101010101011010101011100010110101010101101010101110001011010101010110101010111000101101010101011010101011100010110101010101101"
  54. 'TheString = "00110000110001110001110010110011110101111000110001110011110010110001110011110100110101110101111000111001110001110100110100110010110011110011110011110111110111110110110001110000111001111000110111110001110101111001110111110010110101111000110100110100110001111000110001110110110111110110110101110001110000111001110100110110110001110111110111110001110001110010111000110110110101110111110100110110110011110110111000110111110101110000110010110101110001110010110001110011111001110011110001111001110110110100110001111000110011110001110111111000110001110001" ' Fibonacci
  55. 'TheString = "11010000100101101011010111010110101110101000001101001011100000111001010001100000101100110000010111000100100101110100001101111001011011001100110101111100010010111100010010111111010001111110010011110000110011110011010011010101100001101010011110101001110001100011001110111110011111111101100001100000011000000101101100111100011010001011010101001010000101010011000010011011010110110111011110000001110010100010000000101111101011101111000101010001011111100100101000011001011001101111101100010111010100111001"
  56. 'TheString = "110111001100010110010011101011100111010101100001100101011010101111110000111100010101110000010010110001" ' Wolfram 30
  57. 'TheString = "001100000000001111111111111110110000000010111000000000111111111011111111100000000000110000000011111111110100011111100000000110110000110100111111111001101110100000000101000001100101110011111101001111000000000000000010000111001110011111111110111110000000000000000001100110001000011001011110000000000000000000000000000000000110101111100000000000000001100000000000000001111101111000000000000010000000000000011110111111111111000000000001100111110000111101111111111111100000000111110111110001111011111111111101110000000011111111000000000000000111111111111000000111100000000000000000000111110011110001010111100000110000000000000011110111110001111011110000000000010000000111100111111111111110000000000000110000001111001111100011111111110000000000000000000111111010110011111111110000000011000110000111110001010001111101111000000000011110001110110011010000110001111110000000111000011111000001010000111001111100000000000000111110011111001000000100111110011000000111111111111111111000000001111111111111111111111111111111000011000000100001110111111111111111111110100000000000111000111101111011111111111111000000000001111100111110000000011111111110000000100000001111011110000001111111111111110011010001111111111111000011111111111111110101101111111111011111001001111111111111" ' Chia
  58. 'TheString = "1011001010010100100100110010101010101001010101010101011010010101001010101001010010100110101011010101010101011010101101010101010101010010110101010101100101010101010110101101011010010101010010100110101101001010110101011010010101101010110100101111010101010011011011010010110101010010110100101101010100101011010010101001010101010001011101011010010101011100111010010001101011110010011010001011100110101010010011010101001001010010000101010110001" ' loudar
  59. 'TheString = "11111011110100101011111111110100000011011110101100111100111111110111101110100111100110011111110101111111010111101111100111110111111111111011100111110111111110010000101011111001110101101010110111110" ' Spriggs 2
  60. 'TheString = "1010001101110110000000011100110100101010111110101001100101110100000111101011011000010101101100000110010010010101010110111111111001000100101011101000011110011000000100111100001100111000111100100000000111010011010011001111101000010011101111000011100011010110101101000111101111100101100100000101111011001101100000111011000001001111000110000001110101100101" ' Coalt legit
  61. 'TheString = "01001111011010000010110000100000010010010010000001110111011011110110111001100100011001010111001000100000011010000110111101110111001000000110100101110100001000000111011101101001011011000110110000100000011001000110111100100000011101110110100101110100011010000010000001110011011101000111010101100110011001100010000001101100011010010110101101100101001000000110001101101111011011100111011001100101011100100111010001101001011011100110011100100000011011100110111101110010011011010110000101101100001000000111010001100101011110000111010000100000011101000110111100100000011000100110100101101110011000010111001001111001" ' Zach binary thing
  62. 'TheString = "10111010101010101010101001010101010101001010101001010101010101010101010101010101010101010101010101010101001010100100100101010101010101001010100101010101010100101010100101010101010101010101001010010110010101010010101010101010101010101010100101001001001010101010101010101010101001010101001001101010010" ' Spriggs hand
  63. 'TheString = "01100101001010001100001101101111011010010101010110110101001000001111001111110101000101111011010101111101010101101010101001010101011000010101010101001011010100110100110100110011010101010101110101010111111101011010100000001101111000010111000110111001000010100001101010110100000111101011111100001011001010110010110" ' Luke 50
  64. 'TheString = "010101111010111100110000001001100100101100000101110001100101000010001001111101111111111100011110000011011110011000100011100100001101110011001001011001000011110010001000111100011100011110010110011110111010110100001000110000010000111000111011100110011010101111111100100010001111111100010100001011000011" 'Spriggs
  65. 'TheString = "10101010101011101000011101010111010101010101100111001010100111100001011011110101000001111010101101010000001111110011111110111101110111001110110010000100010101010101010100101011010110101010101010101001000000001111110000011110101010101010100010101110101010101101111111111111111111101010101010101000000" ' 63
  66. 'TheString = "11100101110011011010110100110011111011010110100100000110000100101001001010011100111101101110000001000000011011100101110000000111100100011101000000101000110100001000000001111010101011000010001110111110001001110101011000010101001111010100100000011100110110110000111010001010000011010000101111101011000" ' using RND function
  67. 'TheString = "00101010001100101010010101010100101010010100101010010101010100100000101011110101001010010101010010000011101010100101010101001010010101010101010110101001010100101010101001010100101010100101010100101010101001010010101010010101010101010100101010101010101010101001010101010100101010101001010101001101010" ' 78
  68. 'TheString = "11100101010011001001001010101001010000101001000010100010110111010101010011010100100100110101010010010110100101001001010010101010010010100101001010010100100101001001010010010110010010101010101001010101001010101010010101001001010101001010101010101010101010101010101010010101001010010100101001010101001" ' 68
  69. 'TheString = "10101011100101100101010101010101010101010101010101010101010010011010100000000011111111111001011001101010101010110010101010101010101010101010100101100101010101010110011101011110101010101010101101101010101111010101100101001011010010101010101011010101001110101010111101110011010011001101001101011000101" ' 68
  70. 'TheString = "10101101000110101000101010101010101010100101010101010100101110010101001001010100101010101001001010101001010000010010001010010010101010100110010101010101010101010110010101010010100101010010101010101001010101010101010010101010101010101010010101010101010101010101010010101001001010010100101010101010101" ' 76
  71.  
  72. For j = 1 To Len(TheString)
  73.  
  74.     Cls
  75.     Locate 1, 1
  76.     Print "Analyzing:"
  77.     Print
  78.     Print Left$(TheString, j) + "["; Right$(TheString, Len(TheString) - j); "]"
  79.     Print
  80.  
  81.     ' Main prediction call
  82.     predictedGuess = Analyze(Left$(TheString, j), 0)
  83.  
  84.     ' Reconciliation
  85.     Print "Prediction: "; _Trim$(Str$(predictedGuess))
  86.     Print "Actual:     "; _Trim$(Mid$(TheString, j + 1, 1))
  87.     Print
  88.     If (predictedGuess = Val(Mid$(TheString, j + 1, 1))) Then
  89.         correctGuesses = correctGuesses + 1
  90.         streakGuess = streakGuess + 1
  91.         Print "I was right."
  92.     Else
  93.         streakGuess = 0
  94.         Print "I was wrong."
  95.     End If
  96.     totalGuesses = totalGuesses + 1
  97.     Print "I'm on a "; _Trim$(Str$(streakGuess)); "-game winning streak."
  98.     Print "I have been correct on "; _Trim$(Str$(Int(100 * correctGuesses / totalGuesses))); "% of "; _Trim$(Str$(totalGuesses)); " guesses."
  99.  
  100.     ' Draw bottom graph
  101.     f = (_Width - 1) / Int(Len(TheString))
  102.     If (f > 1) Then f = 1 / f
  103.     ProgressGraph(1 + Int(j * f)) = correctGuesses / totalGuesses
  104.     For k = 1 To 1 + Int(j * (_Width - 1) / Int(Len(TheString)))
  105.         Locate 25 - Int(10 * ProgressGraph(1 + Int(k * f))), k: Print "*"
  106.     Next
  107.  
  108.     _Delay .015
  109.     _Display
  110.  
  111.  
  112. Function Analyze (TheStringIn As String, pswitch As Integer)
  113.     Dim TheReturn As Integer
  114.     Dim As Integer n
  115.     Dim As Double r, j, k, h
  116.     Dim Fingerprint(16) As String
  117.     Dim Partialguess(2 To 10, 2) As Double ' Change the upper bound to a higer number for more accuracy.
  118.  
  119.     ' Create shifted versions of string, i.e. ABCD -> BCDA, CDAB, DABC, ABCD, BCDA, etc.
  120.     Fingerprint(1) = TheStringIn
  121.     For n = 2 To UBound(Fingerprint)
  122.         Fingerprint(n) = Right$(Fingerprint(n - 1), Len(Fingerprint(n - 1)) - 1) + Left$(Fingerprint(n - 1), 1)
  123.     Next
  124.  
  125.     ' Initialize partial results.
  126.     For n = LBound(Partialguess) To UBound(Partialguess)
  127.         Partialguess(n, 1) = -999
  128.     Next
  129.  
  130.     Call CreateHisto(Fingerprint(), Alphabet2(), 2)
  131.     Call CreateHisto(Fingerprint(), Alphabet3(), 3)
  132.     Call CreateHisto(Fingerprint(), Alphabet4(), 4)
  133.     Call CreateHisto(Fingerprint(), Alphabet5(), 5)
  134.     Call CreateHisto(Fingerprint(), Alphabet6(), 6)
  135.     Call CreateHisto(Fingerprint(), Alphabet7(), 7)
  136.     Call CreateHisto(Fingerprint(), Alphabet8(), 8)
  137.     Call CreateHisto(Fingerprint(), Alphabet9(), 9)
  138.     Call CreateHisto(Fingerprint(), Alphabet10(), 10)
  139.     'Call CreateHisto(Fingerprint(), Alphabet11(), 11)
  140.     'Call CreateHisto(Fingerprint(), Alphabet12(), 12)
  141.     'Call CreateHisto(Fingerprint(), Alphabet13(), 13)
  142.  
  143.     If (pswitch = 1) Then
  144.         For n = 1 To _Width
  145.             Print "-";
  146.         Next
  147.         Print
  148.     End If
  149.  
  150.     If (pswitch = 1) Then
  151.         If (Len(TheStringIn) >= 2) Then Call PrintHisto(Alphabet2(), 3) ' Set the last number >=1 to print stats for that histogram.
  152.         If (Len(TheStringIn) >= 3) Then Call PrintHisto(Alphabet3(), 3)
  153.         If (Len(TheStringIn) >= 4) Then Call PrintHisto(Alphabet4(), 0)
  154.         If (Len(TheStringIn) >= 5) Then Call PrintHisto(Alphabet5(), 0)
  155.         If (Len(TheStringIn) >= 6) Then Call PrintHisto(Alphabet6(), 0)
  156.         If (Len(TheStringIn) >= 7) Then Call PrintHisto(Alphabet7(), 0)
  157.         If (Len(TheStringIn) >= 8) Then Call PrintHisto(Alphabet8(), 0)
  158.         If (Len(TheStringIn) >= 9) Then Call PrintHisto(Alphabet9(), 0)
  159.         If (Len(TheStringIn) >= 10) Then Call PrintHisto(Alphabet10(), 0)
  160.         'If (Len(TheStringIn) >= 11) Then Call PrintHisto(Alphabet11(), 0)
  161.         'If (Len(TheStringIn) >= 12) Then Call PrintHisto(Alphabet12(), 0)
  162.         'If (Len(TheStringIn) >= 13) Then Call PrintHisto(Alphabet13(), 0)
  163.         Print
  164.     End If
  165.  
  166.     If (Len(TheStringIn) >= 2) Then Call MakeGuess(TheStringIn, Alphabet2(), 2, Partialguess(), pswitch) ' Set the last number =1 to print guess for that histogram.
  167.     If (Len(TheStringIn) >= 3) Then Call MakeGuess(TheStringIn, Alphabet3(), 3, Partialguess(), pswitch)
  168.     If (Len(TheStringIn) >= 4) Then Call MakeGuess(TheStringIn, Alphabet4(), 4, Partialguess(), 0)
  169.     If (Len(TheStringIn) >= 5) Then Call MakeGuess(TheStringIn, Alphabet5(), 5, Partialguess(), 0)
  170.     If (Len(TheStringIn) >= 6) Then Call MakeGuess(TheStringIn, Alphabet6(), 6, Partialguess(), 0)
  171.     If (Len(TheStringIn) >= 7) Then Call MakeGuess(TheStringIn, Alphabet7(), 7, Partialguess(), 0)
  172.     If (Len(TheStringIn) >= 8) Then Call MakeGuess(TheStringIn, Alphabet8(), 8, Partialguess(), 0)
  173.     If (Len(TheStringIn) >= 9) Then Call MakeGuess(TheStringIn, Alphabet9(), 9, Partialguess(), 0)
  174.     If (Len(TheStringIn) >= 10) Then Call MakeGuess(TheStringIn, Alphabet10(), 10, Partialguess(), 0)
  175.     'If (Len(TheStringIn) >= 11) Then Call MakeGuess(TheStringIn, Alphabet11(), 11, Partialguess(), 0)
  176.     'If (Len(TheStringIn) >= 12) Then Call MakeGuess(TheStringIn, Alphabet12(), 12, Partialguess(), 0)
  177.     'If (Len(TheStringIn) >= 13) Then Call MakeGuess(TheStringIn, Alphabet13(), 13, Partialguess(), 0)
  178.     If (pswitch = 1) Then Print
  179.  
  180.     If (pswitch = 1) Then
  181.         Print "Analyzing:"
  182.         Print TheStringIn
  183.  
  184.         Print
  185.         Print "Thinking:";
  186.         For k = LBound(Partialguess) To UBound(Partialguess)
  187.             If (Partialguess(k, 1) <> -999) Then
  188.                 Print Partialguess(k, 1);
  189.             Else
  190.                 Print "_ ";
  191.             End If
  192.         Next
  193.         Print
  194.     End If
  195.  
  196.     j = 0
  197.     r = 0
  198.  
  199.     For k = UBound(Partialguess) To LBound(Partialguess) Step -1
  200.         If (Partialguess(k, 1) <> -999) Then
  201.  
  202.             ' This is the made-up part of the model:
  203.             ' The variable r contributes to weighted average.
  204.             ' The variable j is used for normalization.
  205.             ' Scaling factor h influences weighted average calculaton.
  206.             ' The factors multiplying h are totally arbitrary. Notes:
  207.             '   setting o(h^2) means the later alphabets count for more.
  208.             '   Partialguess(k, 1) euqals the calculated guess at frequency k.
  209.             '   Partialguess(k, 2) euqals the peak count of the unscaled histogram.
  210.             '   ...while Partialguess(k, 2) is here, it does not seem to help calculations.
  211.  
  212.             h = 1 + k - LBound(Partialguess)
  213.  
  214.             h = h ^ 2
  215.  
  216.             ' Standard weighted average:
  217.             r = r + h * Partialguess(k, 1)
  218.             j = j + h
  219.  
  220.         End If
  221.     Next
  222.     If (j <> 0) Then
  223.         r = r / j
  224.     End If
  225.  
  226.     If (pswitch = 1) Then Print "Predicting:  "; _Trim$(Str$(r))
  227.  
  228.     If (r > .5) Then
  229.         r = 1
  230.     Else
  231.         r = 0
  232.     End If
  233.  
  234.     If (pswitch = 1) Then
  235.         Print "Rounding to: "; _Trim$(Str$(r))
  236.     End If
  237.  
  238.     TheReturn = r
  239.     Analyze = TheReturn
  240.  
  241. Sub MakeGuess (TheStringIn As String, arralpha() As LetterBin, wid As Integer, arrbeta() As Double, pswitch As Integer)
  242.     Dim TheReturn As Double
  243.     Dim As Integer j, k, n
  244.     TheReturn = 0
  245.     j = 1 '0
  246.     k = 0
  247.     For n = 1 To UBound(arralpha)
  248.         If (Left$(arralpha(n).Signature, wid - 1) = Right$(TheStringIn, wid - 1)) Then
  249.             If (arralpha(n).Count >= j) Then
  250.                 If (pswitch = 1) Then Print "Order-"; Right$("0" + _Trim$(Str$(wid)), 2); " guess: "; arralpha(n).Signature; " . "; _Trim$(Str$(arralpha(n).Count))
  251.                 TheReturn = TheReturn + Val(Right$(arralpha(n).Signature, 1))
  252.                 k = k + 1
  253.                 j = arralpha(n).Count
  254.             End If
  255.         End If
  256.     Next
  257.     If (k <> 0) Then
  258.         TheReturn = TheReturn / k
  259.         arrbeta(wid, 1) = TheReturn
  260.         arrbeta(wid, 2) = j
  261.     Else
  262.         TheReturn = .5
  263.         arrbeta(wid, 1) = TheReturn
  264.         arrbeta(wid, 2) = j
  265.     End If
  266.  
  267. Sub CreateHisto (arrfinger() As String, arralpha() As LetterBin, w As Integer)
  268.     Dim As Integer j, k, n
  269.     For n = 1 To UBound(arralpha)
  270.         arralpha(n).Count = 0
  271.     Next
  272.     For j = 1 To w
  273.         For k = 1 To Len(arrfinger(j)) - (Len(arrfinger(j)) Mod w) Step w '- 0 Step 1 'w 'make the 0 a -w? might not matter at all
  274.             For n = 1 To UBound(arralpha)
  275.                 If (Mid$(arrfinger(j), k, w) = arralpha(n).Signature) Then
  276.                     arralpha(n).Count = arralpha(n).Count + 1
  277.                 End If
  278.             Next
  279.         Next
  280.     Next
  281.     Call QuickSort(arralpha(), 1, UBound(arralpha))
  282.  
  283. Sub PrintHisto (arr() As LetterBin, w As Integer)
  284.     Dim As Integer j, n
  285.     If (w > 0) Then
  286.         If (w > UBound(arr)) Then
  287.             j = UBound(arr)
  288.         Else
  289.             j = w
  290.         End If
  291.         Print "Histogram: "; _Trim$(Str$(UBound(arr))); "-letter regroup, showing top "; _Trim$(Str$(w))
  292.         For n = 1 To j
  293.             Print arr(n).Signature; arr(n).Count
  294.         Next
  295.     End If
  296.  
  297. Sub NewAlphabet (arrold() As LetterBin, arrnew() As LetterBin)
  298.     Dim As Integer j, k, n
  299.     n = 0
  300.     For k = 1 To 2
  301.         For j = 1 To UBound(arrold)
  302.             n = n + 1
  303.             arrnew(n).Signature = arrold(j).Signature
  304.         Next
  305.     Next
  306.     For j = 1 To UBound(arrnew)
  307.         If (j <= UBound(arrnew) / 2) Then
  308.             arrnew(j).Signature = "0" + arrnew(j).Signature
  309.         Else
  310.             arrnew(j).Signature = "1" + arrnew(j).Signature
  311.         End If
  312.     Next
  313.  
  314. Sub QuickSort (arr() As LetterBin, LowLimit As Long, HighLimit As Long)
  315.     Dim As Long piv
  316.     If (LowLimit < HighLimit) Then
  317.         piv = Partition(arr(), LowLimit, HighLimit)
  318.         Call QuickSort(arr(), LowLimit, piv - 1)
  319.         Call QuickSort(arr(), piv + 1, HighLimit)
  320.     End If
  321.  
  322. Function Partition (arr() As LetterBin, LowLimit As Long, HighLimit As Long)
  323.     Dim As Long i, j
  324.     Dim As Double pivot, tmp
  325.     pivot = arr(HighLimit).Count
  326.     i = LowLimit - 1
  327.     For j = LowLimit To HighLimit - 1
  328.         tmp = arr(j).Count - pivot
  329.         If (tmp >= 0) Then
  330.             i = i + 1
  331.             Swap arr(i), arr(j)
  332.         End If
  333.     Next
  334.     Swap arr(i + 1), arr(HighLimit)
  335.     Partition = i + 1
  336.  

Alright, so the rest can be explained in the screenshot.

  [ This attachment cannot be displayed inline in 'Print Page' view ]  

The fake little "graph" made of asterisks is designed to trace across the screen exactly like a progress indicator. It moves along linearly, doesn't jump around, and has only one speed. (It won't do that microsoft thing where 99% takes a month to complete.) The lines of code that are responsible for this graph are highlighted, and you can basically ignore the y-value in it. Hope that helps!
Title: Re: Looking for old program or help recreating it
Post by: random1 on December 15, 2021, 04:24:15 pm
Wow, 100 times more productive.  I should have some time tomorrow to update my end.

Many thanks for everything.

R1   


Title: Re: Looking for old program or help recreating it
Post by: random1 on December 15, 2021, 04:36:03 pm
Ran a quick test using real data, amazing!!!
R1.
Title: Re: Looking for old program or help recreating it
Post by: STxAxTIC on December 15, 2021, 04:41:22 pm
Glad it's looking better and better r1!

It's still evolving little by little: today I re-included the order-1 alphabets (so literally just 0 and 1) and this thing's putting game improved yet again. I also improved a few things about how it looks, and it also reports on its best streak now too, cause why not? Anyway, here's the latest and greatest:

Code: QB64: [Select]
  1.  
  2. Screen _NewImage(120, 40)
  3.  
  4. ' Version: 13
  5.  
  6. Type LetterBin
  7.     Signature As String
  8.     Count As Integer
  9.  
  10. Dim Shared Alphabet1(2) As LetterBin ' 0 1
  11. Dim Shared Alphabet2(4) As LetterBin ' 00 01 10 11
  12. Dim Shared Alphabet3(8) As LetterBin ' 000 001 010 011 100 101 110 111
  13. Dim Shared Alphabet4(16) As LetterBin ' etc.
  14. Dim Shared Alphabet5(32) As LetterBin
  15. Dim Shared Alphabet6(64) As LetterBin
  16. Dim Shared Alphabet7(128) As LetterBin
  17. Dim Shared Alphabet8(256) As LetterBin
  18. Dim Shared Alphabet9(512) As LetterBin
  19. Dim Shared Alphabet10(1024) As LetterBin
  20. Dim Shared Alphabet11(2048) As LetterBin
  21. Dim Shared Alphabet12(4096) As LetterBin
  22. Dim Shared Alphabet13(8192) As LetterBin
  23.  
  24. Alphabet1(1).Signature = "0"
  25. Alphabet1(2).Signature = "1"
  26. Call NewAlphabet(Alphabet1(), Alphabet2())
  27. Call NewAlphabet(Alphabet2(), Alphabet3())
  28. Call NewAlphabet(Alphabet3(), Alphabet4())
  29. Call NewAlphabet(Alphabet4(), Alphabet5())
  30. Call NewAlphabet(Alphabet5(), Alphabet6())
  31. Call NewAlphabet(Alphabet6(), Alphabet7())
  32. Call NewAlphabet(Alphabet7(), Alphabet8())
  33. Call NewAlphabet(Alphabet8(), Alphabet9())
  34. Call NewAlphabet(Alphabet9(), Alphabet10())
  35. Call NewAlphabet(Alphabet10(), Alphabet11())
  36. Call NewAlphabet(Alphabet11(), Alphabet12())
  37. Call NewAlphabet(Alphabet12(), Alphabet13())
  38.  
  39. '''
  40. Dim TheString As String
  41.  
  42. Dim predictedGuess As Integer
  43. Dim correctGuesses As Double
  44. Dim totalGuesses As Double
  45. Dim streakGuess As Integer
  46. Dim streakBest As Integer
  47.  
  48. Dim ProgressGraph(1 To _Width) As Double
  49.  
  50. '''
  51. ' Systematic cases:
  52. '''
  53. '                                                                                                                                         Score / Ending
  54. '                                                                                                                                                 Streak:
  55. '                                                                                                                                         ---------------
  56. 'TheString = "111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111" ' (100% / 119)
  57. 'TheString = "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" ' (100% / 119)
  58. 'TheString = "010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101" ' (96%  / 112)
  59. 'TheString = "101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010" ' (96%  / 112)
  60. 'TheString = "001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001" ' (96%  / 108)
  61. 'TheString = "010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010" ' (96%  / 109)
  62. 'TheString = "100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100" ' (93%  / 108)
  63. 'TheString = "110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110" ' (96%  / 108)
  64. 'TheString = "101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101" ' (96%  / 109)
  65. 'TheString = "011011011011011011011011011011011011011011011011011011011011011011011011011011011011011011011011011011011011011011011011" ' (93%  / 108)
  66. '
  67. '''
  68. ' Community hand-typed cases:
  69. '''
  70. '            (from Cobalt) (Results in: 48%  -  Claims he made this data hand but behavior in Discord raises doubt.)
  71. 'TheString = "1010001101110110000000011100110100101010111110101001100101110100000111101011011000010101101100000110010010010101010110111111111001000100101011101000011110011000000100111100001100111000111100100000000111010011010011001111101000010011101111000011100011010110101101000111101111100101100100000101111011001101100000111011000001001111000110000001110101100101"
  72. '            (from Loudar) (Results in: 71%)
  73. 'TheString = "1011001010010100100100110010101010101001010101010101011010010101001010101001010010100110101011010101010101011010101101010101010101010010110101010101100101010101010110101101011010010101010010100110101101001010110101011010010101101010110100101111010101010011011011010010110101010010110100101101010100101011010010101001010101010001011101011010010101011100111010010001101011110010011010001011100110101010010011010101001001010010000101010110001"
  74. '            (from Luke) (Results in: 51%  -  I have long suspected Luke to be a computer. The numbers are now in.)
  75. 'TheString = "01100101001010001100001101101111011010010101010110110101001000001111001111110101000101111011010101111101010101101010101001010101011000010101010101001011010100110100110100110011010101010101110101010111111101011010100000001101111000010111000110111001000010100001101010110100000111101011111100001011001010110010110" ' Luke 50
  76. '            (from Sarafromct) (Results in: 64%)
  77. 'TheString = "10101010101011101000011101010111010101010101100111001010100111100001011011110101000001111010101101010000001111110011111110111101110111001110110010000100010101010101010100101011010110101010101010101001000000001111110000011110101010101010100010101110101010101101111111111111111111101010101010101000000" ' 63
  78. '            (from Spriggs) (Results in: 85%)
  79. TheString = "10111010101010101010101001010101010101001010101001010101010101010101010101010101010101010101010101010101001010100100100101010101010101001010100101010101010100101010100101010101010101010101001010010110010101010010101010101010101010101010100101001001001010101010101010101010101001010101001001101010010"
  80. '            (from Spriggs) (Results in: 67%)
  81. 'TheString = "11111011110100101011111111110100000011011110101100111100111111110111101110100111100110011111110101111111010111101111100111110111111111111011100111110111111110010000101011111001110101101010110111110"
  82. '            (from Hotpants) (Results in: 62%)
  83. 'TheString = "01010100011001010010101010101010101000110101010111101010100100011010101010100100101110010010010100001010101001010101010110010001001011000100100110101001001001010000000001010101101111101001010100010101001001010101000100101001100100010011010101010101010111010010101011101011011010110100100010010100100100010010001001" ' Tom
  84. '
  85. '''
  86. ' Known-Random cases:
  87. '''
  88. '            (using RND) (Results in: 45%)
  89. 'TheString = "11100101110011011010110100110011111011010110100100000110000100101001001010011100111101101110000001000000011011100101110000000111100100011101000000101000110100001000000001111010101011000010001110111110001001110101011000010101001111010100100000011100110110110000111010001010000011010000101111101011000"
  90. '            (from Spriggs) (Results in: 52%)
  91. 'TheString = "010101111010111100110000001001100100101100000101110001100101000010001001111101111111111100011110000011011110011000100011100100001101110011001001011001000011110010001000111100011100011110010110011110111010110100001000110000010000111000111011100110011010101111111100100010001111111100010100001011000011"
  92. '            (Wolfrm rule 30, central column) (Results in: 47%)
  93. 'TheString = "110111001100010110010011101011100111010101100001100101011010101111110000111100010101110000010010110001"
  94. '            (using RND) (Results in: 46%)
  95. 'TheString = "111001011100110110101101001100111110110101101001000001100001001010010010100111001111011011100000010000000110111001011100000001111001000111010000001010001101000010000000011110101010110000100011101111100010011101010110000101010011110101001000000111001101101100001110100010100000110100001011111010110000"
  96. '            (using RND) (Results in: 46%)
  97. 'TheString = "111001011100110110101101001100111110110101101001000001100001001010010010100111001111011011100000010000000110111001011100000001111001000111010000001010001101000010000000011110101010110000100011101111100010011101010110000101010011110101001000000111001101101100001110100010100000110100001011111010110000101110111110011100001000110010010001100111101000001101011000010101101011111010010001010010110110011000001001101000011100000011110001110011100010101010111101100100100001001000101101110110101100001111011101000100111110000001110000111011101000110110100111101101001100100110000111110111101001100010011110"
  98. '            (using RND) (Results in: 45%)
  99. 'TheString = "111001011100110110101101001100111110110101101001000001100001001010010010100111001111011011100000010000000110111001011100000001111001000111010000001010001101000010000000011110101010110000100011101111100010011101010110000101010011110101001000000111001101101100001110100010100000110100001011111010110000101110111110011100001000110010010001100111101000001101011000010101101011111010010001010010110110011000001001101000011100000011110001110011100010101010111101100100100001001000101101110110101100001111011101000100111110000001110000111011101000110110100111101101001100100110000111110111101001100010011110111001001100111000110011011000100101100010101010000010000111111010111111011100011100001000011000100100111001100001111010001010000001011100000101110000110010111110010101010110111110011100100001011101010000011011110110100010110111000100000110000001001010001011010000010001111110100100010011100011001000"
  100. '            (using RND) (Results in: 48%)
  101. 'TheString = "111001011100110110101101001100111110110101101001000001100001001010010010100111001111011011100000010000000110111001011100000001111001000111010000001010001101000010000000011110101010110000100011101111100010011101010110000101010011110101001000000111001101101100001110100010100000110100001011111010110000101110111110011100001000110010010001100111101000001101011000010101101011111010010001010010110110011000001001101000011100000011110001110011100010101010111101100100100001001000101101110110101100001111011101000100111110000001110000111011101000110110100111101101001100100110000111110111101001100010011110111001001100111000110011011000100101100010101010000010000111111010111111011100011100001000011000100100111001100001111010001010000001011100000101110000110010111110010101010110111110011100100001011101010000011011110110100010110111000100000110000001001010001011010000010001111110100100010011100011001000011101011010100110110000110010010011110111001001011111011000000100010011011100111110111011111101100011011101001111110100011010000111001001010111011101000001010010010100111010001001010101001000010011100111010101000110010110101111001110000010110110010101001000011000101000001100110100111101000110111101101010011011000101100101001010001100110101000101110000101100110010011010001010101010101101110101110110101100101001111100110110101011001000001100101001011000101100001001000001010111010100010100101011001111001011011100011001110010111011110010111101011101000100100010111010000001010011101010001110110110101011000101010100000001110110101011110101111100100101101000001011000101001110010010010000111001101010100101111101001110010001011000001001000111010001000011000111000000111001110111110011110110101100111011001100101101010101100010100100001010010110010000001100110010010100110011110110000001001000111001001010010000011111110011110010001100011100011010000111100111111010010001010011100100111100111101111110101000010011100011111100010000011111101101010010100000011011001110001100001011111100111000001110111011001111110011011100111000110110110011110000111000010011011000011001111111110010100000111110011111100100001100000000110001111101101011100011111011110001100100001100011100011111000000110011011100110101101001001111101101000000110101101001100011100011001110001000000111111100110101001110100010010010100000010100001010001011011001101010011111001101110110010101000111101100111000011000111001100011011011010100111111001100000100100110000100101001111111100110010111100000111101101001111001010011010011011100101001001001110101110001101010001111010101100101010111000111000011000001010010010101010100001110010001001001110110011100110011111001100111010011110100100110010000100011010001110000000100001100000010000111000111111000111100010001101011000101000010100011100011111000100010101000001001011001000101101111110111110110001101001001011100011110001101100010100101101011001001100111000000111111110110100010111111101000000001111000100001111111011000101001111110010000110101100010000011100110111101011011100110"
  102.  
  103.  
  104.  
  105.  
  106. 'Cls
  107. 'Locate 1, 1
  108. 'Print " Press 0 or 1 as randomly as you can. The longer the string, the better."
  109. 'Input "", TheString
  110.  
  111.  
  112.  
  113.  
  114.  
  115. For j = 1 To Len(TheString)
  116.  
  117.     Cls
  118.     Locate 1, 1
  119.     For k = 1 To _Width
  120.         Print "_";
  121.     Next
  122.     Print
  123.     Print "Analyzing: (string length "; _Trim$(Str$(Len(TheString))); ")"
  124.     Print
  125.     Color 7
  126.     Print Left$(TheString, j);
  127.     Color 8
  128.     Print "["; Right$(TheString, Len(TheString) - j); "]"
  129.     Color 7
  130.     Print
  131.  
  132.     ' Main prediction call
  133.     predictedGuess = Analyze(Left$(TheString, j), 0)
  134.  
  135.     ' Reconciliation
  136.     Print "Prediction: "; _Trim$(Str$(predictedGuess))
  137.     If (j < Len(TheString)) Then
  138.         Print "Actual:     "; _Trim$(Mid$(TheString, j + 1, 1))
  139.         If (predictedGuess = Val(Mid$(TheString, j + 1, 1))) Then
  140.             correctGuesses = correctGuesses + 1
  141.             streakGuess = streakGuess + 1
  142.             If (streakGuess > streakBest) Then streakBest = streakGuess
  143.             Print "I am RIGHT this round."
  144.         Else
  145.             streakGuess = 0
  146.             Print "I am WRONG this round."
  147.         End If
  148.         totalGuesses = totalGuesses + 1
  149.     Else
  150.         Print "Actual:     ?"
  151.     End If
  152.     Print
  153.     Print "I'm on a "; _Trim$(Str$(streakGuess)); "-round winning streak."
  154.     Print "My best streak has been "; _Trim$(Str$(streakBest)); "."
  155.     Print "My correctness rate is "; _Trim$(Str$(Int(100 * correctGuesses / totalGuesses))); "% in "; _Trim$(Str$(totalGuesses)); " guesses."
  156.     If (j = Len(TheString)) Then
  157.         Print
  158.         Print "Complete."
  159.     End If
  160.  
  161.     ' Draw bottom graph
  162.     If (1 = 1) Then
  163.         For k = 1 To _Width
  164.             Locate _Height - 5, k: Print "_"
  165.             Locate _Height - 5 - Int(10), k: Print "_"
  166.         Next
  167.         Locate _Height - 5 + 1, 1: Print "0%"
  168.         Locate _Height - 5 - Int(10) - 1, 1: Print "100%"
  169.         f = (_Width - 1) / Int(Len(TheString))
  170.         If (f > 1) Then f = 1 / f
  171.         ProgressGraph(1 + Int(j * f)) = correctGuesses / totalGuesses
  172.         g = (_Width - 0) / Int(Len(TheString))
  173.         If (g > 1) Then g = 1
  174.         For k = 1 To Int(j * g)
  175.             Locate _Height - 5 - Int(10 * ProgressGraph(1 + Int(k * f))), k: Print "*"
  176.         Next
  177.     End If
  178.  
  179.     _Delay .015
  180.     _Display
  181.  
  182.  
  183. Function Analyze (TheStringIn As String, pswitch As Integer)
  184.     Dim TheReturn As Integer
  185.     Dim As Integer n
  186.     Dim As Double r, j, k, h
  187.     Dim Fingerprint(16) As String
  188.     Dim Partialguess(1 To 10, 2) As Double ' Change the upper bound to a higer number for more accuracy.
  189.  
  190.     ' Create shifted versions of string, i.e. ABCD -> BCDA, CDAB, DABC, ABCD, BCDA, etc.
  191.     Fingerprint(1) = TheStringIn
  192.     For n = 2 To UBound(Fingerprint)
  193.         Fingerprint(n) = Right$(Fingerprint(n - 1), Len(Fingerprint(n - 1)) - 1) + Left$(Fingerprint(n - 1), 1)
  194.     Next
  195.  
  196.     ' Initialize partial results.
  197.     For n = LBound(Partialguess) To UBound(Partialguess)
  198.         Partialguess(n, 1) = -999
  199.     Next
  200.  
  201.     Call CreateHisto(Fingerprint(), Alphabet1(), 1)
  202.     Call CreateHisto(Fingerprint(), Alphabet2(), 2)
  203.     Call CreateHisto(Fingerprint(), Alphabet3(), 3)
  204.     Call CreateHisto(Fingerprint(), Alphabet4(), 4)
  205.     Call CreateHisto(Fingerprint(), Alphabet5(), 5)
  206.     Call CreateHisto(Fingerprint(), Alphabet6(), 6)
  207.     Call CreateHisto(Fingerprint(), Alphabet7(), 7)
  208.     Call CreateHisto(Fingerprint(), Alphabet8(), 8)
  209.     Call CreateHisto(Fingerprint(), Alphabet9(), 9)
  210.     Call CreateHisto(Fingerprint(), Alphabet10(), 10)
  211.     'Call CreateHisto(Fingerprint(), Alphabet11(), 11)
  212.     'Call CreateHisto(Fingerprint(), Alphabet12(), 12)
  213.     'Call CreateHisto(Fingerprint(), Alphabet13(), 13)
  214.  
  215.     If (pswitch = 1) Then
  216.         For n = 1 To _Width
  217.             Print "-";
  218.         Next
  219.         Print
  220.     End If
  221.  
  222.     If (pswitch = 1) Then ' Set the last number >=1 to print stats for that histogram.
  223.         If (Len(TheStringIn) >= 1) Then Call PrintHisto(Alphabet1(), 2)
  224.         If (Len(TheStringIn) >= 2) Then Call PrintHisto(Alphabet2(), 3)
  225.         If (Len(TheStringIn) >= 3) Then Call PrintHisto(Alphabet3(), 3)
  226.         If (Len(TheStringIn) >= 4) Then Call PrintHisto(Alphabet4(), 0)
  227.         If (Len(TheStringIn) >= 5) Then Call PrintHisto(Alphabet5(), 0)
  228.         If (Len(TheStringIn) >= 6) Then Call PrintHisto(Alphabet6(), 0)
  229.         If (Len(TheStringIn) >= 7) Then Call PrintHisto(Alphabet7(), 0)
  230.         If (Len(TheStringIn) >= 8) Then Call PrintHisto(Alphabet8(), 0)
  231.         If (Len(TheStringIn) >= 9) Then Call PrintHisto(Alphabet9(), 0)
  232.         If (Len(TheStringIn) >= 10) Then Call PrintHisto(Alphabet10(), 0)
  233.         'If (Len(TheStringIn) >= 11) Then Call PrintHisto(Alphabet11(), 0)
  234.         'If (Len(TheStringIn) >= 12) Then Call PrintHisto(Alphabet12(), 0)
  235.         'If (Len(TheStringIn) >= 13) Then Call PrintHisto(Alphabet13(), 0)
  236.         Print
  237.     End If
  238.  
  239.     If (Len(TheStringIn) >= 1) Then Call MakeGuess(TheStringIn, Alphabet1(), 1, Partialguess(), pswitch)
  240.     If (Len(TheStringIn) >= 2) Then Call MakeGuess(TheStringIn, Alphabet2(), 2, Partialguess(), pswitch) ' Set the last number =1 to print guess for that histogram.
  241.     If (Len(TheStringIn) >= 3) Then Call MakeGuess(TheStringIn, Alphabet3(), 3, Partialguess(), pswitch)
  242.     If (Len(TheStringIn) >= 4) Then Call MakeGuess(TheStringIn, Alphabet4(), 4, Partialguess(), 0)
  243.     If (Len(TheStringIn) >= 5) Then Call MakeGuess(TheStringIn, Alphabet5(), 5, Partialguess(), 0)
  244.     If (Len(TheStringIn) >= 6) Then Call MakeGuess(TheStringIn, Alphabet6(), 6, Partialguess(), 0)
  245.     If (Len(TheStringIn) >= 7) Then Call MakeGuess(TheStringIn, Alphabet7(), 7, Partialguess(), 0)
  246.     If (Len(TheStringIn) >= 8) Then Call MakeGuess(TheStringIn, Alphabet8(), 8, Partialguess(), 0)
  247.     If (Len(TheStringIn) >= 9) Then Call MakeGuess(TheStringIn, Alphabet9(), 9, Partialguess(), 0)
  248.     If (Len(TheStringIn) >= 10) Then Call MakeGuess(TheStringIn, Alphabet10(), 10, Partialguess(), 0)
  249.     'If (Len(TheStringIn) >= 11) Then Call MakeGuess(TheStringIn, Alphabet11(), 11, Partialguess(), 0)
  250.     'If (Len(TheStringIn) >= 12) Then Call MakeGuess(TheStringIn, Alphabet12(), 12, Partialguess(), 0)
  251.     'If (Len(TheStringIn) >= 13) Then Call MakeGuess(TheStringIn, Alphabet13(), 13, Partialguess(), 0)
  252.     If (pswitch = 1) Then Print
  253.  
  254.     If (pswitch = 1) Then
  255.         Print "Thinking:";
  256.         For k = LBound(Partialguess) To UBound(Partialguess)
  257.             If (Partialguess(k, 1) <> -999) Then
  258.                 Print Partialguess(k, 1);
  259.             Else
  260.                 Print "_ ";
  261.             End If
  262.         Next
  263.         Print
  264.     End If
  265.  
  266.     j = 0
  267.     r = 0
  268.  
  269.     For k = UBound(Partialguess) To LBound(Partialguess) Step -1
  270.         If (Partialguess(k, 1) <> -999) Then
  271.  
  272.             ' This is the made-up part of the model:
  273.             ' The variable r contributes to weighted average.
  274.             ' The variable j is used for normalization.
  275.             ' Scaling factor h influences weighted average calculaton.
  276.             ' The factors multiplying h are totally arbitrary. Notes:
  277.             '   setting o(h^2) means the later alphabets count for more.
  278.             '   Partialguess(k, 1) euqals the calculated guess at frequency k.
  279.             '   Partialguess(k, 2) euqals the peak count of the unscaled histogram.
  280.             '   ...while Partialguess(k, 2) is here, it does not seem to help calculations.
  281.  
  282.             h = 1 + k - LBound(Partialguess)
  283.  
  284.             h = h ^ 2
  285.  
  286.             ' Standard weighted average:
  287.             r = r + h * Partialguess(k, 1)
  288.             j = j + h
  289.  
  290.         End If
  291.     Next
  292.     If (j <> 0) Then
  293.         r = r / j
  294.     End If
  295.  
  296.     If (pswitch = 1) Then Print "Predicting:  "; _Trim$(Str$(r))
  297.  
  298.     If (r > .5) Then
  299.         r = 1
  300.     Else
  301.         r = 0
  302.     End If
  303.  
  304.     If (pswitch = 1) Then
  305.         Print "Rounding to: "; _Trim$(Str$(r))
  306.     End If
  307.  
  308.     If (pswitch = 1) Then
  309.         For n = 1 To _Width
  310.             Print "-";
  311.         Next
  312.         Print: Print
  313.     End If
  314.  
  315.     TheReturn = r
  316.     Analyze = TheReturn
  317.  
  318. Sub MakeGuess (TheStringIn As String, arralpha() As LetterBin, wid As Integer, arrbeta() As Double, pswitch As Integer)
  319.     Dim TheReturn As Double
  320.     Dim As Integer j, k, n
  321.     TheReturn = 0
  322.     j = 1 '0
  323.     k = 0
  324.     For n = 1 To UBound(arralpha)
  325.         If (Left$(arralpha(n).Signature, wid - 1) = Right$(TheStringIn, wid - 1)) Then
  326.             If (arralpha(n).Count >= j) Then
  327.                 If (pswitch = 1) Then Print "Order-"; Right$("0" + _Trim$(Str$(wid)), 2); " guess: "; arralpha(n).Signature; " . "; _Trim$(Str$(arralpha(n).Count))
  328.                 TheReturn = TheReturn + Val(Right$(arralpha(n).Signature, 1))
  329.                 k = k + 1
  330.                 j = arralpha(n).Count
  331.             End If
  332.         End If
  333.     Next
  334.     If (k <> 0) Then
  335.         TheReturn = TheReturn / k
  336.         arrbeta(wid, 1) = TheReturn
  337.         arrbeta(wid, 2) = j
  338.     Else
  339.         TheReturn = .5
  340.         arrbeta(wid, 1) = TheReturn
  341.         arrbeta(wid, 2) = j
  342.     End If
  343.  
  344. Sub CreateHisto (arrfinger() As String, arralpha() As LetterBin, w As Integer)
  345.     Dim As Integer j, k, n
  346.     For n = 1 To UBound(arralpha)
  347.         arralpha(n).Count = 0
  348.     Next
  349.     For j = 1 To w
  350.         For k = 1 To Len(arrfinger(j)) - (Len(arrfinger(j)) Mod w) Step w '- 0 Step 1 'w 'make the 0 a -w? might not matter at all
  351.             For n = 1 To UBound(arralpha)
  352.                 If (Mid$(arrfinger(j), k, w) = arralpha(n).Signature) Then
  353.                     arralpha(n).Count = arralpha(n).Count + 1
  354.                 End If
  355.             Next
  356.         Next
  357.     Next
  358.     Call QuickSort(arralpha(), 1, UBound(arralpha))
  359.  
  360. Sub PrintHisto (arr() As LetterBin, w As Integer)
  361.     Dim As Integer j, n
  362.     If (w > 0) Then
  363.         If (w > UBound(arr)) Then
  364.             j = UBound(arr)
  365.         Else
  366.             j = w
  367.         End If
  368.         Print "Histogram: "; _Trim$(Str$(UBound(arr))); "-letter regroup, showing top "; _Trim$(Str$(w))
  369.         For n = 1 To j
  370.             Print arr(n).Signature; arr(n).Count
  371.         Next
  372.     End If
  373.  
  374. Sub NewAlphabet (arrold() As LetterBin, arrnew() As LetterBin)
  375.     Dim As Integer j, k, n
  376.     n = 0
  377.     For k = 1 To 2
  378.         For j = 1 To UBound(arrold)
  379.             n = n + 1
  380.             arrnew(n).Signature = arrold(j).Signature
  381.         Next
  382.     Next
  383.     For j = 1 To UBound(arrnew)
  384.         If (j <= UBound(arrnew) / 2) Then
  385.             arrnew(j).Signature = "0" + arrnew(j).Signature
  386.         Else
  387.             arrnew(j).Signature = "1" + arrnew(j).Signature
  388.         End If
  389.     Next
  390.  
  391. Sub QuickSort (arr() As LetterBin, LowLimit As Long, HighLimit As Long)
  392.     Dim As Long piv
  393.     If (LowLimit < HighLimit) Then
  394.         piv = Partition(arr(), LowLimit, HighLimit)
  395.         Call QuickSort(arr(), LowLimit, piv - 1)
  396.         Call QuickSort(arr(), piv + 1, HighLimit)
  397.     End If
  398.  
  399. Function Partition (arr() As LetterBin, LowLimit As Long, HighLimit As Long)
  400.     Dim As Long i, j
  401.     Dim As Double pivot, tmp
  402.     pivot = arr(HighLimit).Count
  403.     i = LowLimit - 1
  404.     For j = LowLimit To HighLimit - 1
  405.         tmp = arr(j).Count - pivot
  406.         If (tmp >= 0) Then
  407.             i = i + 1
  408.             Swap arr(i), arr(j)
  409.         End If
  410.     Next
  411.     Swap arr(i + 1), arr(HighLimit)
  412.     Partition = i + 1
  413.  

Looks like this now while running:

  [ This attachment cannot be displayed inline in 'Print Page' view ]  
Title: Re: Looking for old program or help recreating it
Post by: random1 on December 15, 2021, 07:16:07 pm
If it gets any better the possibilities will expand exponentially.  I think it's has already
surpassed my expectations but more is better. 

Your quickly becoming my best new friend, LOL.  Can't wait for future improvements.

R1
Title: Re: Looking for old program or help recreating it
Post by: random1 on December 15, 2021, 08:10:15 pm
I am going to add stats for each prediction be it a 0 or 1.  This way I can track the
percentages of correct predictions for each value.

Also in my main program, if a string contains all 0's or all 1's then it skips the predictor
stage and uses the digit that makes up the entire string as the prediction.  Nothing to be
gained by processing a string if there's only one choice.

I have ran several strings that I consider the hardest to predict and while the overall is
lower, high 60's to low 70's, the streaks seem to increase in size. 

R1     


     
Title: Re: Looking for old program or help recreating it
Post by: STxAxTIC on December 15, 2021, 08:29:46 pm
Hey r1,

I have made such a weird discovery, I don't even know its implications yet, but follow me for a minute.

* Suppose I have a string that starts just as a "1". To be definite, call this x$. So x$ = "1".
* Next I feed this through the analyzer, and the analyzer tells me that another "1" is most likely to come next. Ok, so at this stage, lets do the *opposite*.
* Append x$ with a "0", having predicted a 1. So x$ = "10" now.
* Feed this new x$ through the analyzer, and it predicts a "1" should follow the "10". But we're doing the opposite, so I append x$ = "100".

See what I'm doing? Start with a seed, and whatever the predictor says, make a string that's the opposite of whats predicted. The result is hilarious. You wind up with a thing I'll call a "pathological string", where all predictions are WRONG by definition. Look at this result!

  [ This attachment cannot be displayed inline in 'Print Page' view ]  

It's flat zeros! Don't do any fretting though, we're out on impossible limb. For real data to behave this way randomly would take longer than the age of the universe. Or, put another way, some system that feeds you such data would be indistinguishable, in that moment, from the program you're looking at now. (Weird.) It turns out I can generate probably infinite of these "pathological strings". But it gets even more interesting. Change even a single digit, such as the first digit, and everything downstream of that shatters like glass, and its back to a usual-looking pattern. Here is the same sequence minus the first character:

  [ This attachment cannot be displayed inline in 'Print Page' view ]  

Even though the entire string is meant to "trick" the analyzer, the entire string needs to be intact for the trick to happen. That's super interesting. There is nothing fundamental about the so-called pathological string, I mean in terms of their contents. They are strictly dependent on the model being used, and that is buried in my Analyze function. Their existence will always persist though, regardless of the model. There's got to be some kind of theorem about this... Anyway, thought you'd find this academically interesting. Has very little bearing on the task at hand, but here are what some more patholgical strings look like:

Code: QB64: [Select]
  1.     '''
  2.     ' Pathological cases:
  3.     '''
  4.     n = n + 1: TestData(n) = "011111101111111110101111110011111110110111110111011110111001110111010110111101001111101010111110010111100110111011010110" ' seed 0
  5.     n = n + 1: TestData(n) = "100000010000000001010000001100000001001000001000100001000110001000101001000010110000010101000001101000011001000100101001" ' seed 1
  6.     n = n + 1: TestData(n) = "001111111110111111101011111100111110111011110110111110101011110111100110111111000111111110010111110011101110101101110010" ' seed 00
  7.     n = n + 1: TestData(n) = "011111101111111110101111110011111110110111110111011110111001110111010110111101001111101010111110010111100110111011010110" ' seed 01
  8.     n = n + 1: TestData(n) = "100000010000000001010000001100000001001000001000100001000110001000101001000010110000010101000001101000011001000100101001" ' seed 10
  9.     n = n + 1: TestData(n) = "110000000001000000010100000011000001000100001001000001010100001000011001000000111000000001101000001100010001010010001101" ' seed 11
  10.     n = n + 1: TestData(n) = "000111111111011111101101111101011111110011111110101011101110110110101110011101111011101010011110110011111011110011011110" ' seed 000
  11.     n = n + 1: TestData(n) = "001111111110111111101011111100111110111011110110111110101011110111100110111111000111111110010111110011101110101101110010" ' seed 001
  12.     n = n + 1: TestData(n) = "010111111111011111101101111101011110111011110101011111100111111110010111110111001110111110001111110100111110101101110100" ' seed 010
  13.     n = n + 1: TestData(n) = "011111101111111110101111110011111110110111110111011110111001110111010110111101001111101010111110010111100110111011010110" ' seed 011
  14.     n = n + 1: TestData(n) = "100000010000000001010000001100000001001000001000100001000110001000101001000010110000010101000001101000011001000100101001" ' seed 100
  15.     n = n + 1: TestData(n) = "101000000000100000010010000010100001000100001010100000011000000001101000001000110001000001110000001011000001010010001011" ' seed 101

And those are sensitive - change one thing and the graph explodes like you're taking apart a wristwatch. Full code below:

Code: QB64: [Select]
  1.  
  2. Screen _NewImage(120, 40)
  3.  
  4. ' Version: 14
  5.  
  6. Type LetterBin
  7.     Signature As String
  8.     Count As Integer
  9.  
  10. Dim Shared Alphabet1(2) As LetterBin ' 0 1
  11. Dim Shared Alphabet2(4) As LetterBin ' 00 01 10 11
  12. Dim Shared Alphabet3(8) As LetterBin ' 000 001 010 011 100 101 110 111
  13. Dim Shared Alphabet4(16) As LetterBin ' etc.
  14. Dim Shared Alphabet5(32) As LetterBin
  15. Dim Shared Alphabet6(64) As LetterBin
  16. Dim Shared Alphabet7(128) As LetterBin
  17. Dim Shared Alphabet8(256) As LetterBin
  18. Dim Shared Alphabet9(512) As LetterBin
  19. Dim Shared Alphabet10(1024) As LetterBin
  20. Dim Shared Alphabet11(2048) As LetterBin
  21. Dim Shared Alphabet12(4096) As LetterBin
  22. Dim Shared Alphabet13(8192) As LetterBin
  23.  
  24. Alphabet1(1).Signature = "0"
  25. Alphabet1(2).Signature = "1"
  26. Call NewAlphabet(Alphabet1(), Alphabet2())
  27. Call NewAlphabet(Alphabet2(), Alphabet3())
  28. Call NewAlphabet(Alphabet3(), Alphabet4())
  29. Call NewAlphabet(Alphabet4(), Alphabet5())
  30. Call NewAlphabet(Alphabet5(), Alphabet6())
  31. Call NewAlphabet(Alphabet6(), Alphabet7())
  32. Call NewAlphabet(Alphabet7(), Alphabet8())
  33. Call NewAlphabet(Alphabet8(), Alphabet9())
  34. Call NewAlphabet(Alphabet9(), Alphabet10())
  35. Call NewAlphabet(Alphabet10(), Alphabet11())
  36. Call NewAlphabet(Alphabet11(), Alphabet12())
  37. Call NewAlphabet(Alphabet12(), Alphabet13())
  38.  
  39. '''
  40.  
  41. ReDim Shared TestData(1000) As String
  42. ReDim _Preserve TestData(LoadTestData(0))
  43.  
  44. Dim TheString As String
  45.  
  46. Dim As Integer j, k, n
  47. Dim GuessPredicted As Integer
  48. Dim GuessesCorrect As Double
  49. Dim GuessesTotal As Double
  50. Dim GuessStreak As Integer
  51. Dim GuessStreakBest As Integer
  52.  
  53. Dim ProgressGraph(1 To _Width, 2) As Double
  54.  
  55.  
  56. For n = 1 To UBound(TestData)
  57.  
  58.     TheString = TestData(n)
  59.     GuessesCorrect = 0
  60.     GuessesTotal = 0
  61.     GuessStreak = 0
  62.     GuessStreakBest = 0
  63.  
  64.     ' Uncomment this to manually test one string.
  65.     '''
  66.     '1
  67.     TheString = "00000010000000001010000001100000001001000001000100001000110001000101001000010110000010101000001101000011001000100101001"
  68.  
  69.     '''
  70.     'Cls: Locate 1, 1
  71.     'Input "", TheString
  72.     '''
  73.  
  74.     For j = 1 To Len(TheString)
  75.  
  76.         Cls
  77.         Locate 1, 1
  78.         For k = 1 To _Width
  79.             Print "_";
  80.         Next
  81.         Print
  82.         Print "Analyzing: (test string # "; _Trim$(Str$(n)); ", length "; _Trim$(Str$(Len(TheString))); ")"
  83.         Print
  84.         Color 7
  85.         Print Left$(TheString, j);
  86.         Color 8
  87.         Print "["; Right$(TheString, Len(TheString) - j); "]"
  88.         Color 7
  89.         Print
  90.  
  91.         ' Main prediction call
  92.         GuessPredicted = Analyze(Left$(TheString, j), 0)
  93.  
  94.         ' Reconciliation
  95.         Print "Prediction: "; _Trim$(Str$(GuessPredicted))
  96.         If (j < Len(TheString)) Then
  97.             Print "Actual:     "; _Trim$(Mid$(TheString, j + 1, 1))
  98.             If (GuessPredicted = Val(Mid$(TheString, j + 1, 1))) Then
  99.                 GuessesCorrect = GuessesCorrect + 1
  100.                 GuessStreak = GuessStreak + 1
  101.                 If (GuessStreak > GuessStreakBest) Then GuessStreakBest = GuessStreak
  102.                 Print "I am RIGHT this round."
  103.             Else
  104.                 GuessStreak = 0
  105.                 Print "I am WRONG this round."
  106.             End If
  107.             GuessesTotal = GuessesTotal + 1
  108.         Else
  109.             Print "Actual:     ?"
  110.         End If
  111.         Print
  112.         Print "I'm on a "; _Trim$(Str$(GuessStreak)); "-round winning streak."
  113.         Print "My best streak has been "; _Trim$(Str$(GuessStreakBest)); "."
  114.         Print "My correctness rate is "; _Trim$(Str$(Int(100 * GuessesCorrect / GuessesTotal))); "% in "; _Trim$(Str$(GuessesTotal)); " guesses."
  115.         If (j = Len(TheString)) Then
  116.             Print
  117.             Print "Complete."
  118.         End If
  119.  
  120.         ' Draw bottom graph
  121.         If (1 = 1) Then
  122.             For k = 1 To _Width
  123.                 Locate _Height - 5, k: Print "_"
  124.                 Locate _Height - 5 - Int(10), k: Print "_"
  125.             Next
  126.             Locate _Height - 5 + 1, 1: Print "0%"
  127.             Locate _Height - 5 - Int(10) - 1, 1: Print "100%"
  128.             f = (_Width - 1) / Int(Len(TheString))
  129.             If (f > 1) Then f = 1 / f
  130.             ProgressGraph(1 + Int(j * f), 1) = GuessesCorrect / GuessesTotal
  131.             If (GuessStreak = 0) Then
  132.                 ProgressGraph(1 + Int(j * f), 2) = 120
  133.             Else
  134.                 ProgressGraph(1 + Int(j * f), 2) = 251
  135.             End If
  136.             g = (_Width - 0) / Int(Len(TheString))
  137.             If (g > 1) Then g = 1
  138.             For k = 1 To Int(j * g)
  139.                 Locate _Height - 5 - Int(10 * ProgressGraph(1 + Int(k * f), 1)), k: Print Chr$(ProgressGraph(1 + Int(k * f), 2))
  140.             Next
  141.         End If
  142.  
  143.         _Delay .015
  144.         _Display
  145.     Next
  146.  
  147.     _Delay 3
  148.  
  149.  
  150.  
  151. Function Analyze (TheStringIn As String, pswitch As Integer)
  152.     Dim TheReturn As Integer
  153.     Dim As Integer n
  154.     Dim As Double r, j, k, h
  155.     Dim Fingerprint(16) As String
  156.     Dim Partialguess(1 To 10, 2) As Double ' Change the upper bound to a higer number for more accuracy.
  157.  
  158.     ' Create shifted versions of string, i.e. ABCD -> BCDA, CDAB, DABC, ABCD, BCDA, etc.
  159.     Fingerprint(1) = TheStringIn
  160.     For n = 2 To UBound(Fingerprint)
  161.         Fingerprint(n) = Right$(Fingerprint(n - 1), Len(Fingerprint(n - 1)) - 1) + Left$(Fingerprint(n - 1), 1)
  162.     Next
  163.  
  164.     ' Initialize partial results.
  165.     For n = LBound(Partialguess) To UBound(Partialguess)
  166.         Partialguess(n, 1) = -999
  167.     Next
  168.  
  169.     Call CreateHisto(Fingerprint(), Alphabet1(), 1)
  170.     Call CreateHisto(Fingerprint(), Alphabet2(), 2)
  171.     Call CreateHisto(Fingerprint(), Alphabet3(), 3)
  172.     Call CreateHisto(Fingerprint(), Alphabet4(), 4)
  173.     Call CreateHisto(Fingerprint(), Alphabet5(), 5)
  174.     Call CreateHisto(Fingerprint(), Alphabet6(), 6)
  175.     Call CreateHisto(Fingerprint(), Alphabet7(), 7)
  176.     Call CreateHisto(Fingerprint(), Alphabet8(), 8)
  177.     Call CreateHisto(Fingerprint(), Alphabet9(), 9)
  178.     Call CreateHisto(Fingerprint(), Alphabet10(), 10)
  179.     'Call CreateHisto(Fingerprint(), Alphabet11(), 11)
  180.     'Call CreateHisto(Fingerprint(), Alphabet12(), 12)
  181.     'Call CreateHisto(Fingerprint(), Alphabet13(), 13)
  182.  
  183.     If (pswitch = 1) Then
  184.         For n = 1 To _Width
  185.             Print "-";
  186.         Next
  187.         Print
  188.     End If
  189.  
  190.     If (pswitch = 1) Then ' Set the last number >=1 to print stats for that histogram.
  191.         If (Len(TheStringIn) >= 1) Then Call PrintHisto(Alphabet1(), 2)
  192.         If (Len(TheStringIn) >= 2) Then Call PrintHisto(Alphabet2(), 3)
  193.         If (Len(TheStringIn) >= 3) Then Call PrintHisto(Alphabet3(), 3)
  194.         If (Len(TheStringIn) >= 4) Then Call PrintHisto(Alphabet4(), 0)
  195.         If (Len(TheStringIn) >= 5) Then Call PrintHisto(Alphabet5(), 0)
  196.         If (Len(TheStringIn) >= 6) Then Call PrintHisto(Alphabet6(), 0)
  197.         If (Len(TheStringIn) >= 7) Then Call PrintHisto(Alphabet7(), 0)
  198.         If (Len(TheStringIn) >= 8) Then Call PrintHisto(Alphabet8(), 0)
  199.         If (Len(TheStringIn) >= 9) Then Call PrintHisto(Alphabet9(), 0)
  200.         If (Len(TheStringIn) >= 10) Then Call PrintHisto(Alphabet10(), 0)
  201.         'If (Len(TheStringIn) >= 11) Then Call PrintHisto(Alphabet11(), 0)
  202.         'If (Len(TheStringIn) >= 12) Then Call PrintHisto(Alphabet12(), 0)
  203.         'If (Len(TheStringIn) >= 13) Then Call PrintHisto(Alphabet13(), 0)
  204.         Print
  205.     End If
  206.  
  207.     If (Len(TheStringIn) >= 1) Then Call MakeGuess(TheStringIn, Alphabet1(), 1, Partialguess(), pswitch) ' Set the last number =1 to print guess for that histogram.
  208.     If (Len(TheStringIn) >= 2) Then Call MakeGuess(TheStringIn, Alphabet2(), 2, Partialguess(), pswitch)
  209.     If (Len(TheStringIn) >= 3) Then Call MakeGuess(TheStringIn, Alphabet3(), 3, Partialguess(), pswitch)
  210.     If (Len(TheStringIn) >= 4) Then Call MakeGuess(TheStringIn, Alphabet4(), 4, Partialguess(), 0)
  211.     If (Len(TheStringIn) >= 5) Then Call MakeGuess(TheStringIn, Alphabet5(), 5, Partialguess(), 0)
  212.     If (Len(TheStringIn) >= 6) Then Call MakeGuess(TheStringIn, Alphabet6(), 6, Partialguess(), 0)
  213.     If (Len(TheStringIn) >= 7) Then Call MakeGuess(TheStringIn, Alphabet7(), 7, Partialguess(), 0)
  214.     If (Len(TheStringIn) >= 8) Then Call MakeGuess(TheStringIn, Alphabet8(), 8, Partialguess(), 0)
  215.     If (Len(TheStringIn) >= 9) Then Call MakeGuess(TheStringIn, Alphabet9(), 9, Partialguess(), 0)
  216.     If (Len(TheStringIn) >= 10) Then Call MakeGuess(TheStringIn, Alphabet10(), 10, Partialguess(), 0)
  217.     'If (Len(TheStringIn) >= 11) Then Call MakeGuess(TheStringIn, Alphabet11(), 11, Partialguess(), 0)
  218.     'If (Len(TheStringIn) >= 12) Then Call MakeGuess(TheStringIn, Alphabet12(), 12, Partialguess(), 0)
  219.     'If (Len(TheStringIn) >= 13) Then Call MakeGuess(TheStringIn, Alphabet13(), 13, Partialguess(), 0)
  220.     If (pswitch = 1) Then Print
  221.  
  222.     If (pswitch = 1) Then
  223.         Print "Thinking:";
  224.         For k = LBound(Partialguess) To UBound(Partialguess)
  225.             If (Partialguess(k, 1) <> -999) Then
  226.                 Print Partialguess(k, 1);
  227.             Else
  228.                 Print "_ ";
  229.             End If
  230.         Next
  231.         Print
  232.     End If
  233.  
  234.     j = 0
  235.     r = 0
  236.  
  237.     For k = UBound(Partialguess) To LBound(Partialguess) Step -1
  238.         If (Partialguess(k, 1) <> -999) Then
  239.  
  240.             ' This is the made-up part of the model:
  241.             ' The variable r contributes to weighted average.
  242.             ' The variable j is used for normalization.
  243.             ' Scaling factor h influences weighted average calculaton.
  244.             ' The factors multiplying h are totally arbitrary. Notes:
  245.             '   setting o(h^2) means the later alphabets count for more.
  246.             '   Partialguess(k, 1) euqals the calculated guess at frequency k.
  247.             '   Partialguess(k, 2) euqals the peak count of the unscaled histogram.
  248.             '   ...while Partialguess(k, 2) is here, it does not seem to help calculations.
  249.  
  250.             h = 1 + k - LBound(Partialguess)
  251.  
  252.             h = h ^ 2
  253.  
  254.             ' Standard weighted average:
  255.             r = r + h * Partialguess(k, 1)
  256.             j = j + h
  257.  
  258.         End If
  259.     Next
  260.     If (j <> 0) Then
  261.         r = r / j
  262.     End If
  263.  
  264.     If (pswitch = 1) Then Print "Predicting:  "; _Trim$(Str$(r))
  265.  
  266.     If (r > .5) Then
  267.         r = 1
  268.     Else
  269.         r = 0
  270.     End If
  271.  
  272.     If (pswitch = 1) Then
  273.         Print "Rounding to: "; _Trim$(Str$(r))
  274.     End If
  275.  
  276.     If (pswitch = 1) Then
  277.         For n = 1 To _Width
  278.             Print "-";
  279.         Next
  280.         Print: Print
  281.     End If
  282.  
  283.     TheReturn = r
  284.     Analyze = TheReturn
  285.  
  286. Sub MakeGuess (TheStringIn As String, arralpha() As LetterBin, wid As Integer, arrbeta() As Double, pswitch As Integer)
  287.     Dim TheReturn As Double
  288.     Dim As Integer j, k, n
  289.     TheReturn = 0
  290.     j = 1
  291.     k = 0
  292.     For n = 1 To UBound(arralpha)
  293.         If (Left$(arralpha(n).Signature, wid - 1) = Right$(TheStringIn, wid - 1)) Then
  294.             If (arralpha(n).Count >= j) Then
  295.                 If (pswitch = 1) Then Print "Order-"; Right$("0" + _Trim$(Str$(wid)), 2); " guess: "; arralpha(n).Signature; " . "; _Trim$(Str$(arralpha(n).Count))
  296.                 TheReturn = TheReturn + Val(Right$(arralpha(n).Signature, 1))
  297.                 k = k + 1
  298.                 j = arralpha(n).Count
  299.             End If
  300.         End If
  301.     Next
  302.     If (k <> 0) Then
  303.         TheReturn = TheReturn / k
  304.         arrbeta(wid, 1) = TheReturn
  305.         arrbeta(wid, 2) = j
  306.     Else
  307.         TheReturn = .5
  308.         arrbeta(wid, 1) = TheReturn
  309.         arrbeta(wid, 2) = j
  310.     End If
  311.  
  312. Sub CreateHisto (arrfinger() As String, arralpha() As LetterBin, w As Integer)
  313.     Dim As Integer j, k, n
  314.     For n = 1 To UBound(arralpha)
  315.         arralpha(n).Count = 0
  316.     Next
  317.     For j = 1 To w
  318.         For k = 1 To Len(arrfinger(j)) - (Len(arrfinger(j)) Mod w) Step w '- 0 Step 1 'w 'make the 0 a -w? might not matter at all
  319.             For n = 1 To UBound(arralpha)
  320.                 If (Mid$(arrfinger(j), k, w) = arralpha(n).Signature) Then
  321.                     arralpha(n).Count = arralpha(n).Count + 1
  322.                 End If
  323.             Next
  324.         Next
  325.     Next
  326.     Call QuickSort(arralpha(), 1, UBound(arralpha))
  327.  
  328. Sub PrintHisto (arr() As LetterBin, w As Integer)
  329.     Dim As Integer j, n
  330.     If (w > 0) Then
  331.         If (w > UBound(arr)) Then
  332.             j = UBound(arr)
  333.         Else
  334.             j = w
  335.         End If
  336.         Print "Histogram: "; _Trim$(Str$(UBound(arr))); "-letter regroup, showing top "; _Trim$(Str$(w))
  337.         For n = 1 To j
  338.             Print arr(n).Signature; arr(n).Count
  339.         Next
  340.     End If
  341.  
  342. Sub NewAlphabet (arrold() As LetterBin, arrnew() As LetterBin)
  343.     Dim As Integer j, k, n
  344.     n = 0
  345.     For k = 1 To 2
  346.         For j = 1 To UBound(arrold)
  347.             n = n + 1
  348.             arrnew(n).Signature = arrold(j).Signature
  349.         Next
  350.     Next
  351.     For j = 1 To UBound(arrnew)
  352.         If (j <= UBound(arrnew) / 2) Then
  353.             arrnew(j).Signature = "0" + arrnew(j).Signature
  354.         Else
  355.             arrnew(j).Signature = "1" + arrnew(j).Signature
  356.         End If
  357.     Next
  358.  
  359. Sub QuickSort (arr() As LetterBin, LowLimit As Long, HighLimit As Long)
  360.     Dim As Long piv
  361.     If (LowLimit < HighLimit) Then
  362.         piv = Partition(arr(), LowLimit, HighLimit)
  363.         Call QuickSort(arr(), LowLimit, piv - 1)
  364.         Call QuickSort(arr(), piv + 1, HighLimit)
  365.     End If
  366.  
  367. Function Partition (arr() As LetterBin, LowLimit As Long, HighLimit As Long)
  368.     Dim As Long i, j
  369.     Dim As Double pivot, tmp
  370.     pivot = arr(HighLimit).Count
  371.     i = LowLimit - 1
  372.     For j = LowLimit To HighLimit - 1
  373.         tmp = arr(j).Count - pivot
  374.         If (tmp >= 0) Then
  375.             i = i + 1
  376.             Swap arr(i), arr(j)
  377.         End If
  378.     Next
  379.     Swap arr(i + 1), arr(HighLimit)
  380.     Partition = i + 1
  381.  
  382. Function LoadTestData (alwayszero As Integer)
  383.     Dim n As Integer
  384.     n = alwayszero
  385.     '''
  386.     ' Systematic cases:
  387.     '''
  388.     n = n + 1: TestData(n) = "1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111"
  389.     n = n + 1: TestData(n) = "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
  390.     n = n + 1: TestData(n) = "0101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101"
  391.     n = n + 1: TestData(n) = "1010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010"
  392.     n = n + 1: TestData(n) = "0010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010"
  393.     n = n + 1: TestData(n) = "0100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100"
  394.     n = n + 1: TestData(n) = "1001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001"
  395.     n = n + 1: TestData(n) = "1101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101"
  396.     n = n + 1: TestData(n) = "1011011011011011011011011011011011011011011011011011011011011011011011011011011011011011011011011011011011011011011011011011011011011011011011011011011011011011"
  397.     n = n + 1: TestData(n) = "0110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110"
  398.     '
  399.     '''
  400.     ' Community hand-typed cases:
  401.     '''
  402.     ' (from Cobalt) (Results in: 48%  -  Claims he made this data hand but behavior in Discord raises doubt.)
  403.     n = n + 1: TestData(n) = "1010001101110110000000011100110100101010111110101001100101110100000111101011011000010101101100000110010010010101010110111111111001000100101011101000011110011000000100111100001100111000111100100000000111010011010011001111101000010011101111000011100011010110101101000111101111100101100100000101111011001101100000111011000001001111000110000001110101100101"
  404.     ' (from Keybone) (Results in: 82%)
  405.     n = n + 1: TestData(n) = "101010101010101010101001010101010101001010111001010101010101010101010100010101010101010100101001010101001100101010001010100101010100101010100101010101010101010011011110010101010100100101010110010011001010011001010100010100101010010101010101010010101010101010010101001010101010100110010101010100101010101010011001001010100101010010101010100101010010101001010100101001010010101010111010100110011001010101010100110101001010101010100101001010111010101010101010100101001010101010010101010101001010101001010101001010100101010100101010010101010101001010101001010101010101001010101001010100101010101010010101010010010101010101010101010010100101010101001010100101001010101001111101010101010100101010110011001010101010101010110101010101101010101010100101010010101010010101010101101110010101001010101010110010100101010101001011010101010100110101010100101010010101010100101010101001010101010101001010101010011010101010101110110100101010111010101011011001011001010101001010101010101010101010011001010101010100101010101010101010010100101"
  406.     ' (from Keybone) (Results in: 54%)
  407.     n = n + 1: TestData(n) = "0101110101100011010100101011001110001011001010001110101111010100111011100100101001010011110101101000101010001010101111001010111010101010100001010101000101101100101111101010010101110110111001000101000011010101010001001001001111101011101010100010110101110101100000101010101110111010100100100001110111100101011110101010001010001110010110111110110010101001001011101000101001011100011101000010101010101101010010110100101101000101111010101110111001010011101111010101000010101111100010101011110101011011110100001010110"
  408.     ' (from Loudar) (Results in: 71%)
  409.     n = n + 1: TestData(n) = "1011001010010100100100110010101010101001010101010101011010010101001010101001010010100110101011010101010101011010101101010101010101010010110101010101100101010101010110101101011010010101010010100110101101001010110101011010010101101010110100101111010101010011011011010010110101010010110100101101010100101011010010101001010101010001011101011010010101011100111010010001101011110010011010001011100110101010010011010101001001010010000101010110001"
  410.     ' (from Luke) (Results in: 51%  -  I have long suspected Luke to be a computer. The numbers are now in.)
  411.     n = n + 1: TestData(n) = "01100101001010001100001101101111011010010101010110110101001000001111001111110101000101111011010101111101010101101010101001010101011000010101010101001011010100110100110100110011010101010101110101010111111101011010100000001101111000010111000110111001000010100001101010110100000111101011111100001011001010110010110" ' Luke 50
  412.     ' (from Sarafromct) (Results in: 64%)
  413.     n = n + 1: TestData(n) = "10101010101011101000011101010111010101010101100111001010100111100001011011110101000001111010101101010000001111110011111110111101110111001110110010000100010101010101010100101011010110101010101010101001000000001111110000011110101010101010100010101110101010101101111111111111111111101010101010101000000" ' 63
  414.     ' (from Spriggs) (Results in: 85%)
  415.     n = n + 1: TestData(n) = "10111010101010101010101001010101010101001010101001010101010101010101010101010101010101010101010101010101001010100100100101010101010101001010100101010101010100101010100101010101010101010101001010010110010101010010101010101010101010101010100101001001001010101010101010101010101001010101001001101010010"
  416.     ' (from Spriggs) (Results in: 67%)
  417.     n = n + 1: TestData(n) = "11111011110100101011111111110100000011011110101100111100111111110111101110100111100110011111110101111111010111101111100111110111111111111011100111110111111110010000101011111001110101101010110111110"
  418.     ' (from Hotpants) (Results in: 62%)
  419.     n = n + 1: TestData(n) = "01010100011001010010101010101010101000110101010111101010100100011010101010100100101110010010010100001010101001010101010110010001001011000100100110101001001001010000000001010101101111101001010100010101001001010101000100101001100100010011010101010101010111010010101011101011011010110100100010010100100100010010001001" ' Tom
  420.     '
  421.     '''
  422.     ' Known-Random cases:
  423.     '''
  424.     ' (using RND) (Results in: 45%)
  425.     n = n + 1: TestData(n) = "11100101110011011010110100110011111011010110100100000110000100101001001010011100111101101110000001000000011011100101110000000111100100011101000000101000110100001000000001111010101011000010001110111110001001110101011000010101001111010100100000011100110110110000111010001010000011010000101111101011000"
  426.     ' (from Spriggs) (Results in: 52%)
  427.     n = n + 1: TestData(n) = "010101111010111100110000001001100100101100000101110001100101000010001001111101111111111100011110000011011110011000100011100100001101110011001001011001000011110010001000111100011100011110010110011110111010110100001000110000010000111000111011100110011010101111111100100010001111111100010100001011000011"
  428.     ' (Wolfrm rule 30, central column) (Results in: 47%)
  429.     n = n + 1: TestData(n) = "110111001100010110010011101011100111010101100001100101011010101111110000111100010101110000010010110001"
  430.     ' (using RND) (Results in: 46%)
  431.     n = n + 1: TestData(n) = "111001011100110110101101001100111110110101101001000001100001001010010010100111001111011011100000010000000110111001011100000001111001000111010000001010001101000010000000011110101010110000100011101111100010011101010110000101010011110101001000000111001101101100001110100010100000110100001011111010110000"
  432.     ' (using RND) (Results in: 46%)
  433.     n = n + 1: TestData(n) = "111001011100110110101101001100111110110101101001000001100001001010010010100111001111011011100000010000000110111001011100000001111001000111010000001010001101000010000000011110101010110000100011101111100010011101010110000101010011110101001000000111001101101100001110100010100000110100001011111010110000101110111110011100001000110010010001100111101000001101011000010101101011111010010001010010110110011000001001101000011100000011110001110011100010101010111101100100100001001000101101110110101100001111011101000100111110000001110000111011101000110110100111101101001100100110000111110111101001100010011110"
  434.     ' (using RND) (Results in: 45%)
  435.     n = n + 1: TestData(n) = "111001011100110110101101001100111110110101101001000001100001001010010010100111001111011011100000010000000110111001011100000001111001000111010000001010001101000010000000011110101010110000100011101111100010011101010110000101010011110101001000000111001101101100001110100010100000110100001011111010110000101110111110011100001000110010010001100111101000001101011000010101101011111010010001010010110110011000001001101000011100000011110001110011100010101010111101100100100001001000101101110110101100001111011101000100111110000001110000111011101000110110100111101101001100100110000111110111101001100010011110111001001100111000110011011000100101100010101010000010000111111010111111011100011100001000011000100100111001100001111010001010000001011100000101110000110010111110010101010110111110011100100001011101010000011011110110100010110111000100000110000001001010001011010000010001111110100100010011100011001000"
  436.     ' (using RND) (Results in: 48%)
  437.     n = n + 1: TestData(n) = "111001011100110110101101001100111110110101101001000001100001001010010010100111001111011011100000010000000110111001011100000001111001000111010000001010001101000010000000011110101010110000100011101111100010011101010110000101010011110101001000000111001101101100001110100010100000110100001011111010110000101110111110011100001000110010010001100111101000001101011000010101101011111010010001010010110110011000001001101000011100000011110001110011100010101010111101100100100001001000101101110110101100001111011101000100111110000001110000111011101000110110100111101101001100100110000111110111101001100010011110111001001100111000110011011000100101100010101010000010000111111010111111011100011100001000011000100100111001100001111010001010000001011100000101110000110010111110010101010110111110011100100001011101010000011011110110100010110111000100000110000001001010001011010000010001111110100100010011100011001000011101011010100110110000110010010011110111001001011111011000000100010011011100111110111011111101100011011101001111110100011010000111001001010111011101000001010010010100111010001001010101001000010011100111010101000110010110101111001110000010110110010101001000011000101000001100110100111101000110111101101010011011000101100101001010001100110101000101110000101100110010011010001010101010101101110101110110101100101001111100110110101011001000001100101001011000101100001001000001010111010100010100101011001111001011011100011001110010111011110010111101011101000100100010111010000001010011101010001110110110101011000101010100000001110110101011110101111100100101101000001011000101001110010010010000111001101010100101111101001110010001011000001001000111010001000011000111000000111001110111110011110110101100111011001100101101010101100010100100001010010110010000001100110010010100110011110110000001001000111001001010010000011111110011110010001100011100011010000111100111111010010001010011100100111100111101111110101000010011100011111100010000011111101101010010100000011011001110001100001011111100111000001110111011001111110011011100111000110110110011110000111000010011011000011001111111110010100000111110011111100100001100000000110001111101101011100011111011110001100100001100011100011111000000110011011100110101101001001111101101000000110101101001100011100011001110001000000111111100110101001110100010010010100000010100001010001011011001101010011111001101110110010101000111101100111000011000111001100011011011010100111111001100000100100110000100101001111111100110010111100000111101101001111001010011010011011100101001001001110101110001101010001111010101100101010111000111000011000001010010010101010100001110010001001001110110011100110011111001100111010011110100100110010000100011010001110000000100001100000010000111000111111000111100010001101011000101000010100011100011111000100010101000001001011001000101101111110111110110001101001001011100011110001101100010100101101011001001100111000000111111110110100010111111101000000001111000100001111111011000101001111110010000110101100010000011100110111101011011100110"
  438.     '
  439.     '''
  440.     ' Pathological cases:
  441.     '''
  442.     n = n + 1: TestData(n) = "011111101111111110101111110011111110110111110111011110111001110111010110111101001111101010111110010111100110111011010110" ' seed 0
  443.     n = n + 1: TestData(n) = "100000010000000001010000001100000001001000001000100001000110001000101001000010110000010101000001101000011001000100101001" ' seed 1
  444.     n = n + 1: TestData(n) = "001111111110111111101011111100111110111011110110111110101011110111100110111111000111111110010111110011101110101101110010" ' seed 00
  445.     n = n + 1: TestData(n) = "011111101111111110101111110011111110110111110111011110111001110111010110111101001111101010111110010111100110111011010110" ' seed 01
  446.     n = n + 1: TestData(n) = "100000010000000001010000001100000001001000001000100001000110001000101001000010110000010101000001101000011001000100101001" ' seed 10
  447.     n = n + 1: TestData(n) = "110000000001000000010100000011000001000100001001000001010100001000011001000000111000000001101000001100010001010010001101" ' seed 11
  448.     n = n + 1: TestData(n) = "000111111111011111101101111101011111110011111110101011101110110110101110011101111011101010011110110011111011110011011110" ' seed 000
  449.     n = n + 1: TestData(n) = "001111111110111111101011111100111110111011110110111110101011110111100110111111000111111110010111110011101110101101110010" ' seed 001
  450.     n = n + 1: TestData(n) = "010111111111011111101101111101011110111011110101011111100111111110010111110111001110111110001111110100111110101101110100" ' seed 010
  451.     n = n + 1: TestData(n) = "011111101111111110101111110011111110110111110111011110111001110111010110111101001111101010111110010111100110111011010110" ' seed 011
  452.     n = n + 1: TestData(n) = "100000010000000001010000001100000001001000001000100001000110001000101001000010110000010101000001101000011001000100101001" ' seed 100
  453.     n = n + 1: TestData(n) = "101000000000100000010010000010100001000100001010100000011000000001101000001000110001000001110000001011000001010010001011" ' seed 101
  454.  
  455.     LoadTestData = n
  456.  
  457. ''''''''''
  458. ' Code for creating pathological strings:
  459. 'Dim x$
  460. 'Dim q
  461. 'x$ = "101"
  462. 'Print x$;
  463. 'Do
  464. '    Cls
  465. '    Locate 1, 1
  466. '    q = Analyze(x$, 0)
  467. '    If (q = 1) Then
  468. '        x$ = x$ + "0"
  469. '    Else
  470. '        x$ = x$ + "1"
  471. '    End If
  472. '    Print x$
  473. '    _Display
  474. '    _Delay .015
  475. '    _Limit 120
  476. 'Loop Until Len(x$) = 120
  477. 'Open "nnn.txt" For Output As #1
  478. 'Print #1, x$
  479. 'Close #1
  480. ''''''''''
Title: Re: Looking for old program or help recreating it
Post by: random1 on December 15, 2021, 11:05:15 pm
STxAxTIC

I haven't tested but one string in this manner but the 1 to 0 prediction ratio is 1 in 17.52.
The predictor predicted (0) 473 times vs only 27 (1's) in a string of 500 entries. 

I then looked at the full string of 1422 entries and it shows the overall counts are 916 zeros
vs 506 ones.  This gives us a ratio of 1 in 2.81 for the full string. 

The full string shows (0) makes up 64.4% of the data while (1) makes up 35.5%.  Next I will
test the number predicted (1) guesses to see how many of those were correct.

We might need to step back and reevaluate a few things.

R1

 
     
Title: Re: Looking for old program or help recreating it
Post by: STxAxTIC on December 15, 2021, 11:14:31 pm
Deep breath r1,

The eval core hasn't changed in quite a while, and when it does, all of my metrics improve. Can you paste in a string you find "interesting" so I can do my own analysis?
Title: Re: Looking for old program or help recreating it
Post by: random1 on December 16, 2021, 07:26:13 am
STxAxTIC

Here is the string I am using, it's a update of a earlier posted string. Difficultly rating = 7
 
00101000111101101011000010000100001100110110100001100001100000000010011001000101000010001000000111011100000100000000010111010110000000010001110010110111000001011010111100101101010000011101110011010000110010011101011111000001000011001000000010011110011000000010101010011100100000010100010010111100100100100001000010011001101101001101110100011001100000010100000010001000010110100010100011000010001010101011110000000000110000011001000000100001110000100100010000001110000010100000101010100010001101000010

I can provide the full length strings if needed, I will place them in a .bas file so word wrap is not a problem, let me know.

I added counters to show the counts for the number of 0's and the number of 1's the predictor makes.
I also counted the number of correct guesses for each.

Results
The predictor predicted a zero 473 times, of those it correctly predicted a (0) 299 times for  63.2%
The predictor predicted a one 27 times, of those it correctly predicted a (1) 13 times for 48.%1

My concerns center on the total number of 1's the predictor makes.  Some strings tested have a
greater number of 1's with hit rates running in the mid 40's. 

My primal thoughts on this is that maybe a small weight could be added to the ones column but this
might produce unwanted results.  I have a control panel that would allow me to tinker with weight
values, don't know if this would help or not. In past attempts I was able to tweak the results for
the better but not enough to make any real progress.  Like to know your thoughts.
 

R1
Title: Re: Looking for old program or help recreating it
Post by: STxAxTIC on December 16, 2021, 01:32:14 pm
Morning R1,

That string looks fine, I'll fix up some comments on it later.

(edit: deleted some crap i decided wasnt true)



Alright, so you raise another point about tweaking the model. This part is subtle, and is frankly the only "human decision" made throughout this entire code. Here's the heart:

Code: QB64: [Select]
  1.     For k = UBound(Partialguess) To LBound(Partialguess) Step -1
  2.         If (Partialguess(k, 1) <> -999) Then
  3.  
  4.             ' This is the made-up part of the model:
  5.             ' The variable r contributes to weighted average.
  6.             ' The variable j is used for normalization.
  7.             ' Scaling factor h influences weighted average calculaton.
  8.             ' The factors multiplying h are totally arbitrary. Notes:
  9.             '   setting o(h^2) means the later alphabets count for more.
  10.             '   Partialguess(k, 1) euqals the calculated guess at frequency k.
  11.             '   Partialguess(k, 2) euqals the peak count of the unscaled histogram.
  12.             '   ...while Partialguess(k, 2) is here, it does not seem to help calculations.
  13.  
  14.             h = 1 + k - LBound(Partialguess)
  15.  
  16.             h = h ^ 2
  17.  
  18.             ' Standard weighted average:
  19.             r = r + h * Partialguess(k, 1)
  20.             j = j + h
  21.  
  22.         End If
  23.     Next
  24.     If (j <> 0) Then
  25.         r = r / j
  26.     End If
  27.  

All you need to pay attention to is the variable h. Right now, the model is set so that h is proportional to the library size we're using, and then I let h -> h^2 so that later, longer guesses count for more. If you want all partial guesses to count the same, let h=1. If you want early guesses to count for more, let h -> sqr(h) or something. I haven't changed this part in quite some time, so beware what you get! (There are probably even better models waiting to be discovered right here but I haven't really needed to yet...)



OH and I almost forgot. Want better accuracy? uncomment alphabets 11,12, and 13. It will look for deeper patterns in trade for a little speed.

Title: Re: Looking for old program or help recreating it
Post by: random1 on December 16, 2021, 09:02:46 pm
STxAxTIC

Un-commenting the alphabets should not present a speed issue on my end.  My mention of the
added weight is to introduce a user defined static value just before the final prediction is made.
Like I said I have a control panel already set up for this sort a thing.  However I would like to
wait until we think the predictor is fully developed before coding the CP into the main program. 
When the predictor is fully developed then it will run in sort of a silent mode so to say with just
a process bar to indicate the overall progress.  I will add the print switch to all the printed stuff
so that it can be blocked when it's no longer needed.

Attached is a picture of the predictors front end showing process bars,  Red is data gathering,
Green = formatting, blue = predictor process, larger pink bar to the right indicates overall
progress.  Picture shows a 10 string run.

Second picture shows the yet unfinished config menu.  This writes any user settings to a .ini file
which is then read just before the predictor is ran. 

R1       

Title: Re: Looking for old program or help recreating it
Post by: STxAxTIC on December 17, 2021, 05:15:34 am
Hey R1,

You mentioned plenty in the above, but I wanted to expound on this part a little:

Quote
My mention of the added weight is to introduce a user defined static value just before the final prediction is made. Like I said I have a control panel already set up for this sort a thing.

Throughout using this program, it occurred to me that my variable "h" explained above does not need to be a single value, but can be an array h() with one "weight" per value, much like you're talking about. The novel idea comes next: This array h() can actually be "trained" by the machine itself using whatever input strings we want, kindof exactly like a real AI project. So far all my code does is a big dumb deterministic calculation, but imagine if it tweaked its own model in order to maximize performance on the full suite of test strings? It's not even that difficult, the way I set things up.

I can't get to work on that yet though, because off to the side I'm trying to document all the progress we've made so far. This code doesn't speak well enough for itself, and certainly doesn't defend itself against... ahem... attacks... so I'm drafting a fake article on this as we speak. This will explain why I'm going to stop using the forum as a dev blog, too, haha.

Keep me posted with your updates, I like the screenshots too!
Title: Re: Looking for old program or help recreating it
Post by: random1 on December 17, 2021, 04:04:35 pm
STxAxTIC

I understand and agree.  If even what we have already discussed could be successfully implemented
then it might become very lucrative tool, don't blame you for going undercover so to say.   Please
stay in touch via private message if you have anything more to share.  As I've said I have been
working on this for years using different approaches but find my lack of skill in converting certain
math's into working code a problem.  As you probability already know, most mathematicians kind
of roll their eyes at something like this, some, not all.   

Many thanks for everything.

R1.

P.S.
My program makes a bunch of statistical calculations before the strings are ever presented to the
predictor.  I have not  implemented any of them yet as I need to first streamline your code so
that it integrates perfectly with the main program code.  I will add several controls to the config
menu like the string length, number of calls, weights, threshold, trigger etc... 

Again thanks for your post.             
Title: Re: Looking for old program or help recreating it
Post by: STxAxTIC on December 17, 2021, 04:16:24 pm
Ah hey R1!

So maybe I wasn't a thousand percent clear in my post above - I'm not really going underground with this work as much as I'm getting out of everyone's hair with it. Since the whole idea here isn't so obvious, it deserves a proper explanation rather than just code and forum posts... So that means I'm putting the work elsewhere, namely here:

http://barnes.x10host.com/pages/Binary-Analyzer.php (http://barnes.x10host.com/pages/Binary-Analyzer.php)

It's barely a third of the way done as I sit here now, but within the next few days it should be fully drafted. I do this in notepad without spell check cause I'm a madlad, so this page is subject to corrections. Anyway, the full story is now going there ^
Title: Re: Looking for old program or help recreating it
Post by: random1 on December 17, 2021, 07:36:36 pm
STxAxTIC

The information in the link has already filled in several blanks I had in understanding your
code, stupid me.  I should be able to adapt it now so that it fits seamlessly into my existing
code.     

Big thumbs up on the link and I look forward to the finished project.  Maybe were on the same
page now.  I admit I've been a bit cryptic in my postings.         

Thanks 

R1 
Title: Re: Looking for old program or help recreating it
Post by: STxAxTIC on December 17, 2021, 11:01:56 pm
Hey R1 -

I just wanted to let you know of yet another discovery that I made that speeds everything up by ... lemme think... O(len(S)), where S is the input sequence. Anyway, I finally got around to testing whether my full-blown "phase analysis" - which was necessary for projects similar to this one - was necessary for this problem. Turns out everything improves yet again if I leave the phase stuff out of my solution. What's this mean for the code? The array inside the Analyze function called Fingerprint can be completely commented out. TheString is just "The String" now. No need to create close copies. I'm going to leave that code in anyway (related problems need it to stay, details on request). The real speed change happens because of:

Code: QB64: [Select]
  1. Sub CreateHisto (arrfinger() As String, arralpha() As LetterBin, w As Integer)
  2.     Dim As Integer j, k, n
  3.     For n = 1 To UBound(arralpha)
  4.         arralpha(n).Count = 0
  5.     Next
  6.     'For j = 1 To w
  7.     j = 1
  8.     For k = 1 To Len(arrfinger(j)) - (Len(arrfinger(j)) Mod w) Step w
  9.         For n = 1 To UBound(arralpha)
  10.             If (Mid$(arrfinger(j), k, w) = arralpha(n).Signature) Then
  11.                 arralpha(n).Count = arralpha(n).Count + 1
  12.             End If
  13.         Next
  14.     Next
  15.     'Next
  16.     Call QuickSort(arralpha(), 1, UBound(arralpha))

See the entire FOR loop commented out? Good news. This all means j=1 for the whole sub, and the "fingerprint" array arrfinger() is really just a constant, just the working string. Doing this move improved every result by a little bit, and the whole thing runs faster. It's rare to find a win-win this late into the project!

I only found this because my write-up demanded that I talk about it. Since I don't want to delete a whole chapter, it's just "optional" now. I know you have the link, but for completeness:

http://barnes.x10host.com/pages/Binary-Analyzer.php (http://barnes.x10host.com/pages/Binary-Analyzer.php)

... And of course, the full code as of now:

Code: QB64: [Select]
  1.  
  2. Screen _NewImage(120, 40)
  3.  
  4. ' Version: 15
  5.  
  6. Type LetterBin
  7.     Signature As String
  8.     Count As Integer
  9.  
  10. Dim Shared Alphabet1(2) As LetterBin ' 0 1
  11. Dim Shared Alphabet2(4) As LetterBin ' 00 01 10 11
  12. Dim Shared Alphabet3(8) As LetterBin ' 000 001 010 011 100 101 110 111
  13. Dim Shared Alphabet4(16) As LetterBin ' etc.
  14. Dim Shared Alphabet5(32) As LetterBin
  15. Dim Shared Alphabet6(64) As LetterBin
  16. Dim Shared Alphabet7(128) As LetterBin
  17. Dim Shared Alphabet8(256) As LetterBin
  18. Dim Shared Alphabet9(512) As LetterBin
  19. Dim Shared Alphabet10(1024) As LetterBin
  20. Dim Shared Alphabet11(2048) As LetterBin
  21. Dim Shared Alphabet12(4096) As LetterBin
  22. Dim Shared Alphabet13(8192) As LetterBin
  23.  
  24. Alphabet1(1).Signature = "0"
  25. Alphabet1(2).Signature = "1"
  26. Call NewAlphabet(Alphabet1(), Alphabet2())
  27. Call NewAlphabet(Alphabet2(), Alphabet3())
  28. Call NewAlphabet(Alphabet3(), Alphabet4())
  29. Call NewAlphabet(Alphabet4(), Alphabet5())
  30. Call NewAlphabet(Alphabet5(), Alphabet6())
  31. Call NewAlphabet(Alphabet6(), Alphabet7())
  32. Call NewAlphabet(Alphabet7(), Alphabet8())
  33. Call NewAlphabet(Alphabet8(), Alphabet9())
  34. Call NewAlphabet(Alphabet9(), Alphabet10())
  35. Call NewAlphabet(Alphabet10(), Alphabet11())
  36. Call NewAlphabet(Alphabet11(), Alphabet12())
  37. Call NewAlphabet(Alphabet12(), Alphabet13())
  38.  
  39. '''
  40.  
  41. ReDim Shared TestData(1000) As String
  42. ReDim _Preserve TestData(LoadTestData(0))
  43.  
  44. Dim TheString As String
  45.  
  46. Dim As Integer j, k, n
  47. Dim GuessPredicted As Integer
  48. Dim GuessesCorrect As Double
  49. Dim GuessesTotal As Double
  50. Dim GuessStreak As Integer
  51. Dim GuessStreakBest As Integer
  52.  
  53. Dim ProgressGraph(1 To _Width, 2) As Double
  54.  
  55.  
  56.  
  57.  
  58. ''''''''''''
  59. ''' Code for creating pathological strings:
  60. 'Dim x$
  61. 'Dim q
  62. 'x$ = "1"
  63. 'Print x$;
  64. 'Do
  65. '    Cls
  66. '    Locate 1, 1
  67. '    q = Analyze(x$, 0)
  68. '    If (q = 1) Then
  69. '        x$ = x$ + "0"
  70. '    Else
  71. '        x$ = x$ + "1"
  72. '    End If
  73. '    Print x$
  74. '    _Display
  75. '    _Delay .015
  76. '    _Limit 120
  77. 'Loop Until Len(x$) = 4000
  78. 'Open "nnn.txt" For Output As #1
  79. 'Print #1, x$
  80. 'Close #1
  81. '''''''''''
  82.  
  83. For n = 1 To UBound(TestData)
  84.  
  85.     TheString = TestData(n)
  86.     GuessesCorrect = 0
  87.     GuessesTotal = 0
  88.     GuessStreak = 0
  89.     GuessStreakBest = 0
  90.  
  91.     '''
  92.     'TheString = ""
  93.     'Randomize Timer
  94.     'For k = 1 To 300
  95.     '    If (Rnd > .5) Then TheString = TheString + "1" Else TheString = TheString + "0"
  96.     'Next
  97.  
  98.     'TheString = "111000111000111000111000"
  99.  
  100.     '''
  101.     'Cls: Locate 1, 1
  102.     'Input "", TheString
  103.     '''
  104.  
  105.     For j = 1 To Len(TheString)
  106.  
  107.         Cls
  108.         Locate 1, 1
  109.         For k = 1 To _Width
  110.             Print "_";
  111.         Next
  112.         Print
  113.         Print "Analyzing: (test # "; _Trim$(Str$(n)); ", length "; _Trim$(Str$(Len(TheString))); ")"
  114.         Print
  115.         Color 7
  116.         Print Left$(TheString, j);
  117.         Color 8
  118.         Print "["; Right$(TheString, Len(TheString) - j); "]"
  119.         Color 7
  120.         Print
  121.  
  122.         ' Main prediction call
  123.         GuessPredicted = Analyze(Left$(TheString, j), 0)
  124.  
  125.         ' Reconciliation
  126.         Print "Prediction: "; _Trim$(Str$(GuessPredicted))
  127.         If (j < Len(TheString)) Then
  128.             Print "Actual:     "; _Trim$(Mid$(TheString, j + 1, 1))
  129.             If (GuessPredicted = Val(Mid$(TheString, j + 1, 1))) Then
  130.                 GuessesCorrect = GuessesCorrect + 1
  131.                 GuessStreak = GuessStreak + 1
  132.                 If (GuessStreak > GuessStreakBest) Then GuessStreakBest = GuessStreak
  133.                 Print "I am RIGHT this round."
  134.             Else
  135.                 GuessStreak = 0
  136.                 Print "I am WRONG this round."
  137.             End If
  138.             GuessesTotal = GuessesTotal + 1
  139.         Else
  140.             Print "Actual:     ?"
  141.         End If
  142.         Print
  143.         Print "I'm on a "; _Trim$(Str$(GuessStreak)); "-round winning streak."
  144.         Print "My best streak has been "; _Trim$(Str$(GuessStreakBest)); "."
  145.         Print "My correctness rate is "; _Trim$(Str$(Int(100 * GuessesCorrect / GuessesTotal))); "% in "; _Trim$(Str$(GuessesTotal)); " guesses."
  146.  
  147.         ' Draw bottom graph
  148.         If (CsrLin <= 23) Then
  149.             For k = 1 To _Width
  150.                 Locate _Height - 5, k: Print "_"
  151.                 Locate _Height - 5 - 10, k: Print "_"
  152.             Next
  153.             Locate _Height - 5 + 1, 1: Print "0%"
  154.             Locate _Height - 5 - 10 - 1, 1: Print "100%"
  155.             f = (_Width - 1) / Int(Len(TheString))
  156.             If (f > 1) Then f = 1 / f
  157.             ProgressGraph(1 + Int(j * f), 1) = GuessesCorrect / GuessesTotal
  158.             If (GuessStreak = 0) Then
  159.                 ProgressGraph(1 + Int(j * f), 2) = 120
  160.             Else
  161.                 ProgressGraph(1 + Int(j * f), 2) = 251
  162.             End If
  163.             g = (_Width - 0) / Int(Len(TheString))
  164.             If (g > 1) Then g = 1
  165.             For k = 1 To Int(j * g)
  166.                 Locate _Height - 5 - Int(10 * ProgressGraph(1 + Int(k * f), 1)), k: Print Chr$(ProgressGraph(1 + Int(k * f), 2))
  167.             Next
  168.         End If
  169.  
  170.         _Delay .015
  171.         _Display
  172.     Next
  173.  
  174.  
  175.     _Delay 1
  176.  
  177.  
  178.  
  179. Function Analyze (TheStringIn As String, pswitch As Integer)
  180.     Dim TheReturn As Integer
  181.     Dim As Integer n
  182.     Dim As Double r, j, k, h
  183.     Dim Fingerprint(16) As String
  184.     Dim Partialguess(1 To 10, 2) As Double ' Change the upper bound to a higer number for more accuracy.
  185.  
  186.     ' Create shifted versions of string, i.e. ABCD -> BCDA, CDAB, DABC, ABCD, BCDA, etc.
  187.     Fingerprint(1) = TheStringIn
  188.     For n = 2 To UBound(Fingerprint)
  189.         Fingerprint(n) = Right$(Fingerprint(n - 1), Len(Fingerprint(n - 1)) - 1) + Left$(Fingerprint(n - 1), 1)
  190.     Next
  191.  
  192.     ' Initialize partial results.
  193.     For n = LBound(Partialguess) To UBound(Partialguess)
  194.         Partialguess(n, 1) = -999
  195.     Next
  196.  
  197.     Call CreateHisto(Fingerprint(), Alphabet1(), 1)
  198.     Call CreateHisto(Fingerprint(), Alphabet2(), 2)
  199.     Call CreateHisto(Fingerprint(), Alphabet3(), 3)
  200.     Call CreateHisto(Fingerprint(), Alphabet4(), 4)
  201.     Call CreateHisto(Fingerprint(), Alphabet5(), 5)
  202.     Call CreateHisto(Fingerprint(), Alphabet6(), 6)
  203.     Call CreateHisto(Fingerprint(), Alphabet7(), 7)
  204.     Call CreateHisto(Fingerprint(), Alphabet8(), 8)
  205.     Call CreateHisto(Fingerprint(), Alphabet9(), 9)
  206.     Call CreateHisto(Fingerprint(), Alphabet10(), 10)
  207.     'Call CreateHisto(Fingerprint(), Alphabet11(), 11)
  208.     'Call CreateHisto(Fingerprint(), Alphabet12(), 12)
  209.     'Call CreateHisto(Fingerprint(), Alphabet13(), 13)
  210.  
  211.     If (pswitch = 1) Then
  212.         For n = 1 To _Width
  213.             Print "-";
  214.         Next
  215.         Print
  216.     End If
  217.  
  218.     If (pswitch = 1) Then ' Set the last number >=1 to print stats for that histogram.
  219.         If (Len(TheStringIn) >= 1) Then Call PrintHisto(Alphabet1(), 2)
  220.         If (Len(TheStringIn) >= 2) Then Call PrintHisto(Alphabet2(), 4)
  221.         If (Len(TheStringIn) >= 3) Then Call PrintHisto(Alphabet3(), 4)
  222.         If (Len(TheStringIn) >= 4) Then Call PrintHisto(Alphabet4(), 0)
  223.         If (Len(TheStringIn) >= 5) Then Call PrintHisto(Alphabet5(), 0)
  224.         If (Len(TheStringIn) >= 6) Then Call PrintHisto(Alphabet6(), 0)
  225.         If (Len(TheStringIn) >= 7) Then Call PrintHisto(Alphabet7(), 0)
  226.         If (Len(TheStringIn) >= 8) Then Call PrintHisto(Alphabet8(), 0)
  227.         If (Len(TheStringIn) >= 9) Then Call PrintHisto(Alphabet9(), 0)
  228.         If (Len(TheStringIn) >= 10) Then Call PrintHisto(Alphabet10(), 0)
  229.         'If (Len(TheStringIn) >= 11) Then Call PrintHisto(Alphabet11(), 0)
  230.         'If (Len(TheStringIn) >= 12) Then Call PrintHisto(Alphabet12(), 0)
  231.         'If (Len(TheStringIn) >= 13) Then Call PrintHisto(Alphabet13(), 0)
  232.         Print
  233.     End If
  234.  
  235.     If (Len(TheStringIn) >= 1) Then Call MakeGuess(TheStringIn, Alphabet1(), 1, Partialguess(), 0) ' Set the last number =1 to print guess for that histogram.
  236.     If (Len(TheStringIn) >= 2) Then Call MakeGuess(TheStringIn, Alphabet2(), 2, Partialguess(), pswitch)
  237.     If (Len(TheStringIn) >= 3) Then Call MakeGuess(TheStringIn, Alphabet3(), 3, Partialguess(), pswitch)
  238.     If (Len(TheStringIn) >= 4) Then Call MakeGuess(TheStringIn, Alphabet4(), 4, Partialguess(), 0)
  239.     If (Len(TheStringIn) >= 5) Then Call MakeGuess(TheStringIn, Alphabet5(), 5, Partialguess(), 0)
  240.     If (Len(TheStringIn) >= 6) Then Call MakeGuess(TheStringIn, Alphabet6(), 6, Partialguess(), 0)
  241.     If (Len(TheStringIn) >= 7) Then Call MakeGuess(TheStringIn, Alphabet7(), 7, Partialguess(), 0)
  242.     If (Len(TheStringIn) >= 8) Then Call MakeGuess(TheStringIn, Alphabet8(), 8, Partialguess(), 0)
  243.     If (Len(TheStringIn) >= 9) Then Call MakeGuess(TheStringIn, Alphabet9(), 9, Partialguess(), 0)
  244.     If (Len(TheStringIn) >= 10) Then Call MakeGuess(TheStringIn, Alphabet10(), 10, Partialguess(), 0)
  245.     'If (Len(TheStringIn) >= 11) Then Call MakeGuess(TheStringIn, Alphabet11(), 11, Partialguess(), 0)
  246.     'If (Len(TheStringIn) >= 12) Then Call MakeGuess(TheStringIn, Alphabet12(), 12, Partialguess(), 0)
  247.     'If (Len(TheStringIn) >= 13) Then Call MakeGuess(TheStringIn, Alphabet13(), 13, Partialguess(), 0)
  248.     If (pswitch = 1) Then Print
  249.  
  250.     If (pswitch = 1) Then
  251.         Print "Thinking:";
  252.         For k = LBound(Partialguess) To UBound(Partialguess)
  253.             If (Partialguess(k, 1) <> -999) Then
  254.                 Print Partialguess(k, 1);
  255.             Else
  256.                 Print "_ ";
  257.             End If
  258.         Next
  259.         Print
  260.     End If
  261.  
  262.     j = 0
  263.     r = 0
  264.  
  265.     For k = UBound(Partialguess) To LBound(Partialguess) Step -1
  266.         If (Partialguess(k, 1) <> -999) Then
  267.  
  268.             ' This is the made-up part of the model:
  269.             ' The variable r contributes to weighted average.
  270.             ' The variable j is used for normalization.
  271.             ' Scaling factor h influences weighted average calculaton.
  272.             ' The factors multiplying h are totally arbitrary. Notes:
  273.             '   setting o(h^2) means the later alphabets count for more.
  274.             '   Partialguess(k, 1) euqals the calculated guess at frequency k.
  275.             '   Partialguess(k, 2) euqals the peak count of the unscaled histogram.
  276.             '   ...while Partialguess(k, 2) is here, it does not seem to help calculations.
  277.  
  278.             h = 1 + k - LBound(Partialguess)
  279.  
  280.             h = h ^ 2
  281.  
  282.             ' Standard weighted average:
  283.             r = r + h * Partialguess(k, 1)
  284.             j = j + h
  285.  
  286.         End If
  287.     Next
  288.     If (j <> 0) Then
  289.         r = r / j
  290.     End If
  291.  
  292.     If (pswitch = 1) Then Print "Predicting:  "; _Trim$(Str$(r))
  293.  
  294.     If (r > .5) Then
  295.         r = 1
  296.     Else
  297.         r = 0
  298.     End If
  299.  
  300.     If (pswitch = 1) Then
  301.         Print "Rounding to: "; _Trim$(Str$(r))
  302.     End If
  303.  
  304.     If (pswitch = 1) Then
  305.         For n = 1 To _Width
  306.             Print "-";
  307.         Next
  308.         Print: Print
  309.     End If
  310.  
  311.     TheReturn = r
  312.     Analyze = TheReturn
  313.  
  314. Sub MakeGuess (TheStringIn As String, arralpha() As LetterBin, wid As Integer, arrbeta() As Double, pswitch As Integer)
  315.     Dim TheReturn As Double
  316.     Dim As Integer j, k, n
  317.     TheReturn = 0
  318.     j = 1
  319.     k = 0
  320.     For n = 1 To UBound(arralpha)
  321.         If (Left$(arralpha(n).Signature, wid - 1) = Right$(TheStringIn, wid - 1)) Then
  322.             If (arralpha(n).Count >= j) Then
  323.                 If (pswitch = 1) Then Print "Order-"; Right$("0" + _Trim$(Str$(wid)), 2); " guess: "; arralpha(n).Signature; " . "; _Trim$(Str$(arralpha(n).Count))
  324.                 TheReturn = TheReturn + Val(Right$(arralpha(n).Signature, 1))
  325.                 k = k + 1
  326.                 j = arralpha(n).Count
  327.             End If
  328.         End If
  329.     Next
  330.     If (k <> 0) Then
  331.         TheReturn = TheReturn / k
  332.     Else
  333.         TheReturn = .5
  334.     End If
  335.     arrbeta(wid, 1) = TheReturn
  336.     arrbeta(wid, 2) = j
  337.  
  338. Sub CreateHisto (arrfinger() As String, arralpha() As LetterBin, w As Integer)
  339.     Dim As Integer j, k, n
  340.     For n = 1 To UBound(arralpha)
  341.         arralpha(n).Count = 0
  342.     Next
  343.     'For j = 1 To w
  344.     j = 1
  345.     For k = 1 To Len(arrfinger(j)) - (Len(arrfinger(j)) Mod w) Step w
  346.         For n = 1 To UBound(arralpha)
  347.             If (Mid$(arrfinger(j), k, w) = arralpha(n).Signature) Then
  348.                 arralpha(n).Count = arralpha(n).Count + 1
  349.             End If
  350.         Next
  351.     Next
  352.     'Next
  353.     Call QuickSort(arralpha(), 1, UBound(arralpha))
  354.  
  355. Sub PrintHisto (arr() As LetterBin, w As Integer)
  356.     Dim As Integer j, n
  357.     If (w > 0) Then
  358.         If (w > UBound(arr)) Then
  359.             j = UBound(arr)
  360.         Else
  361.             j = w
  362.         End If
  363.         Print "Histogram: "; _Trim$(Str$(UBound(arr))); "-letter regroup, showing top "; _Trim$(Str$(w))
  364.         For n = 1 To j
  365.             Print arr(n).Signature; arr(n).Count
  366.         Next
  367.     End If
  368.  
  369. Sub NewAlphabet (arrold() As LetterBin, arrnew() As LetterBin)
  370.     Dim As Integer j, k, n
  371.     n = 0
  372.     For k = 1 To 2
  373.         For j = 1 To UBound(arrold)
  374.             n = n + 1
  375.             arrnew(n).Signature = arrold(j).Signature
  376.         Next
  377.     Next
  378.     For j = 1 To UBound(arrnew)
  379.         If (j <= UBound(arrnew) / 2) Then
  380.             arrnew(j).Signature = "0" + arrnew(j).Signature
  381.         Else
  382.             arrnew(j).Signature = "1" + arrnew(j).Signature
  383.         End If
  384.     Next
  385.  
  386. Sub QuickSort (arr() As LetterBin, LowLimit As Long, HighLimit As Long)
  387.     Dim As Long piv
  388.     If (LowLimit < HighLimit) Then
  389.         piv = Partition(arr(), LowLimit, HighLimit)
  390.         Call QuickSort(arr(), LowLimit, piv - 1)
  391.         Call QuickSort(arr(), piv + 1, HighLimit)
  392.     End If
  393.  
  394. Function Partition (arr() As LetterBin, LowLimit As Long, HighLimit As Long)
  395.     Dim As Long i, j
  396.     Dim As Double pivot, tmp
  397.     pivot = arr(HighLimit).Count
  398.     i = LowLimit - 1
  399.     For j = LowLimit To HighLimit - 1
  400.         tmp = arr(j).Count - pivot
  401.         If (tmp >= 0) Then
  402.             i = i + 1
  403.             Swap arr(i), arr(j)
  404.         End If
  405.     Next
  406.     Swap arr(i + 1), arr(HighLimit)
  407.     Partition = i + 1
  408.  
  409. Function LoadTestData (alwayszero As Integer)
  410.     Dim n As Integer
  411.     n = alwayszero
  412.     '''
  413.     ' Systematic cases:
  414.     '''
  415.     n = n + 1: TestData(n) = "1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111"
  416.     n = n + 1: TestData(n) = "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
  417.     n = n + 1: TestData(n) = "0101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101"
  418.     n = n + 1: TestData(n) = "1010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010"
  419.     n = n + 1: TestData(n) = "0010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010"
  420.     n = n + 1: TestData(n) = "0100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100"
  421.     n = n + 1: TestData(n) = "1001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001"
  422.     n = n + 1: TestData(n) = "1101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101101"
  423.     n = n + 1: TestData(n) = "1011011011011011011011011011011011011011011011011011011011011011011011011011011011011011011011011011011011011011011011011011011011011011011011011011011011011011"
  424.     n = n + 1: TestData(n) = "0110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110"
  425.     '
  426.     '''
  427.     ' Community hand-typed cases:
  428.     '''
  429.     ' (from Cobalt) (Results in: 48%  -  Claims he made this data hand but behavior in Discord raises doubt.)
  430.     n = n + 1: TestData(n) = "1010001101110110000000011100110100101010111110101001100101110100000111101011011000010101101100000110010010010101010110111111111001000100101011101000011110011000000100111100001100111000111100100000000111010011010011001111101000010011101111000011100011010110101101000111101111100101100100000101111011001101100000111011000001001111000110000001110101100101"
  431.     ' (from Keybone) (Results in: 82%)
  432.     n = n + 1: TestData(n) = "101010101010101010101001010101010101001010111001010101010101010101010100010101010101010100101001010101001100101010001010100101010100101010100101010101010101010011011110010101010100100101010110010011001010011001010100010100101010010101010101010010101010101010010101001010101010100110010101010100101010101010011001001010100101010010101010100101010010101001010100101001010010101010111010100110011001010101010100110101001010101010100101001010111010101010101010100101001010101010010101010101001010101001010101001010100101010100101010010101010101001010101001010101010101001010101001010100101010101010010101010010010101010101010101010010100101010101001010100101001010101001111101010101010100101010110011001010101010101010110101010101101010101010100101010010101010010101010101101110010101001010101010110010100101010101001011010101010100110101010100101010010101010100101010101001010101010101001010101010011010101010101110110100101010111010101011011001011001010101001010101010101010101010011001010101010100101010101010101010010100101"
  433.     ' (from Keybone) (Results in: 54%)
  434.     n = n + 1: TestData(n) = "0101110101100011010100101011001110001011001010001110101111010100111011100100101001010011110101101000101010001010101111001010111010101010100001010101000101101100101111101010010101110110111001000101000011010101010001001001001111101011101010100010110101110101100000101010101110111010100100100001110111100101011110101010001010001110010110111110110010101001001011101000101001011100011101000010101010101101010010110100101101000101111010101110111001010011101111010101000010101111100010101011110101011011110100001010110"
  435.     ' (from Loudar) (Results in: 71%)
  436.     n = n + 1: TestData(n) = "1011001010010100100100110010101010101001010101010101011010010101001010101001010010100110101011010101010101011010101101010101010101010010110101010101100101010101010110101101011010010101010010100110101101001010110101011010010101101010110100101111010101010011011011010010110101010010110100101101010100101011010010101001010101010001011101011010010101011100111010010001101011110010011010001011100110101010010011010101001001010010000101010110001"
  437.     ' (from Luke) (Results in: 51%  -  I have long suspected Luke to be a computer. The numbers are now in.)
  438.     n = n + 1: TestData(n) = "01100101001010001100001101101111011010010101010110110101001000001111001111110101000101111011010101111101010101101010101001010101011000010101010101001011010100110100110100110011010101010101110101010111111101011010100000001101111000010111000110111001000010100001101010110100000111101011111100001011001010110010110" ' Luke 50
  439.     ' (from Sarafromct) (Results in: 64%)
  440.     n = n + 1: TestData(n) = "10101010101011101000011101010111010101010101100111001010100111100001011011110101000001111010101101010000001111110011111110111101110111001110110010000100010101010101010100101011010110101010101010101001000000001111110000011110101010101010100010101110101010101101111111111111111111101010101010101000000" ' 63
  441.     ' (from Spriggs) (Results in: 85%)
  442.     n = n + 1: TestData(n) = "10111010101010101010101001010101010101001010101001010101010101010101010101010101010101010101010101010101001010100100100101010101010101001010100101010101010100101010100101010101010101010101001010010110010101010010101010101010101010101010100101001001001010101010101010101010101001010101001001101010010"
  443.     ' (from Spriggs) (Results in: 67%)
  444.     n = n + 1: TestData(n) = "11111011110100101011111111110100000011011110101100111100111111110111101110100111100110011111110101111111010111101111100111110111111111111011100111110111111110010000101011111001110101101010110111110"
  445.     ' (from Hotpants) (Results in: 62%)
  446.     n = n + 1: TestData(n) = "01010100011001010010101010101010101000110101010111101010100100011010101010100100101110010010010100001010101001010101010110010001001011000100100110101001001001010000000001010101101111101001010100010101001001010101000100101001100100010011010101010101010111010010101011101011011010110100100010010100100100010010001001" ' Tom
  447.     '
  448.     '''
  449.     ' Known-Random cases:
  450.     '''
  451.     ' (using RND) (Results in: 45%)
  452.     n = n + 1: TestData(n) = "11100101110011011010110100110011111011010110100100000110000100101001001010011100111101101110000001000000011011100101110000000111100100011101000000101000110100001000000001111010101011000010001110111110001001110101011000010101001111010100100000011100110110110000111010001010000011010000101111101011000"
  453.     ' (from Spriggs) (Results in: 52%)
  454.     n = n + 1: TestData(n) = "010101111010111100110000001001100100101100000101110001100101000010001001111101111111111100011110000011011110011000100011100100001101110011001001011001000011110010001000111100011100011110010110011110111010110100001000110000010000111000111011100110011010101111111100100010001111111100010100001011000011"
  455.     ' (Wolfrm rule 30, central column) (Results in: 47%)
  456.     n = n + 1: TestData(n) = "110111001100010110010011101011100111010101100001100101011010101111110000111100010101110000010010110001"
  457.     ' (using RND) (Results in: 46%)
  458.     n = n + 1: TestData(n) = "111001011100110110101101001100111110110101101001000001100001001010010010100111001111011011100000010000000110111001011100000001111001000111010000001010001101000010000000011110101010110000100011101111100010011101010110000101010011110101001000000111001101101100001110100010100000110100001011111010110000"
  459.     ' (using RND) (Results in: 46%)
  460.     n = n + 1: TestData(n) = "111001011100110110101101001100111110110101101001000001100001001010010010100111001111011011100000010000000110111001011100000001111001000111010000001010001101000010000000011110101010110000100011101111100010011101010110000101010011110101001000000111001101101100001110100010100000110100001011111010110000101110111110011100001000110010010001100111101000001101011000010101101011111010010001010010110110011000001001101000011100000011110001110011100010101010111101100100100001001000101101110110101100001111011101000100111110000001110000111011101000110110100111101101001100100110000111110111101001100010011110"
  461.     ' (using RND) (Results in: 45%)
  462.     n = n + 1: TestData(n) = "111001011100110110101101001100111110110101101001000001100001001010010010100111001111011011100000010000000110111001011100000001111001000111010000001010001101000010000000011110101010110000100011101111100010011101010110000101010011110101001000000111001101101100001110100010100000110100001011111010110000101110111110011100001000110010010001100111101000001101011000010101101011111010010001010010110110011000001001101000011100000011110001110011100010101010111101100100100001001000101101110110101100001111011101000100111110000001110000111011101000110110100111101101001100100110000111110111101001100010011110111001001100111000110011011000100101100010101010000010000111111010111111011100011100001000011000100100111001100001111010001010000001011100000101110000110010111110010101010110111110011100100001011101010000011011110110100010110111000100000110000001001010001011010000010001111110100100010011100011001000"
  463.     ' (using RND) (Results in: 48%)
  464.     n = n + 1: TestData(n) = "111001011100110110101101001100111110110101101001000001100001001010010010100111001111011011100000010000000110111001011100000001111001000111010000001010001101000010000000011110101010110000100011101111100010011101010110000101010011110101001000000111001101101100001110100010100000110100001011111010110000101110111110011100001000110010010001100111101000001101011000010101101011111010010001010010110110011000001001101000011100000011110001110011100010101010111101100100100001001000101101110110101100001111011101000100111110000001110000111011101000110110100111101101001100100110000111110111101001100010011110111001001100111000110011011000100101100010101010000010000111111010111111011100011100001000011000100100111001100001111010001010000001011100000101110000110010111110010101010110111110011100100001011101010000011011110110100010110111000100000110000001001010001011010000010001111110100100010011100011001000011101011010100110110000110010010011110111001001011111011000000100010011011100111110111011111101100011011101001111110100011010000111001001010111011101000001010010010100111010001001010101001000010011100111010101000110010110101111001110000010110110010101001000011000101000001100110100111101000110111101101010011011000101100101001010001100110101000101110000101100110010011010001010101010101101110101110110101100101001111100110110101011001000001100101001011000101100001001000001010111010100010100101011001111001011011100011001110010111011110010111101011101000100100010111010000001010011101010001110110110101011000101010100000001110110101011110101111100100101101000001011000101001110010010010000111001101010100101111101001110010001011000001001000111010001000011000111000000111001110111110011110110101100111011001100101101010101100010100100001010010110010000001100110010010100110011110110000001001000111001001010010000011111110011110010001100011100011010000111100111111010010001010011100100111100111101111110101000010011100011111100010000011111101101010010100000011011001110001100001011111100111000001110111011001111110011011100111000110110110011110000111000010011011000011001111111110010100000111110011111100100001100000000110001111101101011100011111011110001100100001100011100011111000000110011011100110101101001001111101101000000110101101001100011100011001110001000000111111100110101001110100010010010100000010100001010001011011001101010011111001101110110010101000111101100111000011000111001100011011011010100111111001100000100100110000100101001111111100110010111100000111101101001111001010011010011011100101001001001110101110001101010001111010101100101010111000111000011000001010010010101010100001110010001001001110110011100110011111001100111010011110100100110010000100011010001110000000100001100000010000111000111111000111100010001101011000101000010100011100011111000100010101000001001011001000101101111110111110110001101001001011100011110001101100010100101101011001001100111000000111111110110100010111111101000000001111000100001111111011000101001111110010000110101100010000011100110111101011011100110"
  465.     '
  466.     '''
  467.     ' Pathological cases:
  468.     '''
  469.     n = n + 1: TestData(n) = "011111101111111110101111110011111110110111110111011110111001110111010110111101001111101010111110010111100110111011010110" ' seed 0
  470.     n = n + 1: TestData(n) = "100000010000000001010000001100000001001000001000100001000110001000101001000010110000010101000001101000011001000100101001" ' seed 1
  471.     n = n + 1: TestData(n) = "001111111110111111101011111100111110111011110110111110101011110111100110111111000111111110010111110011101110101101110010" ' seed 00
  472.     n = n + 1: TestData(n) = "011111101111111110101111110011111110110111110111011110111001110111010110111101001111101010111110010111100110111011010110" ' seed 01
  473.     n = n + 1: TestData(n) = "100000010000000001010000001100000001001000001000100001000110001000101001000010110000010101000001101000011001000100101001" ' seed 10
  474.     n = n + 1: TestData(n) = "110000000001000000010100000011000001000100001001000001010100001000011001000000111000000001101000001100010001010010001101" ' seed 11
  475.     n = n + 1: TestData(n) = "000111111111011111101101111101011111110011111110101011101110110110101110011101111011101010011110110011111011110011011110" ' seed 000
  476.     n = n + 1: TestData(n) = "001111111110111111101011111100111110111011110110111110101011110111100110111111000111111110010111110011101110101101110010" ' seed 001
  477.     n = n + 1: TestData(n) = "010111111111011111101101111101011110111011110101011111100111111110010111110111001110111110001111110100111110101101110100" ' seed 010
  478.     n = n + 1: TestData(n) = "011111101111111110101111110011111110110111110111011110111001110111010110111101001111101010111110010111100110111011010110" ' seed 011
  479.     n = n + 1: TestData(n) = "100000010000000001010000001100000001001000001000100001000110001000101001000010110000010101000001101000011001000100101001" ' seed 100
  480.     n = n + 1: TestData(n) = "101000000000100000010010000010100001000100001010100000011000000001101000001000110001000001110000001011000001010010001011" ' seed 101
  481.  
  482.     LoadTestData = n
  483.  
  484.  
Title: Re: Looking for old program or help recreating it
Post by: STxAxTIC on December 19, 2021, 02:57:46 pm
Hey R1

So the draft is finally complete, I can't believe it. I just updated the site with my hurried, probably typo-ridden discourse taking the reader through this project. I took care to explain every step, with pictures. Its subject to little updates for typos and stuff, but for the model described and the numbers shouldn't change.

As per usual, it's here: http://barnes.x10host.com/pages/Binary-Analyzer.php (http://barnes.x10host.com/pages/Binary-Analyzer.php)

The BAS file at the top is the latest version of the code (and always will be, consider that page the home for this code).

Now.... with all that out of the way.... I changed my "h" variable into an array, so I can turn certain weights on or off manually instead of using a sweeping function. This hasn't been explored whatsoever yet, but the code is ready to go on that front. The challenge now becomes stepping through "weight space", which, ironically can be reduced to a bunch of 1 and 0 switches, which it itself a binary sequence - and we could feed this into the ....!... nevermind... So I'll call this a milestone and let it rest a while.

Now I may inhale.
Title: Re: Looking for old program or help recreating it
Post by: random1 on December 20, 2021, 01:29:55 am
STxAxTIC

I would like to see a fully stripped down version of the code, ie, string in / prediction
out, no print code or commented out stuff.  I use the full update as a stand-alone to
to check the edits I make in my embedded code,  If both outputs match then I figure
there's no mistakes.  If it's not too much to ask, it would be great to have a stripped
version along with full updates. 

Thanks for all the content and work on your end.  I can't weight, "pun intended," to work
with the new version.  Too many arms in the fire right now but soon as the holidays end
I will be able to dig in.

R1   

Title: Re: Looking for old program or help recreating it
Post by: STxAxTIC on December 20, 2021, 07:02:30 am
Morning r1,

So there is a short answer to your question, and that's my function Analyze(). It's a black box that receives a string and returns a number. I got rid of the commented-out lines, but it still takes a print switch argument can be ignored by setting to 0 forever.

Things got a little more complicated, too. I removed from Analyze() all of the human-influenced parts of the prediction model, and put this information in a shared array called AlphaWeight(). There is a good reason for this you may see coming. Anyway, a call to Analyze() looks like this:

Code: QB64: [Select]
  1.  GuessPredicted = Analyze(TheString, AlphaWeight(), 0)

If you want the absolute black-box nugget of code that makes this go, that's the line. You can delete everything enclosing that line and use it in isolation. Admittedly I could/should streamline this function in terms of the way it *looks*, but that's a style issue I'll figure out later. It's me skirting around the arrays-in-types problem, if you want the excuse.

The reason AlphaWeight() is it's own entity now is I've discovered two different prediction models that work for two different jobs. For the long, wacky test strings we've been doing, the full-frequency analysis works best. For human inputs though, for some reason, 5-grams work the best: turn off all weights except 5. This is pure sorcery though, no good reason to have made this realization.

My next job is to come up with a way to "walk through weight space" where I can apply calculus to focus in on the best models for given tasks. Kinda exciting really. Sounds like AI (a term I hate).

As a program note, there are now three downloads at the top of the website. I froze the "article" version of the code in time so that there's something executable to go with the website. The main code is moving on though. (It's all kept straight with a version number.)

Code: QB64: [Select]
  1.  
  2. Screen _NewImage(120, 40)
  3.  
  4. ' Version: 18
  5.  
  6. Type LetterBin
  7.     Signature As String
  8.     Count As Integer
  9.  
  10. Dim Shared Alphabet1(2) As LetterBin ' 0 1
  11. Dim Shared Alphabet2(4) As LetterBin ' 00 01 10 11
  12. Dim Shared Alphabet3(8) As LetterBin ' 000 001 010 011 100 101 110 111
  13. Dim Shared Alphabet4(16) As LetterBin ' etc.
  14. Dim Shared Alphabet5(32) As LetterBin
  15. Dim Shared Alphabet6(64) As LetterBin
  16. Dim Shared Alphabet7(128) As LetterBin
  17. Dim Shared Alphabet8(256) As LetterBin
  18. Dim Shared Alphabet9(512) As LetterBin
  19. Dim Shared Alphabet10(1024) As LetterBin
  20. Dim Shared Alphabet11(2048) As LetterBin
  21. Dim Shared Alphabet12(4096) As LetterBin
  22. Dim Shared Alphabet13(8192) As LetterBin
  23.  
  24. Alphabet1(1).Signature = "0"
  25. Alphabet1(2).Signature = "1"
  26. Call NewAlphabet(Alphabet1(), Alphabet2())
  27. Call NewAlphabet(Alphabet2(), Alphabet3())
  28. Call NewAlphabet(Alphabet3(), Alphabet4())
  29. Call NewAlphabet(Alphabet4(), Alphabet5())
  30. Call NewAlphabet(Alphabet5(), Alphabet6())
  31. Call NewAlphabet(Alphabet6(), Alphabet7())
  32. Call NewAlphabet(Alphabet7(), Alphabet8())
  33. Call NewAlphabet(Alphabet8(), Alphabet9())
  34. Call NewAlphabet(Alphabet9(), Alphabet10())
  35. Call NewAlphabet(Alphabet10(), Alphabet11())
  36. Call NewAlphabet(Alphabet11(), Alphabet12())
  37. Call NewAlphabet(Alphabet12(), Alphabet13())
  38.  
  39. ' Load test data.
  40. ReDim Shared TestData(10000) As String
  41. ReDim _Preserve TestData(LoadTestData(0))
  42.  
  43. ' This is the made-up part of the model.
  44. Dim Shared AlphaWeight(13) As Double
  45.  
  46. ' Statistics and metrics:
  47. Dim GuessPredicted As Integer
  48. Dim GuessesCorrect As Double
  49. Dim GuessesTotal As Double
  50. Dim GuessStreak As Integer
  51. Dim GuessStreakMax As Integer
  52. Dim Grade(10000, 2) As Double
  53.  
  54. Call InitializeModel
  55.  
  56. '''
  57. ' Bypass pre-cooked test data.
  58. 'TestData(1) = "1111111111111111111111"
  59. 'ReDim _Preserve TestData(1)
  60. '''
  61.  
  62. Dim TheString As String
  63. Dim As Integer k, m, n
  64.  
  65. For m = 1 To UBound(TestData)
  66.  
  67.     GuessPredicted = -1
  68.     GuessesCorrect = 0
  69.     GuessesTotal = 0
  70.     GuessStreak = 0
  71.     GuessStreakMax = 0
  72.  
  73.     For n = 1 To Len(TestData(m))
  74.  
  75.         '''
  76.         ' Research Mode
  77.         TheString = Left$(TestData(m), n)
  78.         '''
  79.  
  80.         '''
  81.         '' Gaming Mode
  82.         'Cls
  83.         'Locate 1, 1
  84.         'Print "Press LEFT or RIGHT."
  85.         'k = 0
  86.         'Do: k = _KeyHit: Loop Until ((k = 19200) Or (k = 19712))
  87.         'Select Case k
  88.         '    Case 19200
  89.         '        TheString = TheString + "0"
  90.         '    Case 19712
  91.         '        TheString = TheString + "1"
  92.         'End Select
  93.         '_KeyClear
  94.         '''
  95.  
  96.         Cls
  97.         Color 7
  98.         Locate 1, 1
  99.         For k = 1 To _Width
  100.             Print "_";
  101.         Next
  102.         Print "Model:";
  103.         For k = 1 To UBound(AlphaWeight)
  104.             Print AlphaWeight(k);
  105.         Next
  106.         Print
  107.         Print
  108.         Print "Sequence (length "; _Trim$(Str$(Len(TheString))); "):"
  109.         Print TheString;
  110.         Color 8
  111.         Print Right$(TestData(m), Len(TestData(m)) - n)
  112.         Color 7
  113.  
  114.         ' Reconciliation
  115.         If (GuessPredicted <> -1) Then
  116.             Print
  117.             Print
  118.             Print "I predicted "; _Trim$(Str$(GuessPredicted)); " and you typed "; Right$(TheString, 1); "."
  119.             If (GuessPredicted = Val(Right$(TheString, 1))) Then
  120.                 Print "I am RIGHT this round."
  121.                 GuessesCorrect = GuessesCorrect + 1
  122.                 GuessStreak = GuessStreak + 1
  123.                 If (GuessStreak > GuessStreakMax) Then GuessStreakMax = GuessStreak
  124.                 Grade(n, 2) = 1
  125.             Else
  126.                 Print "I am WRONG this round."
  127.                 GuessStreak = 0
  128.                 Grade(n, 2) = 0
  129.             End If
  130.             GuessesTotal = GuessesTotal + 1
  131.             Grade(n, 1) = GuessesCorrect / GuessesTotal
  132.         End If
  133.  
  134.         If (GuessesTotal > 0) Then
  135.             Print
  136.             Print "I'm on a "; _Trim$(Str$(GuessStreak)); "-round winning streak."
  137.             Print "My best streak has been "; _Trim$(Str$(GuessStreakMax)); "."
  138.             If (GuessesTotal <> 0) Then
  139.                 Print "My correctness rate is "; _Trim$(Str$(Int(100 * GuessesCorrect / GuessesTotal))); "% in "; _Trim$(Str$(GuessesTotal)); " guesses."
  140.             End If
  141.         End If
  142.  
  143.         GuessPredicted = Analyze(TheString, AlphaWeight(), 0)
  144.  
  145.         Print
  146.         Print "I have made a prediction."
  147.         Print "Press LEFT or RIGHT to test me."
  148.  
  149.         ' Draw bottom graph
  150.         If (CsrLin <= 23) Then
  151.             If (GuessesTotal <> 0) Then
  152.                 Call PrintGraph(TheString, Grade())
  153.             End If
  154.         End If
  155.  
  156.         _Delay .02
  157.         _Display
  158.         _Limit 60
  159.     Next
  160.  
  161.     _Delay 3
  162.  
  163.  
  164. Sub InitializeModel
  165.     Dim As Integer k
  166.     For k = 1 To UBound(AlphaWeight)
  167.         AlphaWeight(k) = k ^ 2
  168.     Next
  169.     'AlphaWeight(1) = 0
  170.     'AlphaWeight(2) = 0
  171.     'AlphaWeight(3) = 0
  172.     'AlphaWeight(4) = 0
  173.     'AlphaWeight(5) = 1
  174.     'AlphaWeight(6) = 0
  175.     'AlphaWeight(7) = 0
  176.     'AlphaWeight(8) = 0
  177.     'AlphaWeight(9) = 0
  178.     'AlphaWeight(10) = 0
  179.     AlphaWeight(11) = 0
  180.     AlphaWeight(12) = 0
  181.     AlphaWeight(13) = 0
  182.  
  183. Function Analyze (TheStringIn As String, arrweight() As Double, pswitch As Integer)
  184.     Dim TheReturn As Integer
  185.     Dim As Integer n
  186.     Dim As Double r, j, k
  187.     Dim StringPhase(16) As String
  188.     Dim Partialguess(1 To 13, 2) As Double ' Change the upper bound to a higer number for more accuracy.
  189.  
  190.     ' Create shifted versions of string, i.e. ABCD -> BCDA, CDAB, DABC, ABCD, BCDA, etc.
  191.     StringPhase(1) = TheStringIn
  192.     'For n = 2 To UBound(StringPhase)
  193.     'StringPhase(n) = Right$(StringPhase(n - 1), Len(StringPhase(n - 1)) - 1) + Left$(StringPhase(n - 1), 1)
  194.     'Next
  195.  
  196.     ' Initialize partial results.
  197.     For n = LBound(Partialguess) To UBound(Partialguess)
  198.         Partialguess(n, 1) = -999
  199.     Next
  200.  
  201.     If (arrweight(1) <> 0) Then Call CreateHisto(StringPhase(), Alphabet1(), 1)
  202.     If (arrweight(2) <> 0) Then Call CreateHisto(StringPhase(), Alphabet2(), 2)
  203.     If (arrweight(3) <> 0) Then Call CreateHisto(StringPhase(), Alphabet3(), 3)
  204.     If (arrweight(4) <> 0) Then Call CreateHisto(StringPhase(), Alphabet4(), 4)
  205.     If (arrweight(5) <> 0) Then Call CreateHisto(StringPhase(), Alphabet5(), 5)
  206.     If (arrweight(6) <> 0) Then Call CreateHisto(StringPhase(), Alphabet6(), 6)
  207.     If (arrweight(7) <> 0) Then Call CreateHisto(StringPhase(), Alphabet7(), 7)
  208.     If (arrweight(8) <> 0) Then Call CreateHisto(StringPhase(), Alphabet8(), 8)
  209.     If (arrweight(9) <> 0) Then Call CreateHisto(StringPhase(), Alphabet9(), 9)
  210.     If (arrweight(10) <> 0) Then Call CreateHisto(StringPhase(), Alphabet10(), 10)
  211.     If (arrweight(11) <> 0) Then Call CreateHisto(StringPhase(), Alphabet11(), 11)
  212.     If (arrweight(12) <> 0) Then Call CreateHisto(StringPhase(), Alphabet12(), 12)
  213.     If (arrweight(13) <> 0) Then Call CreateHisto(StringPhase(), Alphabet13(), 13)
  214.  
  215.     If (pswitch = 1) Then
  216.         For n = 1 To _Width
  217.             Print "-";
  218.         Next
  219.         Print
  220.     End If
  221.  
  222.     If (pswitch = 1) Then ' Set the last argument >=1 to print stats for that histogram.
  223.         If ((Len(TheStringIn) >= 1) And (arrweight(1) <> 0)) Then Call PrintHisto(Alphabet1(), 2)
  224.         If ((Len(TheStringIn) >= 2) And (arrweight(2) <> 0)) Then Call PrintHisto(Alphabet2(), 4)
  225.         If ((Len(TheStringIn) >= 3) And (arrweight(3) <> 0)) Then Call PrintHisto(Alphabet3(), 4)
  226.         If ((Len(TheStringIn) >= 4) And (arrweight(4) <> 0)) Then Call PrintHisto(Alphabet4(), 0)
  227.         If ((Len(TheStringIn) >= 5) And (arrweight(5) <> 0)) Then Call PrintHisto(Alphabet5(), 0)
  228.         If ((Len(TheStringIn) >= 6) And (arrweight(6) <> 0)) Then Call PrintHisto(Alphabet6(), 0)
  229.         If ((Len(TheStringIn) >= 7) And (arrweight(7) <> 0)) Then Call PrintHisto(Alphabet7(), 0)
  230.         If ((Len(TheStringIn) >= 8) And (arrweight(8) <> 0)) Then Call PrintHisto(Alphabet8(), 0)
  231.         If ((Len(TheStringIn) >= 9) And (arrweight(9) <> 0)) Then Call PrintHisto(Alphabet9(), 0)
  232.         If ((Len(TheStringIn) >= 10) And (arrweight(10) <> 0)) Then Call PrintHisto(Alphabet10(), 0)
  233.         If ((Len(TheStringIn) >= 11) And (arrweight(11) <> 0)) Then Call PrintHisto(Alphabet11(), 0)
  234.         If ((Len(TheStringIn) >= 12) And (arrweight(12) <> 0)) Then Call PrintHisto(Alphabet12(), 0)
  235.         If ((Len(TheStringIn) >= 13) And (arrweight(13) <> 0)) Then Call PrintHisto(Alphabet13(), 0)
  236.         Print
  237.     End If
  238.  
  239.     If ((Len(TheStringIn) >= 1) And (arrweight(1) <> 0)) Then Call MakeGuess(TheStringIn, Alphabet1(), 1, Partialguess(), 0) ' Set the last argument =1 to print guess for that histogram.
  240.     If ((Len(TheStringIn) >= 2) And (arrweight(2) <> 0)) Then Call MakeGuess(TheStringIn, Alphabet2(), 2, Partialguess(), pswitch)
  241.     If ((Len(TheStringIn) >= 3) And (arrweight(3) <> 0)) Then Call MakeGuess(TheStringIn, Alphabet3(), 3, Partialguess(), pswitch)
  242.     If ((Len(TheStringIn) >= 4) And (arrweight(4) <> 0)) Then Call MakeGuess(TheStringIn, Alphabet4(), 4, Partialguess(), 0)
  243.     If ((Len(TheStringIn) >= 5) And (arrweight(5) <> 0)) Then Call MakeGuess(TheStringIn, Alphabet5(), 5, Partialguess(), 0)
  244.     If ((Len(TheStringIn) >= 6) And (arrweight(6) <> 0)) Then Call MakeGuess(TheStringIn, Alphabet6(), 6, Partialguess(), 0)
  245.     If ((Len(TheStringIn) >= 7) And (arrweight(7) <> 0)) Then Call MakeGuess(TheStringIn, Alphabet7(), 7, Partialguess(), 0)
  246.     If ((Len(TheStringIn) >= 8) And (arrweight(8) <> 0)) Then Call MakeGuess(TheStringIn, Alphabet8(), 8, Partialguess(), 0)
  247.     If ((Len(TheStringIn) >= 9) And (arrweight(9) <> 0)) Then Call MakeGuess(TheStringIn, Alphabet9(), 9, Partialguess(), 0)
  248.     If ((Len(TheStringIn) >= 10) And (arrweight(10) <> 0)) Then Call MakeGuess(TheStringIn, Alphabet10(), 10, Partialguess(), 0)
  249.     If ((Len(TheStringIn) >= 11) And (arrweight(11) <> 0)) Then Call MakeGuess(TheStringIn, Alphabet11(), 11, Partialguess(), 0)
  250.     If ((Len(TheStringIn) >= 12) And (arrweight(12) <> 0)) Then Call MakeGuess(TheStringIn, Alphabet12(), 12, Partialguess(), 0)
  251.     If ((Len(TheStringIn) >= 13) And (arrweight(13) <> 0)) Then Call MakeGuess(TheStringIn, Alphabet13(), 13, Partialguess(), 0)
  252.     If (pswitch = 1) Then Print
  253.  
  254.     If (pswitch = 1) Then
  255.         Print "Thinking:";
  256.         For k = LBound(Partialguess) To UBound(Partialguess)
  257.             If (Partialguess(k, 1) <> -999) Then
  258.                 Print Partialguess(k, 1);
  259.             Else
  260.                 Print "_ ";
  261.             End If
  262.         Next
  263.         Print
  264.     End If
  265.  
  266.     j = 0
  267.     r = 0
  268.  
  269.     For k = UBound(Partialguess) To LBound(Partialguess) Step -1
  270.         If (Partialguess(k, 1) <> -999) Then
  271.             ' weighted average:
  272.             r = r + arrweight(k) * Partialguess(k, 1)
  273.             j = j + arrweight(k)
  274.         End If
  275.     Next
  276.     If (j <> 0) Then
  277.         r = r / j
  278.     End If
  279.  
  280.     If (pswitch = 1) Then Print "Predicting:  "; _Trim$(Str$(r))
  281.  
  282.     If (r > .5) Then
  283.         r = 1
  284.     Else
  285.         r = 0
  286.     End If
  287.  
  288.     If (pswitch = 1) Then
  289.         Print "Rounding to: "; _Trim$(Str$(r))
  290.     End If
  291.  
  292.     If (pswitch = 1) Then
  293.         For n = 1 To _Width
  294.             Print "-";
  295.         Next
  296.         Print: Print
  297.     End If
  298.  
  299.     TheReturn = r
  300.     Analyze = TheReturn
  301.  
  302. Sub MakeGuess (TheStringIn As String, arralpha() As LetterBin, wid As Integer, arrbeta() As Double, pswitch As Integer)
  303.     Dim TheReturn As Double
  304.     Dim As Integer j, k, n
  305.     TheReturn = 0
  306.     j = 1
  307.     k = 0
  308.     For n = 1 To UBound(arralpha)
  309.         If (Left$(arralpha(n).Signature, wid - 1) = Right$(TheStringIn, wid - 1)) Then
  310.             If (arralpha(n).Count >= j) Then
  311.                 If (pswitch = 1) Then Print "Order-"; Right$("0" + _Trim$(Str$(wid)), 2); " guess: "; arralpha(n).Signature; " . "; _Trim$(Str$(arralpha(n).Count))
  312.                 TheReturn = TheReturn + Val(Right$(arralpha(n).Signature, 1))
  313.                 k = k + 1
  314.                 j = arralpha(n).Count
  315.             End If
  316.         End If
  317.     Next
  318.     If (k <> 0) Then
  319.         TheReturn = TheReturn / k
  320.     Else
  321.         TheReturn = .5
  322.     End If
  323.     arrbeta(wid, 1) = TheReturn
  324.     arrbeta(wid, 2) = j
  325.  
  326. Sub CreateHisto (arrfinger() As String, arralpha() As LetterBin, w As Integer)
  327.     Dim As Integer j, k, n
  328.     For n = 1 To UBound(arralpha)
  329.         arralpha(n).Count = 0
  330.     Next
  331.     'For j = 1 To w
  332.     j = 1
  333.     For k = 1 To Len(arrfinger(j)) - (Len(arrfinger(j)) Mod w) Step w
  334.         For n = 1 To UBound(arralpha)
  335.             If (Mid$(arrfinger(j), k, w) = arralpha(n).Signature) Then
  336.                 arralpha(n).Count = arralpha(n).Count + 1
  337.             End If
  338.         Next
  339.     Next
  340.     'Next
  341.     Call QuickSort(arralpha(), 1, UBound(arralpha))
  342.  
  343. Sub PrintHisto (arr() As LetterBin, w As Integer)
  344.     Dim As Integer j, n
  345.     If (w > 0) Then
  346.         If (w > UBound(arr)) Then
  347.             j = UBound(arr)
  348.         Else
  349.             j = w
  350.         End If
  351.         Print "Histogram: "; _Trim$(Str$(UBound(arr))); "-letter regroup, showing top "; _Trim$(Str$(w))
  352.         For n = 1 To j
  353.             Print arr(n).Signature; arr(n).Count
  354.         Next
  355.     End If
  356.  
  357. Sub PrintGraph (TheString As String, arrgrade() As Double)
  358.     Dim As Integer j, k
  359.     Dim As Double f, g, h
  360.     For k = 1 To _Width
  361.         Locate _Height - 5, k: Print "_"
  362.         Locate _Height - 5 - 10, k: Print "_"
  363.     Next
  364.     Locate _Height - 5 + 1, 1: Print "0%"
  365.     Locate _Height - 5 - 10 - 1, 1: Print "100%"
  366.     f = _Width / Len(TheString)
  367.     If (f > 1) Then f = 1
  368.     For j = 1 To Len(TheString)
  369.         h = j * f
  370.         If (h < 1) Then h = h + 1
  371.         g = arrgrade(j, 1)
  372.         Locate _Height - 5 - Int(10 * g), Int(h)
  373.         If (arrgrade(j, 2) = 1) Then
  374.             Print Chr$(251)
  375.         Else
  376.             Print "x"
  377.         End If
  378.     Next
  379.  
  380. Sub NewAlphabet (arrold() As LetterBin, arrnew() As LetterBin)
  381.     Dim As Integer j, k, n
  382.     n = 0
  383.     For k = 1 To 2
  384.         For j = 1 To UBound(arrold)
  385.             n = n + 1
  386.             arrnew(n).Signature = arrold(j).Signature
  387.         Next
  388.     Next
  389.     For j = 1 To UBound(arrnew)
  390.         If (j <= UBound(arrnew) / 2) Then
  391.             arrnew(j).Signature = "0" + arrnew(j).Signature
  392.         Else
  393.             arrnew(j).Signature = "1" + arrnew(j).Signature
  394.         End If
  395.     Next
  396.  
  397. Sub QuickSort (arr() As LetterBin, LowLimit As Long, HighLimit As Long)
  398.     Dim As Long piv
  399.     If (LowLimit < HighLimit) Then
  400.         piv = Partition(arr(), LowLimit, HighLimit)
  401.         Call QuickSort(arr(), LowLimit, piv - 1)
  402.         Call QuickSort(arr(), piv + 1, HighLimit)
  403.     End If
  404.  
  405. Function Partition (arr() As LetterBin, LowLimit As Long, HighLimit As Long)
  406.     Dim As Long i, j
  407.     Dim As Double pivot, tmp
  408.     pivot = arr(HighLimit).Count
  409.     i = LowLimit - 1
  410.     For j = LowLimit To HighLimit - 1
  411.         tmp = arr(j).Count - pivot
  412.         If (tmp >= 0) Then
  413.             i = i + 1
  414.             Swap arr(i), arr(j)
  415.         End If
  416.     Next
  417.     Swap arr(i + 1), arr(HighLimit)
  418.     Partition = i + 1
  419.  
  420. 'Function Pathological$ (TheSeed As String, TheLength As Integer)
  421. '    Dim TheReturn As String
  422. '    TheReturn = TheSeed
  423. '    Dim p
  424. '    Do
  425. '        Cls
  426. '        Locate 1, 1
  427. '        Print TheReturn;
  428. '        p = Analyze(TheReturn, 0)
  429. '        If (p = 1) Then
  430. '            TheReturn = TheReturn + "0"
  431. '        Else
  432. '            TheReturn = TheReturn + "1"
  433. '        End If
  434. '    Loop Until Len(TheReturn) = TheLength
  435. '    Pathological$ = TheReturn
  436. 'End Function
  437.  
  438. Function LoadTestData (alwayszero As Integer)
  439.     Dim n As Integer
  440.     n = alwayszero
  441.  
  442.     '''
  443.     ' Percussive cases:
  444.     '''
  445.     n = n + 1: TestData(n) = "1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111"
  446.     n = n + 1: TestData(n) = "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
  447.     n = n + 1: TestData(n) = "0101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101"
  448.     n = n + 1: TestData(n) = "1010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010"
  449.     n = n + 1: TestData(n) = "0001110011000111001100011100110001110011000111001100011100110001110011000111001100011100110001110011000111001100011100110001110011000111001100011100110001110011"
  450.     n = n + 1: TestData(n) = "0100010111010001011101000101110100010111010001011101000101110100010111010001011101000101110100010111010001011101000101110100010111010001011101000101110100010111"
  451.  
  452.     '''
  453.     ' Human samples:
  454.     '''
  455.     ' (from Keybone)
  456.     n = n + 1: TestData(n) = "101010101010101010101001010101010101001010111001010101010101010101010100010101010101010100101001010101001100101010001010100101010100101010100101010101010101010011011110010101010100100101010110010011001010011001010100010100101010010101010101010010101010101010010101001010101010100110010101010100101010101010011001001010100101010010101010100101010010101001010100101001010010101010111010100110011001010101010100110101001010101010100101001010111010101010101010100101001010101010010101010101001010101001010101001010100101010100101010010101010101001010101001010101010101001010101001010100101010101010010101010010010101010101010101010010100101010101001010100101001010101001111101010101010100101010110011001010101010101010110101010101101010101010100101010010101010010101010101101110010101001010101010110010100101010101001011010101010100110101010100101010010101010100101010101001010101010101001010101010011010101010101110110100101010111010101011011001011001010101001010101010101010101010011001010101010100101010101010101010010100101"
  457.     ' (from Keybone)
  458.     n = n + 1: TestData(n) = "0101110101100011010100101011001110001011001010001110101111010100111011100100101001010011110101101000101010001010101111001010111010101010100001010101000101101100101111101010010101110110111001000101000011010101010001001001001111101011101010100010110101110101100000101010101110111010100100100001110111100101011110101010001010001110010110111110110010101001001011101000101001011100011101000010101010101101010010110100101101000101111010101110111001010011101111010101000010101111100010101011110101011011110100001010110"
  459.     ' (from Loudar)
  460.     n = n + 1: TestData(n) = "1011001010010100100100110010101010101001010101010101011010010101001010101001010010100110101011010101010101011010101101010101010101010010110101010101100101010101010110101101011010010101010010100110101101001010110101011010010101101010110100101111010101010011011011010010110101010010110100101101010100101011010010101001010101010001011101011010010101011100111010010001101011110010011010001011100110101010010011010101001001010010000101010110001"
  461.     ' (from Luke)
  462.     n = n + 1: TestData(n) = "01100101001010001100001101101111011010010101010110110101001000001111001111110101000101111011010101111101010101101010101001010101011000010101010101001011010100110100110100110011010101010101110101010111111101011010100000001101111000010111000110111001000010100001101010110100000111101011111100001011001010110010110"
  463.     ' (from Sarafromct)
  464.     n = n + 1: TestData(n) = "10101010101011101000011101010111010101010101100111001010100111100001011011110101000001111010101101010000001111110011111110111101110111001110110010000100010101010101010100101011010110101010101010101001000000001111110000011110101010101010100010101110101010101101111111111111111111101010101010101000000"
  465.     ' (from Spriggs)
  466.     n = n + 1: TestData(n) = "10111010101010101010101001010101010101001010101001010101010101010101010101010101010101010101010101010101001010100100100101010101010101001010100101010101010100101010100101010101010101010101001010010110010101010010101010101010101010101010100101001001001010101010101010101010101001010101001001101010010"
  467.     ' (from Spriggs)
  468.     n = n + 1: TestData(n) = "11111011110100101011111111110100000011011110101100111100111111110111101110100111100110011111110101111111010111101111100111110111111111111011100111110111111110010000101011111001110101101010110111110"
  469.     ' (from Hotpants)
  470.     n = n + 1: TestData(n) = "01010100011001010010101010101010101000110101010111101010100100011010101010100100101110010010010100001010101001010101010110010001001011000100100110101001001001010000000001010101101111101001010100010101001001010101000100101001100100010011010101010101010111010010101011101011011010110100100010010100100100010010001001"
  471.  
  472.     LoadTestData = n
  473.  
Title: Re: Looking for old program or help recreating it
Post by: STxAxTIC on December 20, 2021, 02:04:07 pm
Hey again R1,

I decided to just try oooooone more idea with this thing, and as fate would have it, that was like a dozen ideas ago. Before I get too crazy far ahead, I wanted to let you know that this program's prediction algo is now able to tune itself without any human intervention. That is to say, it does a kind of machine learning. Gulp. There goes another weekend probably... It seems to be doing very well so far - it's already found a better model than what the Inform game uses. (These updates are coming in hot.)

Just some review so we're on the same page. For a sequence S, the program looks at patterns in fixed width chunks 1,2,3,4...,7,8,9,10. That's why there are 10 alphabets, etc. etc. Alright, so this means the algorithm can come up with 10 different guesses g(n) for the result, one for each chunk size / library. The most general way to combine those looks like:

Prediction(s) = N * (w(1)*g(1) + w(2)*g(2) + w(3)*g(3) + ... + w(10)*g(10))

Where the function w(n) is the weight function we've been talking about. My old h-variable. So far so good?

Up til today, two such w(n)-models have been deployed:
(i) For our heavy testing, I let w(n) = n^2, so high-alphabet guesses matter more than lower ones.
(ii) All w(n)=0 except w(5)=1. Believe it or not, this is really good at predicting humans and there isn't any science behind it.

The website is solely about #1. InForm demo uses #2.

So what's new? Here we go.....

I wanted to think up a general-enough scheme for the weight function w(n) that covers most of "weight space", which is to say - I want a way to systematically guess at these weights. The model that's in play right now is as follows:

(i) Each w(n) is either a 0 or a 1. Either that guess counts, or it doesn't. No further weighting beyond that for now.
(ii) Lining up each w(n) in a row, this might, for instance look like 0100111010. (This means w(1)=0, w(2)=1, w(3)=0, etc.)
(iii) Observe that 0100111010 is itself a binary number. The lowest of these has all 0's: 0000000000. The highest has ten 1's: 1111111111
(iv) Thus, we can cycle through every single binary model by counting from 0000000000 to 1111111111 in binary.
(v) With that realized, test the program on a standardized piece of data and collect statistics on each model. The best model will stand out.

If you follow all that, you're caught up to what my code is doing right now. At the moment I've got it training on just a single sequence, and that's the one provided by Luke. Turns out the AI has already found a model better than the one I was using and the program's not even finished running yet. I know it's early, so results may vary.

Either way. here's what's going on:

Code: QB64: [Select]
  1.  
  2. Screen _NewImage(120, 40)
  3.  
  4. ' Version: 20
  5.  
  6. Type LetterBin
  7.     Signature As String
  8.     Count As Integer
  9.  
  10. Dim Shared Alphabet1(2) As LetterBin ' 0 1
  11. Dim Shared Alphabet2(4) As LetterBin ' 00 01 10 11
  12. Dim Shared Alphabet3(8) As LetterBin ' 000 001 010 011 100 101 110 111
  13. Dim Shared Alphabet4(16) As LetterBin ' etc.
  14. Dim Shared Alphabet5(32) As LetterBin
  15. Dim Shared Alphabet6(64) As LetterBin
  16. Dim Shared Alphabet7(128) As LetterBin
  17. Dim Shared Alphabet8(256) As LetterBin
  18. Dim Shared Alphabet9(512) As LetterBin
  19. Dim Shared Alphabet10(1024) As LetterBin
  20. Dim Shared Alphabet11(2048) As LetterBin
  21. Dim Shared Alphabet12(4096) As LetterBin
  22. Dim Shared Alphabet13(8192) As LetterBin
  23.  
  24. Alphabet1(1).Signature = "0"
  25. Alphabet1(2).Signature = "1"
  26. Call NewAlphabet(Alphabet1(), Alphabet2())
  27. Call NewAlphabet(Alphabet2(), Alphabet3())
  28. Call NewAlphabet(Alphabet3(), Alphabet4())
  29. Call NewAlphabet(Alphabet4(), Alphabet5())
  30. Call NewAlphabet(Alphabet5(), Alphabet6())
  31. Call NewAlphabet(Alphabet6(), Alphabet7())
  32. Call NewAlphabet(Alphabet7(), Alphabet8())
  33. Call NewAlphabet(Alphabet8(), Alphabet9())
  34. Call NewAlphabet(Alphabet9(), Alphabet10())
  35. Call NewAlphabet(Alphabet10(), Alphabet11())
  36. Call NewAlphabet(Alphabet11(), Alphabet12())
  37. Call NewAlphabet(Alphabet12(), Alphabet13())
  38.  
  39. ' Load test data.
  40. ReDim Shared TestData(10000) As String
  41. ReDim _Preserve TestData(LoadTestData(0))
  42.  
  43. ' This is the made-up part of the model.
  44. Dim Shared AlphaWeight(1 To 13) As Double
  45.  
  46. ' Statistics and metrics:
  47. Dim GuessPredicted As Integer
  48. Dim GuessCorrect As Double
  49. Dim GuessTotal As Double
  50. Dim GuessRatioMax As Double
  51. Dim GuessStreak As Integer
  52. Dim GuessStreakMax As Integer
  53. Dim Grade(10000, 2) As Double
  54.  
  55. Dim TheString As String
  56. Dim As Integer k, m, n
  57.  
  58. GuessRatioMax = 0
  59.  
  60. Dim BinaryModelCounter As Integer
  61. Dim BinaryModelBest As Integer
  62. BinaryModelCounter = 0
  63.  
  64. Do While (BinaryModelCounter < 1024)
  65.     Call InitializeBinaryModel(BinaryModelCounter)
  66.     BinaryModelCounter = BinaryModelCounter + 1
  67.  
  68.     '''
  69.     ' Bypass pre-cooked test data.
  70.     TestData(1) = "01100101001010001100001101101111011010010101010110110101001000001111001111110101000101111011010101111101010101101010101001010101011000010101010101001011010100110100110100110011010101010101110101010111111101011010100000001101111000010111000110111001000010100001101010110100000111101011111100001011001010110010110"
  71.     ReDim _Preserve TestData(1)
  72.     '''
  73.  
  74.     For m = 1 To UBound(TestData)
  75.  
  76.         GuessPredicted = -1
  77.         GuessCorrect = 0
  78.         GuessTotal = 0
  79.         GuessStreak = 0
  80.         GuessStreakMax = 0
  81.  
  82.         For n = 1 To Len(TestData(m)) '9999
  83.  
  84.             '''
  85.             ' Research Mode
  86.             TheString = Left$(TestData(m), n)
  87.             '''
  88.  
  89.             '''
  90.             '' Gaming Mode
  91.             'Cls
  92.             'Locate 1, 1
  93.             'Print "Press LEFT or RIGHT."
  94.             'k = 0
  95.             'Do: k = _KeyHit: Loop Until ((k = 19200) Or (k = 19712))
  96.             'Select Case k
  97.             '    Case 19200
  98.             '        TheString = TheString + "0"
  99.             '    Case 19712
  100.             '        TheString = TheString + "1"
  101.             'End Select
  102.             '_KeyClear
  103.             '''
  104.  
  105.             Cls
  106.             Color 7
  107.             Locate 1, 1
  108.             For k = 1 To _Width
  109.                 Print "_";
  110.             Next
  111.             Print "Model:";
  112.             For k = 1 To 10 'UBound(AlphaWeight)
  113.                 Print AlphaWeight(k);
  114.             Next
  115.             Print
  116.             Print
  117.             Print "Sequence (length "; _Trim$(Str$(Len(TheString))); "):"
  118.             Print TheString ';
  119.             Color 8
  120.             'Print Right$(TestData(m), Len(TestData(m)) - n)
  121.             Color 7
  122.  
  123.             ' Reconciliation
  124.             If (GuessPredicted <> -1) Then
  125.                 Print
  126.                 Print "I predicted "; _Trim$(Str$(GuessPredicted)); " and you typed "; Right$(TheString, 1); "."
  127.                 If (GuessPredicted = Val(Right$(TheString, 1))) Then
  128.                     Print "I am RIGHT this round."
  129.                     GuessCorrect = GuessCorrect + 1
  130.                     GuessStreak = GuessStreak + 1
  131.                     If (GuessStreak > GuessStreakMax) Then GuessStreakMax = GuessStreak
  132.                     Grade(n, 2) = 1
  133.                 Else
  134.                     Print "I am WRONG this round."
  135.                     GuessStreak = 0
  136.                     Grade(n, 2) = 0
  137.                 End If
  138.                 GuessTotal = GuessTotal + 1
  139.                 Grade(n, 1) = GuessCorrect / GuessTotal
  140.             End If
  141.  
  142.             If (GuessTotal > 0) Then
  143.                 Print
  144.                 Print "I'm on a "; _Trim$(Str$(GuessStreak)); "-round winning streak."
  145.                 Print "My best streak has been "; _Trim$(Str$(GuessStreakMax)); "."
  146.                 If (GuessTotal <> 0) Then
  147.                     Print "My correctness rate is "; _Trim$(Str$(Int(100 * GuessCorrect / GuessTotal))); "% in "; _Trim$(Str$(GuessTotal)); " guesses."
  148.                 End If
  149.             End If
  150.  
  151.             GuessPredicted = Analyze(TheString, AlphaWeight(), 0)
  152.  
  153.             Print
  154.             'Print "I have made a new prediction."
  155.             'Print "Press LEFT or RIGHT to test me."
  156.             Print "The best model was # "; _Trim$(Str$(BinaryModelBest)); ", rated "; _Trim$(Str$(Int(GuessRatioMax * 100))); "%"
  157.  
  158.             ' Draw bottom graph
  159.             If (CsrLin <= 23) Then
  160.                 If (GuessTotal <> 0) Then
  161.                     Call PrintGraph(TheString, Grade())
  162.                 End If
  163.             End If
  164.  
  165.             _Display
  166.             '_Delay .02
  167.             _Limit 240
  168.         Next
  169.  
  170.         If (GuessCorrect / GuessTotal > GuessRatioMax) Then
  171.             BinaryModelBest = BinaryModelCounter
  172.             GuessRatioMax = GuessCorrect / GuessTotal
  173.         End If
  174.  
  175.         _Display
  176.         _Delay 1
  177.     Next
  178.  
  179.  
  180. Sub InitializeBinaryModel (TheIndexIn As Integer)
  181.     '0 to 1023
  182.     Dim As Integer k
  183.     Dim As String BinWeight
  184.     BinWeight = BIN$(TheIndexIn)
  185.     For k = 1 To 10
  186.         AlphaWeight(k) = Val(Mid$(BinWeight, 10 - k + 1, 1))
  187.     Next
  188.     AlphaWeight(11) = 0
  189.     AlphaWeight(12) = 0
  190.     AlphaWeight(13) = 0
  191.  
  192.     Dim As Integer max, i, msb
  193.     Dim As String b
  194.     max% = 8 * Len(n%) ': MSB% = 1   'uncomment for 16 (32 or 64) bit returns
  195.     For i = max% - 1 To 0 Step -1 'read as big-endian MSB to LSB
  196.         If (n% And 2 ^ i) Then msb% = 1: b$ = b$ + "1" Else If msb% Then b$ = b$ + "0"
  197.     Next
  198.     b$ = "0000000000" + b$
  199.     b$ = Right$(b$, 10)
  200.     If b$ = "" Then BIN$ = "0" Else BIN$ = b$ 'check for empty string
  201.  
  202. Sub InitializeCustomModel
  203.     Dim As Integer k
  204.     For k = LBound(AlphaWeight) To UBound(AlphaWeight)
  205.         AlphaWeight(k) = 0 * k ^ 2
  206.     Next
  207.     'AlphaWeight(1) = 0
  208.     'AlphaWeight(2) = 0
  209.     'AlphaWeight(3) = 0
  210.     'AlphaWeight(4) = 0
  211.     AlphaWeight(5) = 1
  212.     'AlphaWeight(6) = 0
  213.     'AlphaWeight(7) = 0
  214.     'AlphaWeight(8) = 0
  215.     'AlphaWeight(9) = 0
  216.     'AlphaWeight(10) = 0
  217.     AlphaWeight(11) = 0
  218.     AlphaWeight(12) = 0
  219.     AlphaWeight(13) = 0
  220.  
  221. Function Analyze (TheStringIn As String, arrweight() As Double, pswitch As Integer)
  222.     Dim TheReturn As Integer
  223.     Dim As Integer n
  224.     Dim As Double r, j, k
  225.     Dim StringPhase(UBound(arrweight)) As String
  226.     Dim Partialguess(LBound(arrweight) To UBound(arrweight), 2) As Double
  227.  
  228.     StringPhase(1) = TheStringIn
  229.     'For n = 2 To UBound(StringPhase) ' Uncomment for phase analysis.
  230.     'StringPhase(n) = Right$(StringPhase(n - 1), Len(StringPhase(n - 1)) - 1) + Left$(StringPhase(n - 1), 1)
  231.     'Next
  232.  
  233.     ' Initialize partial results.
  234.     For n = LBound(Partialguess) To UBound(Partialguess)
  235.         Partialguess(n, 1) = -999
  236.     Next
  237.  
  238.     If (pswitch = 1) Then
  239.         Print
  240.         For n = 1 To _Width
  241.             Print "-";
  242.         Next
  243.         Print
  244.     End If
  245.  
  246.     If (arrweight(1) <> 0) Then Call CreateHisto(StringPhase(), 1, Alphabet1())
  247.     If (arrweight(2) <> 0) Then Call CreateHisto(StringPhase(), 2, Alphabet2())
  248.     If (arrweight(3) <> 0) Then Call CreateHisto(StringPhase(), 3, Alphabet3())
  249.     If (arrweight(4) <> 0) Then Call CreateHisto(StringPhase(), 4, Alphabet4())
  250.     If (arrweight(5) <> 0) Then Call CreateHisto(StringPhase(), 5, Alphabet5())
  251.     If (arrweight(6) <> 0) Then Call CreateHisto(StringPhase(), 6, Alphabet6())
  252.     If (arrweight(7) <> 0) Then Call CreateHisto(StringPhase(), 7, Alphabet7())
  253.     If (arrweight(8) <> 0) Then Call CreateHisto(StringPhase(), 8, Alphabet8())
  254.     If (arrweight(9) <> 0) Then Call CreateHisto(StringPhase(), 9, Alphabet9())
  255.     If (arrweight(10) <> 0) Then Call CreateHisto(StringPhase(), 10, Alphabet10())
  256.     If (arrweight(11) <> 0) Then Call CreateHisto(StringPhase(), 11, Alphabet11())
  257.     If (arrweight(12) <> 0) Then Call CreateHisto(StringPhase(), 12, Alphabet12())
  258.     If (arrweight(13) <> 0) Then Call CreateHisto(StringPhase(), 13, Alphabet13())
  259.  
  260.     If (pswitch = 1) Then ' Set the last argument >=1 to print stats for that histogram.
  261.         If ((Len(TheStringIn) >= 1) And (arrweight(1) <> 0)) Then Call PrintHisto(Alphabet1(), 0)
  262.         If ((Len(TheStringIn) >= 2) And (arrweight(2) <> 0)) Then Call PrintHisto(Alphabet2(), 0)
  263.         If ((Len(TheStringIn) >= 3) And (arrweight(3) <> 0)) Then Call PrintHisto(Alphabet3(), 0)
  264.         If ((Len(TheStringIn) >= 4) And (arrweight(4) <> 0)) Then Call PrintHisto(Alphabet4(), 0)
  265.         If ((Len(TheStringIn) >= 5) And (arrweight(5) <> 0)) Then Call PrintHisto(Alphabet5(), 4)
  266.         If ((Len(TheStringIn) >= 6) And (arrweight(6) <> 0)) Then Call PrintHisto(Alphabet6(), 0)
  267.         If ((Len(TheStringIn) >= 7) And (arrweight(7) <> 0)) Then Call PrintHisto(Alphabet7(), 0)
  268.         If ((Len(TheStringIn) >= 8) And (arrweight(8) <> 0)) Then Call PrintHisto(Alphabet8(), 0)
  269.         If ((Len(TheStringIn) >= 9) And (arrweight(9) <> 0)) Then Call PrintHisto(Alphabet9(), 0)
  270.         If ((Len(TheStringIn) >= 10) And (arrweight(10) <> 0)) Then Call PrintHisto(Alphabet10(), 0)
  271.         If ((Len(TheStringIn) >= 11) And (arrweight(11) <> 0)) Then Call PrintHisto(Alphabet11(), 0)
  272.         If ((Len(TheStringIn) >= 12) And (arrweight(12) <> 0)) Then Call PrintHisto(Alphabet12(), 0)
  273.         If ((Len(TheStringIn) >= 13) And (arrweight(13) <> 0)) Then Call PrintHisto(Alphabet13(), 0)
  274.         Print
  275.     End If
  276.  
  277.     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.
  278.     If ((Len(TheStringIn) >= 2) And (arrweight(2) <> 0)) Then Call MakeGuess(TheStringIn, 2, Alphabet2(), Partialguess(), 0)
  279.     If ((Len(TheStringIn) >= 3) And (arrweight(3) <> 0)) Then Call MakeGuess(TheStringIn, 3, Alphabet3(), Partialguess(), 0)
  280.     If ((Len(TheStringIn) >= 4) And (arrweight(4) <> 0)) Then Call MakeGuess(TheStringIn, 4, Alphabet4(), Partialguess(), 0)
  281.     If ((Len(TheStringIn) >= 5) And (arrweight(5) <> 0)) Then Call MakeGuess(TheStringIn, 5, Alphabet5(), Partialguess(), pswitch)
  282.     If ((Len(TheStringIn) >= 6) And (arrweight(6) <> 0)) Then Call MakeGuess(TheStringIn, 6, Alphabet6(), Partialguess(), 0)
  283.     If ((Len(TheStringIn) >= 7) And (arrweight(7) <> 0)) Then Call MakeGuess(TheStringIn, 7, Alphabet7(), Partialguess(), 0)
  284.     If ((Len(TheStringIn) >= 8) And (arrweight(8) <> 0)) Then Call MakeGuess(TheStringIn, 8, Alphabet8(), Partialguess(), 0)
  285.     If ((Len(TheStringIn) >= 9) And (arrweight(9) <> 0)) Then Call MakeGuess(TheStringIn, 9, Alphabet9(), Partialguess(), 0)
  286.     If ((Len(TheStringIn) >= 10) And (arrweight(10) <> 0)) Then Call MakeGuess(TheStringIn, 10, Alphabet10(), Partialguess(), 0)
  287.     If ((Len(TheStringIn) >= 11) And (arrweight(11) <> 0)) Then Call MakeGuess(TheStringIn, 11, Alphabet11(), Partialguess(), 0)
  288.     If ((Len(TheStringIn) >= 12) And (arrweight(12) <> 0)) Then Call MakeGuess(TheStringIn, 12, Alphabet12(), Partialguess(), 0)
  289.     If ((Len(TheStringIn) >= 13) And (arrweight(13) <> 0)) Then Call MakeGuess(TheStringIn, 13, Alphabet13(), Partialguess(), 0)
  290.     If (pswitch = 1) Then Print
  291.  
  292.     If (pswitch = 1) Then
  293.         Print "Thinking:";
  294.         For k = LBound(Partialguess) To UBound(Partialguess)
  295.             If (Partialguess(k, 1) <> -999) Then
  296.                 Print Partialguess(k, 1);
  297.             Else
  298.                 Print "_ ";
  299.             End If
  300.         Next
  301.         Print
  302.     End If
  303.  
  304.     j = 0
  305.     r = 0
  306.  
  307.     ' Weighted average calculation
  308.     For k = UBound(Partialguess) To LBound(Partialguess) Step -1
  309.         If (Partialguess(k, 1) <> -999) Then
  310.             r = r + arrweight(k) * Partialguess(k, 1)
  311.             j = j + arrweight(k)
  312.         End If
  313.     Next
  314.     If (j <> 0) Then
  315.         r = r / j
  316.     End If
  317.  
  318.     If (pswitch = 1) Then Print "Predicting:  "; _Trim$(Str$(r))
  319.  
  320.     If (r > .5) Then
  321.         r = 1
  322.     Else
  323.         r = 0
  324.     End If
  325.  
  326.     If (pswitch = 1) Then
  327.         Print "Rounding to: "; _Trim$(Str$(r))
  328.     End If
  329.  
  330.     If (pswitch = 1) Then
  331.         For n = 1 To _Width
  332.             Print "-";
  333.         Next
  334.         Print
  335.     End If
  336.  
  337.     TheReturn = r
  338.     Analyze = TheReturn
  339.  
  340. Sub MakeGuess (TheStringIn As String, wid As Integer, arralpha() As LetterBin, arrguess() As Double, pswitch As Integer)
  341.     Dim TheReturn As Double
  342.     Dim As Integer j, k, n
  343.     TheReturn = 0
  344.     j = 1
  345.     k = 0
  346.     For n = 1 To UBound(arralpha)
  347.         If (Left$(arralpha(n).Signature, wid - 1) = Right$(TheStringIn, wid - 1)) Then
  348.             If (arralpha(n).Count >= j) Then
  349.                 If (pswitch = 1) Then Print "Order-"; Right$("0" + _Trim$(Str$(wid)), 2); " guess: "; arralpha(n).Signature; " . "; _Trim$(Str$(arralpha(n).Count))
  350.                 TheReturn = TheReturn + Val(Right$(arralpha(n).Signature, 1))
  351.                 k = k + 1
  352.                 j = arralpha(n).Count
  353.             End If
  354.         End If
  355.     Next
  356.     If (k <> 0) Then
  357.         TheReturn = TheReturn / k
  358.     Else
  359.         TheReturn = .5
  360.     End If
  361.     arrguess(wid, 1) = TheReturn
  362.     arrguess(wid, 2) = j
  363.  
  364. Sub CreateHisto (arrfinger() As String, wid As Integer, arralpha() As LetterBin)
  365.     Dim As Integer j, k, n
  366.     For n = 1 To UBound(arralpha)
  367.         arralpha(n).Count = 0
  368.     Next
  369.     ' Uncomment this loop to enable phase analysis.
  370.     'For j = 1 To wid
  371.     j = 1
  372.     For k = 1 To Len(arrfinger(j)) - (Len(arrfinger(j)) Mod wid) Step wid
  373.         For n = 1 To UBound(arralpha)
  374.             If (Mid$(arrfinger(j), k, wid) = arralpha(n).Signature) Then
  375.                 arralpha(n).Count = arralpha(n).Count + 1
  376.             End If
  377.         Next
  378.     Next
  379.     'Next
  380.     Call QuickSort(arralpha(), 1, UBound(arralpha))
  381.  
  382. Sub PrintHisto (arr() As LetterBin, wid As Integer)
  383.     Dim As Integer j, n
  384.     If (wid > 0) Then
  385.         If (wid > UBound(arr)) Then
  386.             j = UBound(arr)
  387.         Else
  388.             j = wid
  389.         End If
  390.         Print "Histogram: "; _Trim$(Str$(UBound(arr))); "-letter regroup, showing top "; _Trim$(Str$(wid))
  391.         For n = 1 To j
  392.             Print arr(n).Signature; arr(n).Count
  393.         Next
  394.     End If
  395.  
  396. Sub PrintGraph (TheString As String, arrgrade() As Double)
  397.     Dim As Integer j, k
  398.     Dim As Double f, g
  399.     For k = 1 To _Width
  400.         Locate _Height - 5, k: Print "_"
  401.         Locate _Height - 5 - 10, k: Print "_"
  402.     Next
  403.     Locate _Height - 5 + 1, 1: Print "0%"
  404.     Locate _Height - 5 - 10 - 1, 1: Print "100%"
  405.     f = (_Width) / Len(TheString)
  406.     If (f > 1) Then f = 1
  407.     For j = 2 To Len(TheString)
  408.         g = Int(j * f)
  409.         If (g = 0) Then g = 1
  410.         Locate _Height - 5 - Int(10 * arrgrade(j, 1)), g
  411.         If (arrgrade(j, 2) = 1) Then
  412.             Print Chr$(251)
  413.         Else
  414.             Print "x"
  415.         End If
  416.     Next
  417.  
  418. Sub NewAlphabet (arrold() As LetterBin, arrnew() As LetterBin)
  419.     Dim As Integer j, k, n
  420.     n = 0
  421.     For k = 1 To 2
  422.         For j = 1 To UBound(arrold)
  423.             n = n + 1
  424.             arrnew(n).Signature = arrold(j).Signature
  425.         Next
  426.     Next
  427.     For j = 1 To UBound(arrnew)
  428.         If (j <= UBound(arrnew) / 2) Then
  429.             arrnew(j).Signature = "0" + arrnew(j).Signature
  430.         Else
  431.             arrnew(j).Signature = "1" + arrnew(j).Signature
  432.         End If
  433.     Next
  434.  
  435. Sub QuickSort (arr() As LetterBin, LowLimit As Long, HighLimit As Long)
  436.     Dim As Long piv
  437.     If (LowLimit < HighLimit) Then
  438.         piv = Partition(arr(), LowLimit, HighLimit)
  439.         Call QuickSort(arr(), LowLimit, piv - 1)
  440.         Call QuickSort(arr(), piv + 1, HighLimit)
  441.     End If
  442.  
  443. Function Partition (arr() As LetterBin, LowLimit As Long, HighLimit As Long)
  444.     Dim As Long i, j
  445.     Dim As Double pivot, tmp
  446.     pivot = arr(HighLimit).Count
  447.     i = LowLimit - 1
  448.     For j = LowLimit To HighLimit - 1
  449.         tmp = arr(j).Count - pivot
  450.         If (tmp >= 0) Then
  451.             i = i + 1
  452.             Swap arr(i), arr(j)
  453.         End If
  454.     Next
  455.     Swap arr(i + 1), arr(HighLimit)
  456.     Partition = i + 1
  457.  
  458. 'Function Pathological$ (TheSeed As String, TheLength As Integer)
  459. '    Dim TheReturn As String
  460. '    TheReturn = TheSeed
  461. '    Dim p
  462. '    Do
  463. '        Cls
  464. '        Locate 1, 1
  465. '        Print TheReturn;
  466. '        p = Analyze(TheReturn, 0)
  467. '        If (p = 1) Then
  468. '            TheReturn = TheReturn + "0"
  469. '        Else
  470. '            TheReturn = TheReturn + "1"
  471. '        End If
  472. '    Loop Until Len(TheReturn) = TheLength
  473. '    Pathological$ = TheReturn
  474. 'End Function
  475.  
  476. Function LoadTestData (alwayszero As Integer)
  477.     Dim n As Integer
  478.     n = alwayszero
  479.  
  480.     '''
  481.     ' Percussive cases:
  482.     '''
  483.     n = n + 1: TestData(n) = "1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111"
  484.     n = n + 1: TestData(n) = "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
  485.     n = n + 1: TestData(n) = "0101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101"
  486.     n = n + 1: TestData(n) = "1010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010"
  487.     n = n + 1: TestData(n) = "0001110011000111001100011100110001110011000111001100011100110001110011000111001100011100110001110011000111001100011100110001110011000111001100011100110001110011"
  488.     n = n + 1: TestData(n) = "0100010111010001011101000101110100010111010001011101000101110100010111010001011101000101110100010111010001011101000101110100010111010001011101000101110100010111"
  489.  
  490.     '''
  491.     ' Human samples:
  492.     '''
  493.     ' (from Keybone)
  494.     n = n + 1: TestData(n) = "101010101010101010101001010101010101001010111001010101010101010101010100010101010101010100101001010101001100101010001010100101010100101010100101010101010101010011011110010101010100100101010110010011001010011001010100010100101010010101010101010010101010101010010101001010101010100110010101010100101010101010011001001010100101010010101010100101010010101001010100101001010010101010111010100110011001010101010100110101001010101010100101001010111010101010101010100101001010101010010101010101001010101001010101001010100101010100101010010101010101001010101001010101010101001010101001010100101010101010010101010010010101010101010101010010100101010101001010100101001010101001111101010101010100101010110011001010101010101010110101010101101010101010100101010010101010010101010101101110010101001010101010110010100101010101001011010101010100110101010100101010010101010100101010101001010101010101001010101010011010101010101110110100101010111010101011011001011001010101001010101010101010101010011001010101010100101010101010101010010100101"
  495.     ' (from Keybone)
  496.     n = n + 1: TestData(n) = "0101110101100011010100101011001110001011001010001110101111010100111011100100101001010011110101101000101010001010101111001010111010101010100001010101000101101100101111101010010101110110111001000101000011010101010001001001001111101011101010100010110101110101100000101010101110111010100100100001110111100101011110101010001010001110010110111110110010101001001011101000101001011100011101000010101010101101010010110100101101000101111010101110111001010011101111010101000010101111100010101011110101011011110100001010110"
  497.     ' (from Loudar)
  498.     n = n + 1: TestData(n) = "1011001010010100100100110010101010101001010101010101011010010101001010101001010010100110101011010101010101011010101101010101010101010010110101010101100101010101010110101101011010010101010010100110101101001010110101011010010101101010110100101111010101010011011011010010110101010010110100101101010100101011010010101001010101010001011101011010010101011100111010010001101011110010011010001011100110101010010011010101001001010010000101010110001"
  499.     ' (from Luke)
  500.     n = n + 1: TestData(n) = "01100101001010001100001101101111011010010101010110110101001000001111001111110101000101111011010101111101010101101010101001010101011000010101010101001011010100110100110100110011010101010101110101010111111101011010100000001101111000010111000110111001000010100001101010110100000111101011111100001011001010110010110"
  501.     ' (from Sarafromct)
  502.     n = n + 1: TestData(n) = "10101010101011101000011101010111010101010101100111001010100111100001011011110101000001111010101101010000001111110011111110111101110111001110110010000100010101010101010100101011010110101010101010101001000000001111110000011110101010101010100010101110101010101101111111111111111111101010101010101000000"
  503.     ' (from Spriggs)
  504.     n = n + 1: TestData(n) = "10111010101010101010101001010101010101001010101001010101010101010101010101010101010101010101010101010101001010100100100101010101010101001010100101010101010100101010100101010101010101010101001010010110010101010010101010101010101010101010100101001001001010101010101010101010101001010101001001101010010"
  505.     ' (from Spriggs)
  506.     n = n + 1: TestData(n) = "11111011110100101011111111110100000011011110101100111100111111110111101110100111100110011111110101111111010111101111100111110111111111111011100111110111111110010000101011111001110101101010110111110"
  507.     ' (from Hotpants)
  508.     n = n + 1: TestData(n) = "01010100011001010010101010101010101000110101010111101010100100011010101010100100101110010010010100001010101001010101010110010001001011000100100110101001001001010000000001010101101111101001010100010101001001010101000100101001100100010011010101010101010111010010101011101011011010110100100010010100100100010010001001"
  509.  
  510.     LoadTestData = n
  511.  
Title: Re: Looking for old program or help recreating it
Post by: random1 on December 20, 2021, 09:22:22 pm
STxAxTIC

Very nice work.  One thing that really caught my attention was ranking the strings as to their
level of randomness.

I have two models I am currently working on.  The one I am interested in most is based on a
different type of data although the strings look very similar to those discussed so far. The idea
for this predictor is to first find the strings that show a high probability of being predictable and
process only those strings.  Second is to only take the (1) predictions.  If the prediction is 0 or ?
then toss it out.

This tool only processes 100 to 112 total strings and out of those I need the top 15 predicted 1's.
The more I study the linked information the more convinced I am that it may be possible.
       
Thanks again, again, this must be very time consuming on your end.  I will say that I am having
fun and learning at the same time.  Not many people would go to such extent, it is appreciated. 

R1   
Title: Re: Looking for old program or help recreating it
Post by: random1 on December 23, 2021, 02:50:51 am
Here is a older predictor that I rewrote for this topic.  This works a little similar to the
one STxAxTIC has posted.  This tool has no brains so to say and should be easy to
understand.  I attached a picture that shows the results and a second file which contains
the data string file.  You will notice some of the strings are all *****.  These are events
that are no longer collected but left in place to maintain the data structure.  These are
skipped by the dummy predictor.  Anyone willing can try to improve the overall hit rate
is very welcome.  I am most interested in bringing up the number of correct (1's) made
by the predictor.  The data file needs to be in the same directory as the program or one
could edit the code and add a full path to the open statement. 

Anyway, maybe some brains can be added to make it better.  This is the second of two
predictors I am working on.  The other is the one STxAxTIC posted.  My code is most likely
outdated, but I am old and set in my ways.

Code: QB64: [Select]
  1. Title1$ = "Predictor"
  2. _Title Title1$
  3. A& = _NewImage(400,200,32)
  4.  
  5. Dim PreDiction (1 to 112) as String
  6. Dim StrLen as Double
  7. Dim Match as Double
  8. Dim Count as Double
  9. PrintOn=1  '<- PrintSwitch
  10. StrLen=0  '0 = Use entire string
  11. Color _RGB32(255,255,0),_RGB32(0,0,0)
  12.  
  13. 'String feed from file
  14. Count=0:Match=0:Dud=0
  15. Open "tmp.txt" For Input as #1
  16. Line Input #1, Dat1$
  17. Dat1$=_trim$(Dat1$)
  18. If StrLen > 0 Then Dat1$=Mid$(Dat1$,1,StrLen)  '<- Control Panel Setting to control length of String
  19. Count=Count+1
  20. Goto GotString
  21. ReTurn1:
  22.  
  23. 'Print & exit code
  24. If PrintOn = 1 Then _printString (4,84), "Correct Predictions = " + _Trim$(Str$(Match))
  25. If PrintOn = 1 Then _PrintString (4,100), "Predictor Hit Rate = " + Mid$(_Trim$(Str$(Match/(112-Dud))),1,4) + "% of " + _Trim$(Str$(112-Dud))
  26. If PrintOn = 1 Then _PrintString (4,116), "Strings Not Processed = " + _Trim$(Str$(Dud))
  27. If PrintOn = 1 Then _PrintString (4,132), "Finished....."
  28. Color _RGB32(192,192,192),_RGB32(0,0,0)
  29. _PrintString (4,180), "Press any key to exit"
  30.  
  31. GotString:
  32. If Instr(Dat1$,"*") > 0 Then Dud=Dud+1
  33. If Instr(Dat1$,"*") > 0 Then Goto SkipString 'Skips invalid strings
  34. If PrintOn = 1 Then _PrintString (4, 2), "Analyzing String " + _Trim$(Str$(Count)) + " of 112"
  35. If PrintOn = 1 Then _PrintString (4,20), "Partial String = " + Mid$(Dat1$,1,30)
  36.  
  37. 'Dummy Prediction code Start's here
  38.  
  39. Cyc=4  '<-Control Panel Adjustable
  40. H0=0:H1=0
  41. NextCyc:
  42.  
  43. Pat0$="0"+Mid$(Dat1$,2,Cyc)
  44. Pat1$="1"+Mid$(Dat1$,2,Cyc)
  45.  
  46. L1=1
  47.   Do While L1 <= Len(Dat1$)-Len(Pat0$)
  48.       If Mid$(Dat1$,L1,Len(Pat0$)) = Pat0$ Then H0=H0+1
  49.       If Mid$(Dat1$,L1,Len(Pat1$)) = Pat1$ Then H1=H1+1
  50.      L1=L1+1
  51.   Loop
  52. Cyc=Cyc+1
  53. If Cyc <= 6 Then Goto NextCyc 'Control Panel adjustable
  54.  
  55. 'Dummy Prediction
  56. If H1 >= H0 Then PreDiction(Count)="1" Else PreDiction(Count)="0"
  57.  
  58. 'Counts and print stuff
  59. If PreDiction(Count) = Mid$(Dat1$,1,1) Then Match=Match+1
  60. If PrintOn = 1 then _PrintString (4,36), "Prediction = " + PreDiction(Count) + " "
  61. If Mid$(Dat1$,1,1) = PreDiction(Count) And Mid$(Dat1$,1,1) ="0" Then Hit0=Hit0+1
  62. If Mid$(Dat1$,1,1) = PreDiction(Count) And Mid$(Dat1$,1,1) ="1" Then Hit1=Hit1+1
  63. If PrintOn = 1 then _PrintString (4,52), "P-Match->(0) = " + _Trim$(Str$(Hit0))
  64. If PrintOn = 1 then _PrintString (4,68), "P-Match->(1) = " + _Trim$(Str$(Hit1))
  65. SkipString:
  66. Goto ReTurn1 'get next string
  67.  

R1
Title: Re: Looking for old program or help recreating it
Post by: STxAxTIC on December 23, 2021, 03:51:04 am
Hey r1,

Funny story about tonight - 'cause time felt about right - I was about to try to collect a few recent thoughts on this whole thing and make a new reply, but got sidetracked, only to refresh the forum and see you had the same idea but didn't get sidetracked - you managed to make a coherent post, unlike myself. Later on I'll split my brain and see what's going on inside your predictor, but first I wanted to give an update on what my code is up to. The code itself is pretty stable, but the way I now use it needs to be looked at.

Just some points for review:
(i) Predictions (as an unrounded decimal) are P = N (w(1)*g(1) + w(2)g(2) + ... + w(10)g(10))
(ii) N is a normalization constant
(iii) g(n) is the guess for alphabet size n
(iv) w(n) is the weight of that guess, a 0 or a 1

That stuff must be a thousand percent clear to proceed with me properly. When I say I  "use a model", or "choose a model", all that means is to choose w(n) for each n=1,2,...,10. For a stupid example, setting all w(n)=0 just makes every prediction 0. For another example, setting all w(n)=1 gives equal weight to all n guesses that contribute to the final prediction. Turning on or off various w(n) like light switches gives a different model.

Alright, so lately I've been cycling through all possible w(n) and testing on many kinds of input sequences, and am finding - rather verifying - a few results that I always had a hunch about. This is motivated by noticing that, for some reason, inputs made by human beings are very strong in the w(5)-range, but altogether absent in higher ranges. It's as if the random number generator inside a human is great at sputtering out chunks of 5 or even 7, but not flurries of 8 or 12. Kinda amazing. Certain contrived inputs, like regular patterns, complex patterns, drum beats, etc... are all resonant in various w(n) that make sense when you look at them, these are usually nice and low w(n) as well.

So let me do an example. Working with *only* the first string in the file you attached, namely:

Code: [Select]
S = 11000110100100010010000101001001000000000100010000001000011000000001010000000010010000000110011110000001110101100000001100000000000010100000100100111100001000011111100000010000100100000000001110000001100010000000000100000110000000000100000000010000110000100001000000000000001000110000011111111111111001110000011000001100000001101001000110001110000000010000001111000000000100000001110001001000000010010001001000000001000000000000000000110000010000001000001000010001000001000010111000000001100011100100000000100011000000000001100010000010000100000000000000001000000001010001100000001101000000000100000000000001000000000001110010001110010011001000000101000000110000000000001000000000101000110000000000000000001100000000000000
(I)
Let me use the model with w(1)=1, w(2)=1, etc, ... all w(n)=1. The perfectly averaged model, every frequency gets the same weight. Running this, I get a result of: 74%. Not bad! This mode always does a pretty good job.

(II)
To repeat the past, I can also use the w(n)=n^2 model. Remember that ole thing? This one gives an answer of: 69%. Yuck. Glad we updated the model since the n^2 days.

(III)
Okay, so can we do better than stab around randomly for a model? Yes. By systematically searching, I found the best results in the 533rd model (there may be a better one after 533 but I stopped the program there). Converting 533 to binary, this means the model is: w(1)=1, w(2)=0, w(3)=1, w(4)=0, w(5)=1, w(6)=0, w(7)=0, w(8)=0, w(9)=0, w(10)=1. Okay, so choosing this model 1010100001 and checking the result, we find a success rate of 76%, the highest yet!

So clearly it's worth stepping around in "weight space" for the best model for a given sequence. Humans have their own signature like 000010000. Simple "music" has its own, typically something like 0110000000. Whatever you used to come up with that first string in TMP.txt, there's something significant about 1010100001 when it comes to cracking it. This is all coming to a grand conclusion that says: sequence can be boiled down to a frequency fingerprint. Kinda like Fourier analysis.

Let me know if I'm lecturing to an empty classroom or if you get what I'm fiddling with here, thanks!
Title: Re: Looking for old program or help recreating it
Post by: random1 on December 23, 2021, 05:40:29 pm
STxAxTIC

I can't speak for others but as for me, I am following every word.  The code I posted is very
simple and all it does is this.  As the code is set now, it starts with the 4 most current entries
in the string, lets say 1001 for example, flow = right to left so the first 4 digits in the string.

Next it builds two search strings, Pat0$ and Pat1$.  Pat0$ = "0" + the first 4 digits 1001 and
Pat1$ = "1" + the first 4.

so Pat0$ = 01001 and Pat1$ = 11001

The program worms it's way through the entire string and every time it finds a match it counts
it, ie, Hit0 and Hit1 hold these counts.  Once it finishes the search it then increases the digits
taken from the main string by 1.  So the first cycle uses the first 4 digits in the string, the second
uses 5 and so on.  Both search patterns, ie, Pat0$ and Pat1$ are padded with a 0 or 1 to impose
the next prediction before it happens.  The next value update will equal one of the two search
patterns. 

The program does not reset the counters during the cycle phase.  The number of cycles can be set
to span any range but search strings with lengths of 5 to 7 seem to work best.  In the version I
used in my main program I was able to set the string length, the number of cycles, weights etc
as commented within the code.  These can be ignored, just placed there to indicate values that
can be adjusted.  Sometimes shorter string lengths work better but in my main tool the strings
can have as many as 5K entries.

The predictions are made based on if the counts for Pat1$ are >= the counts for Pat0$.  Very
simple tool.

Once it completes analysis on the string it then loads the next string and repeats the process. 

What it does in a sense, is it only uses the alphabets that coincide with the most recent events
of the string being analyzed, ie the first 4 to 6 plus a leading 0 or 1 to simulate the next event.

It's basically a brute force method that tries to find what happened's most often within the history.
I use the >= because (0's) often make up the majority of the string volume so anytime the total
ones reach or surpass the zero counts the prediction goes to 1.   The results in the posted code
store the predicted values in a array which is not needed here but is used within my program to
transfer predictions to the next stage in my main program.

Please don't think that I have left off working with your attempts, I have read the information
you provide in the link dozens of times.  I understand what your doing and hope you continue
working on it.  The strings I posted are just a subset of the total and a different method is used
in building these strings.  They are based on rather a value stays the same or changes.  Not a
big difference but they do seem to be more predictable.

The hardest thing for me in understanding and making edits to your code so that in fits into my
main program is the print stuff.  Not a biggie but every time you make changes I have to change
my edits also.  What I have done to deal with this until the final version is complete is to add the
load from file option, compile it then shell the program from my main program.  Makes keeping
up much easier.

In the end I hope to edit your code so that it fits seamlessly into my main program where the
only thing printed to screen are the progress bars.

I mentioned somewhere in the post the idea of using more than one prediction tool for each
string in hopes that combining outputs might give a more accurate prediction.  Sometimes
it's easier to built more than one tool to ease complexity and expand the final project.  I can't
begin to tell you the number of times a attempt got so complex I could not follow my own
code.     
 
Anyway,  Many thanks

R1
Title: Re: Looking for old program or help recreating it
Post by: random1 on December 23, 2021, 05:55:52 pm

The below pic shows added counters for the number of incorrect predictions made overall.
If anyone is interested I will post the updated code. 

R1

https://i.postimg.cc/q7jZfNCQ/p1-ps.png (https://i.postimg.cc/q7jZfNCQ/p1-ps.png)
Title: Re: Looking for old program or help recreating it
Post by: STxAxTIC on December 24, 2021, 12:14:13 pm
Yello r1,

I gave your program a closer look and your description really helped. Your method reminds me of a past thread - the stuff I was alluding to way back. Back a few pages ago when I was yelling for Steve and bplus to publicly remember working on a problem similar to this, it was because I remembered their solutions - and lo and behold - turns out yours is much like theirs. It'd say the algorithm you're using is viable for the question on hand, I've seen it work before for similar jobs.

What would be a fun exercise is to find the tuning in w(n)-space that makes my predictor say the same thing that yours does. And on that note, I can totally understand what you mean by saying my code has a whole mess of print statements and stuff. Let me peel that onion a little.

(I)
For anything to work at all, the "alphabets" arrays and the "weights" arrays must be defined. In cartoon code, this obviously looks like:

Code: QB64: [Select]
  1. Dim Shared Alphabet1(2) As LetterBin ' 0 1
  2. Dim Shared Alphabet2(4) As LetterBin ' 00 01 10 11
  3. Dim Shared Alphabet3(8) As LetterBin ' 000 001 010 011 100 101 110 111
  4. Dim Shared Alphabet4(16) As LetterBin ' etc.
  5. ...
  6. Alphabet1(1).Signature = "0"
  7. Alphabet1(2).Signature = "1"
  8. Call NewAlphabet(Alphabet1(), Alphabet2())
  9. Call NewAlphabet(Alphabet2(), Alphabet3())
  10. Call NewAlphabet(Alphabet3(), Alphabet4())
  11. ...
  12. Dim Shared AlphaWeight(1 To 13) As Double
  13.  

where weights are specified a few ways. My favorite being

Code: QB64: [Select]
  1. Call InitializeBinaryModel(BinaryModelIndex)

where BinaryModelIndex is an integer between 0 and 1023. This will convert to a 10-bit binary number that specifies w(n), as you already know.

(II)
Okay, with all that defined, it's ready for use. If you specify a sequence TheString = "00111011000011100100010100101" or whatever, all that's needed now is one function:

Analyze(TheString, AlphaWeight(), 0)

... but this is a function. So you want to print the output or store it in a varaible:

Code: QB64: [Select]
  1. GuessPredicted = Analyze(TheString, AlphaWeight(), 0)

Point is, all you do is specify is TheString, and Analyze gives you a 0 or a 1. Done and done. In my code, everything surrounding Analyze can be deleted - there need not be a main loop or anything else.

(III)

All that said, my actual code puts Analyze in like, 3 loops. This is because, in order to avoid version hell, I use one codebase that does every task in a unified way. Since that's becoming stable, I may shatter this finally into different files to keep it all more digestible. I'll in fact maybe do this - consider the ball still in my court.
Title: Re: Looking for old program or help recreating it
Post by: STxAxTIC on December 24, 2021, 03:47:09 pm
Hey R1,

Quick update on this... So I couldn't bring myself to fragment the code apart yet, I'm still a little busy making discoveries with it, so it's in research mode for the time being. One improvement I made is a way to load the data files you provide:

Code: QB64: [Select]
  1. ' Load test data from file or from sub.
  2.     ReDim _Preserve TestData(LoadTestFile(0, Command$(1), -1))
  3.     ReDim _Preserve TestData(LoadTestData(0))

The "-1" switch means the input string is stored backwards like your program prefers. I'll put the full code at the bottom. The way to use it right now: just compile the EXE and then drag+drop your file onto it. It will buzz through the whole thing swiftly, especially if you turn off the delays and limits. The model used is 0000101000 or something like that.

Some elaboration: There are two main loops in the program, (i) a routine that loops through each data sample while the model is fixed, or (ii) a routine that loops through each model while the sample is fixed. What is does *not* do so far is both at the same time. If all that is too crazy, fret not - Like I was saying, you can just delete around Analyze() until it's simple enough.

Speaking of simple enough, I want to look into turning your predictor into a function. That is, if I take your code, and insist on writing an analog to Analyze(), what does it look like? I'll spend a little while with it.

Code: QB64: [Select]
  1.  
  2. Screen _NewImage(120, 40)
  3.  
  4. ' Version: 22
  5.  
  6. Type LetterBin
  7.     Signature As String
  8.     Count As Integer
  9.  
  10. Dim Shared Alphabet1(2) As LetterBin ' 0 1
  11. Dim Shared Alphabet2(4) As LetterBin ' 00 01 10 11
  12. Dim Shared Alphabet3(8) As LetterBin ' 000 001 010 011 100 101 110 111
  13. Dim Shared Alphabet4(16) As LetterBin ' etc.
  14. Dim Shared Alphabet5(32) As LetterBin
  15. Dim Shared Alphabet6(64) As LetterBin
  16. Dim Shared Alphabet7(128) As LetterBin
  17. Dim Shared Alphabet8(256) As LetterBin
  18. Dim Shared Alphabet9(512) As LetterBin
  19. Dim Shared Alphabet10(1024) As LetterBin
  20. Dim Shared Alphabet11(2048) As LetterBin
  21. Dim Shared Alphabet12(4096) As LetterBin
  22. Dim Shared Alphabet13(8192) As LetterBin
  23.  
  24. Alphabet1(1).Signature = "0"
  25. Alphabet1(2).Signature = "1"
  26. Call NewAlphabet(Alphabet1(), Alphabet2())
  27. Call NewAlphabet(Alphabet2(), Alphabet3())
  28. Call NewAlphabet(Alphabet3(), Alphabet4())
  29. Call NewAlphabet(Alphabet4(), Alphabet5())
  30. Call NewAlphabet(Alphabet5(), Alphabet6())
  31. Call NewAlphabet(Alphabet6(), Alphabet7())
  32. Call NewAlphabet(Alphabet7(), Alphabet8())
  33. Call NewAlphabet(Alphabet8(), Alphabet9())
  34. Call NewAlphabet(Alphabet9(), Alphabet10())
  35. Call NewAlphabet(Alphabet10(), Alphabet11())
  36. Call NewAlphabet(Alphabet11(), Alphabet12())
  37. Call NewAlphabet(Alphabet12(), Alphabet13())
  38.  
  39. ' Specification of weight model.
  40. Dim Shared AlphaWeight(1 To 13) As Double
  41.  
  42. ' Array for test sequences.
  43. ReDim Shared TestData(10000) As String
  44.  
  45. ' Statistics and metrics:
  46. Dim GuessPredicted As Integer
  47. Dim GuessCorrect As Double
  48. Dim GuessTotal As Double
  49. Dim GuessRatioBest As Double
  50. Dim GuessStreak As Integer
  51. Dim GuessStreakMax As Integer
  52. Dim GuessStreakBest As Integer
  53. Dim Grade(10000, 2) As Double
  54. Dim BinaryModelIndex As Integer
  55. Dim BinaryModelBest As Integer
  56.  
  57. ' Working varaibles:
  58. Dim TheString As String
  59. Dim As Integer k, m, n
  60.  
  61. ' Load test data from file or from sub.
  62.     ReDim _Preserve TestData(LoadTestFile(0, Command$(1), -1))
  63.     ReDim _Preserve TestData(LoadTestData(0))
  64.  
  65. GuessRatioBest = 0
  66. GuessStreakBest = 0
  67.  
  68. ' This outter loop is for cycling through models.
  69. ' If models are manually set, this loop goes forever.
  70. BinaryModelIndex = -1
  71. Do While (BinaryModelIndex < 1024)
  72.  
  73.     '''
  74.     ' Automatic increment of model index number.
  75.     'BinaryModelIndex = BinaryModelIndex + 1
  76.     'Call InitializeIndexedModel(BinaryModelIndex)
  77.     '''
  78.  
  79.     '''
  80.     ' Manual setting of model number using one of two similar functions:
  81.     'Call InitializeIndexedModel(16)
  82.     Call InitializeBinaryModel("0000101000")
  83.     '''
  84.  
  85.     ' This enclosed loop is for looping through test strings.
  86.     For m = 1 To UBound(TestData)
  87.  
  88.         GuessPredicted = -1
  89.         GuessCorrect = 0
  90.         GuessTotal = 0
  91.         GuessStreak = 0
  92.         GuessStreakMax = 0
  93.  
  94.         ' This core loop goes through a test string at a rate of one bit per iteration.
  95.         ' For Gaming mode, this essentially becomes an infinite DO loop.
  96.         For n = 1 To Len(TestData(m)) '9999
  97.  
  98.             '''
  99.             ' Auto-feed Mode:
  100.             TheString = Left$(TestData(m), n)
  101.             '''
  102.  
  103.             '''
  104.             ' Gaming Mode:
  105.             'Call InitializeBinaryModel("0000101000")
  106.             'Cls
  107.             'Locate 1, 1
  108.             'Print "Press LEFT or RIGHT."
  109.             'k = 0
  110.             'Do: k = _KeyHit: Loop Until ((k = 19200) Or (k = 19712))
  111.             'Select Case k
  112.             '    Case 19200
  113.             '        TheString = TheString + "0"
  114.             '    Case 19712
  115.             '        TheString = TheString + "1"
  116.             'End Select
  117.             '_KeyClear
  118.             '''
  119.  
  120.             Cls
  121.             Color 7
  122.             Locate 1, 1
  123.             For k = 1 To _Width
  124.                 Print "_";
  125.             Next
  126.             Print "Model ("; _Trim$(Str$(BinaryModelIndex)); "):";
  127.             For k = 1 To 10 'UBound(AlphaWeight)
  128.                 Print AlphaWeight(k);
  129.             Next
  130.             Print
  131.             Print
  132.             Print "Sequence (length "; _Trim$(Str$(Len(TheString))); "):"
  133.             Print TheString;
  134.             Color 8
  135.             Print Right$(TestData(m), Len(TestData(m)) - n);
  136.             Color 7
  137.             Print
  138.  
  139.             ' Reconciliation
  140.             If (GuessPredicted <> -1) Then
  141.                 Print
  142.                 Print "I predicted "; _Trim$(Str$(GuessPredicted)); " and you typed "; Right$(TheString, 1); "."
  143.                 If (GuessPredicted = Val(Right$(TheString, 1))) Then
  144.                     Print "I am RIGHT this round."
  145.                     GuessCorrect = GuessCorrect + 1
  146.                     GuessStreak = GuessStreak + 1
  147.                     If (GuessStreak > GuessStreakMax) Then GuessStreakMax = GuessStreak
  148.                     Grade(n, 2) = 1
  149.                 Else
  150.                     Print "I am WRONG this round."
  151.                     GuessStreak = 0
  152.                     Grade(n, 2) = 0
  153.                 End If
  154.                 GuessTotal = GuessTotal + 1
  155.                 Grade(n, 1) = GuessCorrect / GuessTotal
  156.             End If
  157.  
  158.             If (GuessTotal > 0) Then
  159.                 Print
  160.                 Print "I'm on a "; _Trim$(Str$(GuessStreak)); "-round winning streak."
  161.                 Print "My best streak has been "; _Trim$(Str$(GuessStreakMax)); "."
  162.                 If (GuessTotal <> 0) Then
  163.                     Print "My correctness rate is "; _Trim$(Str$(Int(100 * GuessCorrect / GuessTotal))); "% in "; _Trim$(Str$(GuessTotal)); " guesses."
  164.                 End If
  165.             End If
  166.  
  167.             GuessPredicted = Analyze(TheString, AlphaWeight(), 0)
  168.  
  169.             Print
  170.             'Print "I have made a new prediction."
  171.             'Print "Press LEFT or RIGHT to test me."
  172.             'Print "The best performance has been model #"; _Trim$(Str$(BinaryModelBest)); ", rated "; _Trim$(Str$(Int(GuessRatioBest * 100))); "%, best streak of "; _Trim$(Str$(GuessStreakBest)); "."
  173.  
  174.             ' Draw bottom graph if there's enough room.
  175.             If (CsrLin <= 23) Then
  176.                 If (GuessTotal <> 0) Then
  177.                     Call PrintGraph(TheString, Grade())
  178.                 End If
  179.             End If
  180.  
  181.             _Display
  182.             _Delay .02
  183.             _Limit 240
  184.         Next
  185.  
  186.         If (GuessCorrect / GuessTotal > GuessRatioBest) Then
  187.             BinaryModelBest = BinaryModelIndex
  188.             GuessRatioBest = GuessCorrect / GuessTotal
  189.             GuessStreakBest = GuessStreakMax
  190.         End If
  191.  
  192.         _Delay 3
  193.     Next
  194.  
  195.  
  196.  
  197. Function Analyze (TheStringIn As String, arrweight() As Double, pswitch As Integer)
  198.     Dim TheReturn As Integer
  199.     Dim As Integer n
  200.     Dim As Double r, j, k
  201.     Dim StringPhase(UBound(arrweight)) As String
  202.     Dim Partialguess(LBound(arrweight) To UBound(arrweight), 2) As Double
  203.  
  204.     StringPhase(1) = TheStringIn
  205.     For n = 2 To UBound(StringPhase) ' Phase analysis.
  206.         StringPhase(n) = Right$(StringPhase(n - 1), Len(StringPhase(n - 1)) - 1) + Left$(StringPhase(n - 1), 1)
  207.     Next
  208.  
  209.     ' Initialize partial results.
  210.     For n = LBound(Partialguess) To UBound(Partialguess)
  211.         Partialguess(n, 1) = -999
  212.     Next
  213.  
  214.     If (pswitch = 1) Then
  215.         Print
  216.         For n = 1 To _Width
  217.             Print "-";
  218.         Next
  219.         Print
  220.     End If
  221.  
  222.     If (arrweight(1) <> 0) Then Call CreateHisto(StringPhase(), 1, Alphabet1())
  223.     If (arrweight(2) <> 0) Then Call CreateHisto(StringPhase(), 2, Alphabet2())
  224.     If (arrweight(3) <> 0) Then Call CreateHisto(StringPhase(), 3, Alphabet3())
  225.     If (arrweight(4) <> 0) Then Call CreateHisto(StringPhase(), 4, Alphabet4())
  226.     If (arrweight(5) <> 0) Then Call CreateHisto(StringPhase(), 5, Alphabet5())
  227.     If (arrweight(6) <> 0) Then Call CreateHisto(StringPhase(), 6, Alphabet6())
  228.     If (arrweight(7) <> 0) Then Call CreateHisto(StringPhase(), 7, Alphabet7())
  229.     If (arrweight(8) <> 0) Then Call CreateHisto(StringPhase(), 8, Alphabet8())
  230.     If (arrweight(9) <> 0) Then Call CreateHisto(StringPhase(), 9, Alphabet9())
  231.     If (arrweight(10) <> 0) Then Call CreateHisto(StringPhase(), 10, Alphabet10())
  232.     If (arrweight(11) <> 0) Then Call CreateHisto(StringPhase(), 11, Alphabet11())
  233.     If (arrweight(12) <> 0) Then Call CreateHisto(StringPhase(), 12, Alphabet12())
  234.     If (arrweight(13) <> 0) Then Call CreateHisto(StringPhase(), 13, Alphabet13())
  235.  
  236.     If (pswitch = 1) Then ' Set the last argument >=1 to print stats for that histogram.
  237.         If ((Len(TheStringIn) >= 1) And (arrweight(1) <> 0)) Then Call PrintHisto(Alphabet1(), 0)
  238.         If ((Len(TheStringIn) >= 2) And (arrweight(2) <> 0)) Then Call PrintHisto(Alphabet2(), 0)
  239.         If ((Len(TheStringIn) >= 3) And (arrweight(3) <> 0)) Then Call PrintHisto(Alphabet3(), 0)
  240.         If ((Len(TheStringIn) >= 4) And (arrweight(4) <> 0)) Then Call PrintHisto(Alphabet4(), 0)
  241.         If ((Len(TheStringIn) >= 5) And (arrweight(5) <> 0)) Then Call PrintHisto(Alphabet5(), 4)
  242.         If ((Len(TheStringIn) >= 6) And (arrweight(6) <> 0)) Then Call PrintHisto(Alphabet6(), 0)
  243.         If ((Len(TheStringIn) >= 7) And (arrweight(7) <> 0)) Then Call PrintHisto(Alphabet7(), 0)
  244.         If ((Len(TheStringIn) >= 8) And (arrweight(8) <> 0)) Then Call PrintHisto(Alphabet8(), 0)
  245.         If ((Len(TheStringIn) >= 9) And (arrweight(9) <> 0)) Then Call PrintHisto(Alphabet9(), 0)
  246.         If ((Len(TheStringIn) >= 10) And (arrweight(10) <> 0)) Then Call PrintHisto(Alphabet10(), 0)
  247.         If ((Len(TheStringIn) >= 11) And (arrweight(11) <> 0)) Then Call PrintHisto(Alphabet11(), 0)
  248.         If ((Len(TheStringIn) >= 12) And (arrweight(12) <> 0)) Then Call PrintHisto(Alphabet12(), 0)
  249.         If ((Len(TheStringIn) >= 13) And (arrweight(13) <> 0)) Then Call PrintHisto(Alphabet13(), 0)
  250.         Print
  251.     End If
  252.  
  253.     ' Set the last argument =1 to print guess for that histogram.
  254.     If ((Len(TheStringIn) >= 1) And (arrweight(1) <> 0)) Then Call MakeGuess(TheStringIn, 1, Alphabet1(), Partialguess(), 0)
  255.     If ((Len(TheStringIn) >= 2) And (arrweight(2) <> 0)) Then Call MakeGuess(TheStringIn, 2, Alphabet2(), Partialguess(), 0)
  256.     If ((Len(TheStringIn) >= 3) And (arrweight(3) <> 0)) Then Call MakeGuess(TheStringIn, 3, Alphabet3(), Partialguess(), 0)
  257.     If ((Len(TheStringIn) >= 4) And (arrweight(4) <> 0)) Then Call MakeGuess(TheStringIn, 4, Alphabet4(), Partialguess(), 0)
  258.     If ((Len(TheStringIn) >= 5) And (arrweight(5) <> 0)) Then Call MakeGuess(TheStringIn, 5, Alphabet5(), Partialguess(), pswitch)
  259.     If ((Len(TheStringIn) >= 6) And (arrweight(6) <> 0)) Then Call MakeGuess(TheStringIn, 6, Alphabet6(), Partialguess(), 0)
  260.     If ((Len(TheStringIn) >= 7) And (arrweight(7) <> 0)) Then Call MakeGuess(TheStringIn, 7, Alphabet7(), Partialguess(), 0)
  261.     If ((Len(TheStringIn) >= 8) And (arrweight(8) <> 0)) Then Call MakeGuess(TheStringIn, 8, Alphabet8(), Partialguess(), 0)
  262.     If ((Len(TheStringIn) >= 9) And (arrweight(9) <> 0)) Then Call MakeGuess(TheStringIn, 9, Alphabet9(), Partialguess(), 0)
  263.     If ((Len(TheStringIn) >= 10) And (arrweight(10) <> 0)) Then Call MakeGuess(TheStringIn, 10, Alphabet10(), Partialguess(), 0)
  264.     If ((Len(TheStringIn) >= 11) And (arrweight(11) <> 0)) Then Call MakeGuess(TheStringIn, 11, Alphabet11(), Partialguess(), 0)
  265.     If ((Len(TheStringIn) >= 12) And (arrweight(12) <> 0)) Then Call MakeGuess(TheStringIn, 12, Alphabet12(), Partialguess(), 0)
  266.     If ((Len(TheStringIn) >= 13) And (arrweight(13) <> 0)) Then Call MakeGuess(TheStringIn, 13, Alphabet13(), Partialguess(), 0)
  267.     If (pswitch = 1) Then Print
  268.  
  269.     If (pswitch = 1) Then
  270.         Print "Thinking:   ";
  271.         For k = LBound(Partialguess) To UBound(Partialguess)
  272.             If (Partialguess(k, 1) <> -999) Then
  273.                 Print Partialguess(k, 1);
  274.             Else
  275.                 Print "_ ";
  276.             End If
  277.         Next
  278.         Print
  279.     End If
  280.  
  281.     j = 0
  282.     r = 0
  283.  
  284.     ' Weighted average calculation
  285.     For k = UBound(Partialguess) To LBound(Partialguess) Step -1
  286.         If (Partialguess(k, 1) <> -999) Then
  287.             r = r + arrweight(k) * Partialguess(k, 1)
  288.             j = j + arrweight(k)
  289.         End If
  290.     Next
  291.     If (j <> 0) Then
  292.         r = r / j
  293.     End If
  294.  
  295.     If (pswitch = 1) Then Print "Predicting:  "; _Trim$(Str$(r))
  296.  
  297.     If (r > .5) Then
  298.         r = 1
  299.     Else
  300.         r = 0
  301.     End If
  302.  
  303.     If (pswitch = 1) Then
  304.         Print "Rounding to: "; _Trim$(Str$(r))
  305.     End If
  306.  
  307.     If (pswitch = 1) Then
  308.         For n = 1 To _Width
  309.             Print "-";
  310.         Next
  311.         Print
  312.     End If
  313.  
  314.     TheReturn = r
  315.     Analyze = TheReturn
  316.  
  317. Sub MakeGuess (TheStringIn As String, wid As Integer, arralpha() As LetterBin, arrguess() As Double, pswitch As Integer)
  318.     Dim TheReturn As Double
  319.     Dim As Integer j, k, n
  320.     TheReturn = 0
  321.     j = 1
  322.     k = 0
  323.     For n = 1 To UBound(arralpha)
  324.         If (Left$(arralpha(n).Signature, wid - 1) = Right$(TheStringIn, wid - 1)) Then
  325.             If (arralpha(n).Count >= j) Then
  326.                 If (pswitch = 1) Then Print "Order-"; Right$("0" + _Trim$(Str$(wid)), 2); " guess: "; arralpha(n).Signature; " . "; _Trim$(Str$(arralpha(n).Count))
  327.                 TheReturn = TheReturn + Val(Right$(arralpha(n).Signature, 1))
  328.                 k = k + 1
  329.                 j = arralpha(n).Count
  330.             End If
  331.         End If
  332.     Next
  333.     If (k <> 0) Then
  334.         TheReturn = TheReturn / k
  335.     Else
  336.         TheReturn = .5
  337.     End If
  338.     arrguess(wid, 1) = TheReturn
  339.     arrguess(wid, 2) = j
  340.  
  341. Sub InitializeIndexedModel (TheIndexIn As Integer)
  342.     '0 to 1023
  343.     Call InitializeBinaryModel(BIN$(TheIndexIn))
  344.  
  345. Sub InitializeBinaryModel (Weights As String)
  346.     Dim As Integer k
  347.     If (Weights = "-1") Then
  348.         For k = LBound(AlphaWeight) To UBound(AlphaWeight)
  349.             AlphaWeight(k) = k ^ 2
  350.         Next
  351.     Else
  352.         For k = 1 To 10
  353.             AlphaWeight(k) = Val(Mid$(Weights, k, 1))
  354.         Next
  355.         AlphaWeight(11) = 0
  356.         AlphaWeight(12) = 0
  357.         AlphaWeight(13) = 0
  358.     End If
  359.  
  360.     ' Taken from the Wiki. Ugliest function ever.
  361.     Dim As Integer max, i, msb
  362.     Dim As String b
  363.     max% = 8 * Len(n%) ': MSB% = 1   'uncomment for 16 (32 or 64) bit returns
  364.     For i = max% - 1 To 0 Step -1 'read as big-endian MSB to LSB
  365.         If (n% And 2 ^ i) Then msb% = 1: b$ = b$ + "1" Else If msb% Then b$ = b$ + "0"
  366.     Next
  367.     b$ = "0000000000" + b$
  368.     b$ = Right$(b$, 10)
  369.     If b$ = "" Then BIN$ = "0" Else BIN$ = b$ 'check for empty string
  370.  
  371. Sub CreateHisto (arrseqphase() As String, wid As Integer, arralpha() As LetterBin)
  372.     Dim As Integer j, k, n
  373.     For n = 1 To UBound(arralpha)
  374.         arralpha(n).Count = 0
  375.     Next
  376.     ' Uncomment this loop to enable phase analysis.
  377.     ' Hack j=1 to use base string only.
  378.     For j = 1 To 1 'wid
  379.         For k = 1 To Len(arrseqphase(j)) - (Len(arrseqphase(j)) Mod wid) Step wid
  380.             For n = 1 To UBound(arralpha)
  381.                 If (Mid$(arrseqphase(j), k, wid) = arralpha(n).Signature) Then
  382.                     arralpha(n).Count = arralpha(n).Count + 1
  383.                 End If
  384.             Next
  385.         Next
  386.     Next
  387.     Call QuickSort(arralpha(), 1, UBound(arralpha))
  388.  
  389. Sub PrintHisto (arr() As LetterBin, wid As Integer)
  390.     Dim As Integer j, n
  391.     If (wid > 0) Then
  392.         If (wid > UBound(arr)) Then
  393.             j = UBound(arr)
  394.         Else
  395.             j = wid
  396.         End If
  397.         Print "Histogram: "; _Trim$(Str$(UBound(arr))); "-letter regroup, showing top "; _Trim$(Str$(wid))
  398.         For n = 1 To j
  399.             Print arr(n).Signature; arr(n).Count
  400.         Next
  401.     End If
  402.  
  403. Sub PrintGraph (TheString As String, arrgrade() As Double)
  404.     Dim As Integer j, k
  405.     Dim As Double f, g
  406.     For k = 1 To _Width
  407.         Locate _Height - 5, k: Print "_"
  408.         Locate _Height - 5 - 10, k: Print "_"
  409.     Next
  410.     Locate _Height - 5 + 1, 1: Print "0%"
  411.     Locate _Height - 5 - 10 - 1, 1: Print "100%"
  412.     f = (_Width) / Len(TheString)
  413.     If (f > 1) Then f = 1
  414.     For j = 2 To Len(TheString)
  415.         g = Int(j * f)
  416.         If (g = 0) Then g = 1
  417.         Locate _Height - 5 - Int(10 * arrgrade(j, 1)), g
  418.         If (arrgrade(j, 2) = 1) Then
  419.             Print Chr$(251)
  420.         Else
  421.             Print "x"
  422.         End If
  423.     Next
  424.  
  425. Sub NewAlphabet (arrold() As LetterBin, arrnew() As LetterBin)
  426.     Dim As Integer j, k, n
  427.     n = 0
  428.     For k = 1 To 2
  429.         For j = 1 To UBound(arrold)
  430.             n = n + 1
  431.             arrnew(n).Signature = arrold(j).Signature
  432.         Next
  433.     Next
  434.     For j = 1 To UBound(arrnew)
  435.         If (j <= UBound(arrnew) / 2) Then
  436.             arrnew(j).Signature = "0" + arrnew(j).Signature
  437.         Else
  438.             arrnew(j).Signature = "1" + arrnew(j).Signature
  439.         End If
  440.     Next
  441.  
  442. Sub QuickSort (arr() As LetterBin, LowLimit As Long, HighLimit As Long)
  443.     Dim As Long piv
  444.     If (LowLimit < HighLimit) Then
  445.         piv = Partition(arr(), LowLimit, HighLimit)
  446.         Call QuickSort(arr(), LowLimit, piv - 1)
  447.         Call QuickSort(arr(), piv + 1, HighLimit)
  448.     End If
  449.  
  450. Function Partition (arr() As LetterBin, LowLimit As Long, HighLimit As Long)
  451.     Dim As Long i, j
  452.     Dim As Double pivot, tmp
  453.     pivot = arr(HighLimit).Count
  454.     i = LowLimit - 1
  455.     For j = LowLimit To HighLimit - 1
  456.         tmp = arr(j).Count - pivot
  457.         If (tmp >= 0) Then
  458.             i = i + 1
  459.             Swap arr(i), arr(j)
  460.         End If
  461.     Next
  462.     Swap arr(i + 1), arr(HighLimit)
  463.     Partition = i + 1
  464.  
  465. Function Pathological$ (TheSeed As String, TheLength As Integer)
  466.     Dim TheReturn As String
  467.     TheReturn = TheSeed
  468.     Dim p
  469.     Do
  470.         p = Analyze(TheReturn, AlphaWeight(), 0)
  471.         If (p = 1) Then
  472.             TheReturn = TheReturn + "0"
  473.         Else
  474.             TheReturn = TheReturn + "1"
  475.         End If
  476.     Loop Until Len(TheReturn) = TheLength
  477.     Pathological$ = TheReturn
  478.  
  479. Function LoadTestFile (alwayszero As Integer, TheFile As String, ReversalToggle As Integer)
  480.     Dim As Integer j, k
  481.     Dim n As Integer
  482.     Dim a As String
  483.     n = alwayszero
  484.     Open TheFile For Input As #1
  485.     Do While Not EOF(1)
  486.         n = n + 1
  487.         Line Input #1, a
  488.         TestData(n) = a
  489.     Loop
  490.     Close #1
  491.     If (ReversalToggle = -1) Then
  492.         For k = 1 To n
  493.             a = TestData(k)
  494.             TestData(k) = ""
  495.             For j = Len(a) To 1 Step -1
  496.                 TestData(k) = TestData(k) + Mid$(a, j, 1)
  497.             Next
  498.         Next
  499.     End If
  500.     LoadTestFile = n
  501.  
  502. Function LoadTestData (alwayszero As Integer)
  503.     Dim n As Integer
  504.     n = alwayszero
  505.  
  506.     '''
  507.     ' Percussive cases:
  508.     '''
  509.     n = n + 1: TestData(n) = "1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111"
  510.     n = n + 1: TestData(n) = "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
  511.     n = n + 1: TestData(n) = "0101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101"
  512.     n = n + 1: TestData(n) = "1010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010"
  513.     n = n + 1: TestData(n) = "0001110011000111001100011100110001110011000111001100011100110001110011000111001100011100110001110011000111001100011100110001110011000111001100011100110001110011"
  514.     n = n + 1: TestData(n) = "0100010111010001011101000101110100010111010001011101000101110100010111010001011101000101110100010111010001011101000101110100010111010001011101000101110100010111"
  515.  
  516.     '''
  517.     ' Human samples:
  518.     '''
  519.     ' (from Keybone)
  520.     n = n + 1: TestData(n) = "101010101010101010101001010101010101001010111001010101010101010101010100010101010101010100101001010101001100101010001010100101010100101010100101010101010101010011011110010101010100100101010110010011001010011001010100010100101010010101010101010010101010101010010101001010101010100110010101010100101010101010011001001010100101010010101010100101010010101001010100101001010010101010111010100110011001010101010100110101001010101010100101001010111010101010101010100101001010101010010101010101001010101001010101001010100101010100101010010101010101001010101001010101010101001010101001010100101010101010010101010010010101010101010101010010100101010101001010100101001010101001111101010101010100101010110011001010101010101010110101010101101010101010100101010010101010010101010101101110010101001010101010110010100101010101001011010101010100110101010100101010010101010100101010101001010101010101001010101010011010101010101110110100101010111010101011011001011001010101001010101010101010101010011001010101010100101010101010101010010100101"
  521.     ' (from Keybone)
  522.     n = n + 1: TestData(n) = "0101110101100011010100101011001110001011001010001110101111010100111011100100101001010011110101101000101010001010101111001010111010101010100001010101000101101100101111101010010101110110111001000101000011010101010001001001001111101011101010100010110101110101100000101010101110111010100100100001110111100101011110101010001010001110010110111110110010101001001011101000101001011100011101000010101010101101010010110100101101000101111010101110111001010011101111010101000010101111100010101011110101011011110100001010110"
  523.     ' (from Loudar)
  524.     n = n + 1: TestData(n) = "1011001010010100100100110010101010101001010101010101011010010101001010101001010010100110101011010101010101011010101101010101010101010010110101010101100101010101010110101101011010010101010010100110101101001010110101011010010101101010110100101111010101010011011011010010110101010010110100101101010100101011010010101001010101010001011101011010010101011100111010010001101011110010011010001011100110101010010011010101001001010010000101010110001"
  525.     ' (from Luke)
  526.     n = n + 1: TestData(n) = "01100101001010001100001101101111011010010101010110110101001000001111001111110101000101111011010101111101010101101010101001010101011000010101010101001011010100110100110100110011010101010101110101010111111101011010100000001101111000010111000110111001000010100001101010110100000111101011111100001011001010110010110"
  527.     ' (from Sarafromct)
  528.     n = n + 1: TestData(n) = "10101010101011101000011101010111010101010101100111001010100111100001011011110101000001111010101101010000001111110011111110111101110111001110110010000100010101010101010100101011010110101010101010101001000000001111110000011110101010101010100010101110101010101101111111111111111111101010101010101000000"
  529.     ' (from Spriggs)
  530.     n = n + 1: TestData(n) = "10111010101010101010101001010101010101001010101001010101010101010101010101010101010101010101010101010101001010100100100101010101010101001010100101010101010100101010100101010101010101010101001010010110010101010010101010101010101010101010100101001001001010101010101010101010101001010101001001101010010"
  531.     ' (from Spriggs)
  532.     n = n + 1: TestData(n) = "11111011110100101011111111110100000011011110101100111100111111110111101110100111100110011111110101111111010111101111100111110111111111111011100111110111111110010000101011111001110101101010110111110"
  533.     ' (from Hotpants)
  534.     n = n + 1: TestData(n) = "01010100011001010010101010101010101000110101010111101010100100011010101010100100101110010010010100001010101001010101010110010001001011000100100110101001001001010000000001010101101111101001010100010101001001010101000100101001100100010011010101010101010111010010101011101011011010110100100010010100100100010010001001"
  535.  
  536.     '''
  537.     ' Noted sequences:
  538.     '''
  539.     ' (Wolfram rule 30)
  540.     n = n + 1: TestData(n) = "110111001100010110010011101011100111010101100001100101011010101111110000111100010101110000010010110001110001101101101000000010001111101110100111000111010111000001100100011001111001111110000001111111011001011011100000101100011011000110001110110110010101111111011010110110111101110010111011000100000000001101110010110010111100100110000111110000001011011001111001000010011111000001101001011001001011101011000001101001000101001011101011111011000100000011110101000111101001011010001101000111100001000011110001111010"
  541.  
  542.     LoadTestData = n
  543.  
  544. ''' Museum:
  545. 'Call InitializeIndexedModel(BinaryModelIndex) ' Goes with counter
  546. 'Call InitializeIndexedModel(0)                ' Always zero
  547. 'Call InitializeIndexedModel(1023)             ' Homogeneous
  548. 'Call InitializeIndexedModel(16)               ' This 5-gram case (16) works best for Gaming mode.
  549. 'Call InitializeIndexedModel(82)               ' Learning algo discoverd this is a good one against humans.
  550. 'Call InitializeIndexedModel(18)               ' Learning algo discoverd this is a good one against humans.
  551. 'Call InitializeBinaryModel(-1)               ' Enables custom models.
  552. '''
  553.  
  554. '''
  555. ' Studies in pathology:
  556. 'BinaryModelIndex = 2   ' cracked by 124       0000000010 0001111100
  557. 'BinaryModelIndex = 3   ' cracked by 16        0000000011 0000010000
  558. 'BinaryModelIndex = 4   ' cracked by 265       0000000100 0100001001
  559. 'BinaryModelIndex = 5   ' cracked by 736       0000000101 1011100000
  560. 'BinaryModelIndex = 6   ' cracked by 49        0000000110 0000110001
  561. 'BinaryModelIndex = 7   ' cracked by 88        0000000111 0001011000
  562. 'BinaryModelIndex = 8   ' cracked by xxx       0000001000 lambda=16
  563. 'BinaryModelIndex = 9   ' cracked by xxx       0000001001 xxx
  564. 'BinaryModelIndex = 10  ' cracked by 644       0000001010 1010000100
  565. 'BinaryModelIndex = 11  ' cracked by 261       0000001011 0100000101
  566. '''
  567.  
Title: Re: Looking for old program or help recreating it
Post by: random1 on December 24, 2021, 05:53:09 pm
STxAxTIC

I think were going to need a smarter more inclusive method to reach the level of prediction
I need to call it a success.  The project thus far has already surpassed my expectations but
it seems the goal post has been moved.  Maybe chasing such expectations will turn into a
fool's errand but I can't stop thinking it's achievable.

I have a old predictor, even older then the dummy tool I posted earlier.  I will try to explain
it and maybe it will spark your interest.  It often averaged over 80% overall but I hit a wall so
to say and I was never able to improve it past a certain point.  Here is a rundown on how it
worked.

1st.  Count the overall number of 0's and 1's within the string being processed and calculate
        a hit ratio for both 0 and 1.
     
2nd.  Set a search string length, normally around 6 to 15 but could be much larger if needed.

3rd. Generate a random value between 1 and Len(dat1$), ie, of main string.

4th. A sample is then collected starting at rng value and extending to the length set in step 2

5th. Do a simple count for both 0's and 1's within the randomly collected sample.

6th.  A ratio is then calculated for the random sample.  This ratio is compared against the full
       string ratio and averaged to give a means to calculate the final guess in the 8th, 9th steps.

7th.  The program would be set to collect around 350 to 500 of these samples before making
        the guess / prediction. 

8th. The final step would be to count starting with the leftmost digit in the string to the value
       set in step 2 minus 1.  If the value in step 2 is set to 15 then count the first 14 as we will
       be adding either a 0 or a 1 in the final prediction.

9th.  The guess is made by first adding a digit 0 to the 14 and seeing how well it matches the
        overall ratio and the samples ratio.  Then do the same thing and replace the added 0 with
        a 1 and check again.       

The idea is to first get the ratios for the overall and the random samples, then apply those ratios
to the 14 most current list of digits in the main string.  Lets say the overall sample is something
like 35/65 and the random samples produce a ratio of 40/60 and the counts for the last 14 events
equals something like 33/67. This is then used to make the final guess /prediction.

The random samples give us a good understanding of how many times each digit should appear
within a certain length of sample size.  This is where I got stuck as a simple average is not enough
to make a good prediction.  Maybe creating a lower/upper threshold would add a fine tuning element
to the mix.

Anyway I was thinking you might be able to tinker with it by adding running averages, weights etc
to improve the overall accuracy.  I can post or attach the cartoon code if your interested. 

P.S.
This will be my last post until maybe Monday evening, family coming for Christmas.

Thanks again

R1 
   

Title: Re: Looking for old program or help recreating it
Post by: STxAxTIC on December 28, 2021, 12:16:45 pm
Hey R1

Hope Christmas wasn't too exhausting! I just re-skimmed your nicely-detailed list of steps above, and I think I know what you were getting at. In fact, in some form or another, it sounds a lot like what I'm doing in some places. The way you make the final prediction by asking (qualitatively) "which familiar pattern was the sequence almost finished making?" is exactly what I do. The way we get to that question of course is different. (Insert all that "alphabet" mumbo jumbo I use.)

The reason I break radio silence today is to show a systematic way of improving correctness rates, plus show a few numbers. It's all about fitting the best model to the data, like ordinary curve fitting, but we're stepping through binary models. For every sample sequence tested, this new "stepping" method finds a better model than the one(s) we were assuming by hand. It's definitely a proof that the machine is always more precise than the person when it comes to looking for patterns, haha.

This new kind of analysis completes a good circuit in computation space. The final guess is informed by (i) patterns across all frequencies (alphabet sizes) from 1 to any limit, (ii) all possible ways of guessing the answer, assuming binary models. One next branch of research is nonbinary models, letting w(n) vary as some kind of function. This would be a brain-exploding amount of work to do *perfectly* right, but it can be messed with kinda easily. I drafted (in my usual non-spellchecked Notepad style) to demonstrate things. (Still incomplete but nontrivial.) http://barnes.x10host.com/pages/Binary-Analyzer/Binary-Analyzer-Two.php (http://barnes.x10host.com/pages/Binary-Analyzer/Binary-Analyzer-Two.php)

Just to get back on a familiar track, are there any (new or old) test strings you have in mind that are particularly hard to crack?




Code as of now:

Code: QB64: [Select]
  1.  
  2. _Title "Binary Analyzer"
  3.  
  4. Screen _NewImage(120, 40)
  5.  
  6. ' Version: 22
  7.  
  8. Type LetterBin
  9.     Signature As String
  10.     Count As Integer
  11.  
  12. Dim Shared Alphabet1(2) As LetterBin ' 0 1
  13. Dim Shared Alphabet2(4) As LetterBin ' 00 01 10 11
  14. Dim Shared Alphabet3(8) As LetterBin ' 000 001 010 011 100 101 110 111
  15. Dim Shared Alphabet4(16) As LetterBin ' etc.
  16. Dim Shared Alphabet5(32) As LetterBin
  17. Dim Shared Alphabet6(64) As LetterBin
  18. Dim Shared Alphabet7(128) As LetterBin
  19. Dim Shared Alphabet8(256) As LetterBin
  20. Dim Shared Alphabet9(512) As LetterBin
  21. Dim Shared Alphabet10(1024) As LetterBin
  22. Dim Shared Alphabet11(2048) As LetterBin
  23. Dim Shared Alphabet12(4096) As LetterBin
  24. Dim Shared Alphabet13(8192) As LetterBin
  25.  
  26. Alphabet1(1).Signature = "0"
  27. Alphabet1(2).Signature = "1"
  28. Call NewAlphabet(Alphabet1(), Alphabet2())
  29. Call NewAlphabet(Alphabet2(), Alphabet3())
  30. Call NewAlphabet(Alphabet3(), Alphabet4())
  31. Call NewAlphabet(Alphabet4(), Alphabet5())
  32. Call NewAlphabet(Alphabet5(), Alphabet6())
  33. Call NewAlphabet(Alphabet6(), Alphabet7())
  34. Call NewAlphabet(Alphabet7(), Alphabet8())
  35. Call NewAlphabet(Alphabet8(), Alphabet9())
  36. Call NewAlphabet(Alphabet9(), Alphabet10())
  37. Call NewAlphabet(Alphabet10(), Alphabet11())
  38. Call NewAlphabet(Alphabet11(), Alphabet12())
  39. Call NewAlphabet(Alphabet12(), Alphabet13())
  40.  
  41. ' Specification of weight model.
  42. Dim Shared AlphaWeight(1 To 13) As Double
  43.  
  44. ' Array for test sequences.
  45. ReDim Shared TestData(256 ^ 2) As String
  46.  
  47. ' Statistics and metrics:
  48. Dim GuessPredicted As Integer
  49. Dim GuessCorrect As Double
  50. Dim GuessTotal As Double
  51. Dim GuessRatioBest As Double
  52. Dim GuessRatioWorst As Double
  53. Dim GuessStreak As Integer
  54. Dim GuessStreakMax As Integer
  55. Dim GuessStreakBest As Integer
  56. Dim Grade(256 ^ 2, 2) As Double
  57. Dim BinaryModelIndex As Integer
  58. Dim BinaryModelBest As Integer
  59. Dim BinaryModelWorst As Integer
  60.  
  61. ' Working varaibles:
  62. Dim TheString As String
  63. Dim As Integer k, m, n
  64.  
  65. ' Load test data from file or from sub.
  66.     ReDim _Preserve TestData(LoadTestFile(0, Command$(1), -1))
  67.     ReDim _Preserve TestData(LoadTestData(0))
  68.  
  69. GuessRatioBest = 0
  70. GuessRatioWorst = 1
  71. GuessStreakBest = 0
  72. BinaryModelWorst = 1
  73.  
  74. '''
  75. ' Play area:
  76. 'Call InitializeModelLiteral("0010101000")
  77. 'Call InitializeModelCustom("-1")
  78. 'Call InitializeModelIndexed(84)
  79. 'TestData(1) = Pathological$("1", 1000)
  80. 'TestData(1) = QBPRNG$(Timer, 1000)
  81. n = 1: TestData(n) = "1011001010010100100100110010101010101001010101010101011010010101001010101001010010100110101011010101010101011010101101010101010101010010110101010101100101010101010110101101011010010101010010100110101101001010110101011010010101101010110100101111010101010011011011010010110101010010110100101101010100101011010010101001010101010001011101011010010101011100111010010001101011110010011010001011100110101010010011010101001001010010000101010110001"
  82. ReDim _Preserve TestData(1)
  83. 'Open "output.txt" For Output As #1
  84. 'Print #1, TestData(1)
  85. 'Close #1
  86. '''
  87.  
  88. ' This outer loop is for cycling through models.
  89. ' If models are manually set, this loop goes forever.
  90. BinaryModelIndex = -1
  91. Do While (BinaryModelIndex < 1024)
  92.  
  93.     '''
  94.     ' Automatic increment of model index number.
  95.     BinaryModelIndex = BinaryModelIndex + 1
  96.     Call InitializeModelIndexed(BinaryModelIndex)
  97.     '''
  98.  
  99.     '''
  100.     ' Manual setting of model number using either of two similar functions:
  101.     'Call InitializeModelIndexed(16)
  102.     'Call InitializeModelLiteral("0010100000")
  103.     'Call InitializeModelCustom("-1")
  104.     '''
  105.  
  106.     ' This enclosed loop is for looping through test strings.
  107.     For m = 1 To UBound(TestData)
  108.  
  109.         GuessPredicted = -1
  110.         GuessCorrect = 0
  111.         GuessTotal = 0
  112.         GuessStreak = 0
  113.         GuessStreakMax = 0
  114.  
  115.         ' This core loop goes through a test string at a rate of one bit per iteration.
  116.         ' For Gaming mode, this essentially becomes an infinite DO loop.
  117.         For n = 1 To Len(TestData(m)) '9999
  118.  
  119.             '''
  120.             ' Auto-feed Mode:
  121.             TheString = Left$(TestData(m), n)
  122.             '''
  123.  
  124.             '''
  125.             ' Gaming Mode:
  126.             'Call InitializeModelLiteral("0000101000")
  127.             'Cls
  128.             'Locate 1, 1
  129.             'Print "Press LEFT or RIGHT."
  130.             'k = 0
  131.             'Do: k = _KeyHit: Loop Until ((k = 19200) Or (k = 19712))
  132.             'Select Case k
  133.             '    Case 19200
  134.             '        TheString = TheString + "0"
  135.             '    Case 19712
  136.             '        TheString = TheString + "1"
  137.             'End Select
  138.             '_KeyClear
  139.             '''
  140.  
  141.             Cls
  142.             Color 7
  143.             Locate 1, 1
  144.             For k = 1 To _Width
  145.                 Print "_";
  146.             Next
  147.             Print "Model ("; _Trim$(Str$(BinaryModelIndex)); "):";
  148.             For k = 1 To 10 'UBound(AlphaWeight)
  149.                 Print AlphaWeight(k);
  150.             Next
  151.             Print
  152.             Print
  153.             Print "Sequence (length "; _Trim$(Str$(Len(TheString))); "):"
  154.             Print Right$(TheString, 400);
  155.             Color 8
  156.             Print Left$(Right$(TestData(m), Len(TestData(m)) - n), 400);
  157.             Color 7
  158.             Print
  159.  
  160.             ' Reconciliation
  161.             If (GuessPredicted <> -1) Then
  162.                 Print
  163.                 Print "I predicted "; _Trim$(Str$(GuessPredicted)); " and you typed "; Right$(TheString, 1); "."
  164.                 If (GuessPredicted = Val(Right$(TheString, 1))) Then
  165.                     Print "I am RIGHT this round."
  166.                     GuessCorrect = GuessCorrect + 1
  167.                     GuessStreak = GuessStreak + 1
  168.                     If (GuessStreak > GuessStreakMax) Then GuessStreakMax = GuessStreak
  169.                     Grade(n, 2) = 1
  170.                 Else
  171.                     Print "I am WRONG this round."
  172.                     GuessStreak = 0
  173.                     Grade(n, 2) = 0
  174.                 End If
  175.                 GuessTotal = GuessTotal + 1
  176.                 Grade(n, 1) = GuessCorrect / GuessTotal
  177.             End If
  178.  
  179.             If (GuessTotal > 0) Then
  180.                 Print
  181.                 Print "I'm on a "; _Trim$(Str$(GuessStreak)); "-round winning streak."
  182.                 Print "My best streak has been "; _Trim$(Str$(GuessStreakMax)); "."
  183.                 If (GuessTotal <> 0) Then
  184.                     Print "My correctness rate is "; _Trim$(Str$(Int(100 * GuessCorrect / GuessTotal))); "% in "; _Trim$(Str$(GuessTotal)); " trials."
  185.                 End If
  186.             End If
  187.  
  188.             GuessPredicted = Analyze(TheString, AlphaWeight(), 0)
  189.  
  190.             '''
  191.             ' Reverse polarity if needed for any reason.
  192.             'If (GuessPredicted = 0) Then
  193.             '    GuessPredicted = 1
  194.             'Else
  195.             '    GuessPredicted = 0
  196.             'End If
  197.             '''
  198.  
  199.             Print
  200.             'Print "I have made a new prediction."
  201.             'Print "Press LEFT or RIGHT to test me."
  202.             Print "The best performance has been model #"; _Trim$(Str$(BinaryModelBest)); ", rated "; _Trim$(Str$(Int(GuessRatioBest * 100))); "%, best streak of "; _Trim$(Str$(GuessStreakBest)); "."
  203.             Print "The worst performance has been model #"; _Trim$(Str$(BinaryModelWorst)); ", rated "; _Trim$(Str$(Int(GuessRatioWorst * 100))); "%."
  204.  
  205.             ' Draw bottom graph if there's enough room.
  206.             If (CsrLin <= 23) Then
  207.                 If (GuessTotal <> 0) Then
  208.                     Call PrintGraph(TheString, Grade())
  209.                 End If
  210.             End If
  211.  
  212.             _Display
  213.             _Delay .02
  214.             _Limit 240
  215.         Next
  216.  
  217.         If (GuessTotal > 0) Then
  218.             If (GuessCorrect / GuessTotal >= GuessRatioBest) Then
  219.                 BinaryModelBest = BinaryModelIndex
  220.                 GuessRatioBest = GuessCorrect / GuessTotal
  221.                 GuessStreakBest = GuessStreakMax
  222.                 'Open "output.txt" For Append As #1
  223.                 'Print #1, BinaryModelBest, GuessRatioBest, GuessStreakBest
  224.                 'Close #1
  225.             End If
  226.             If (GuessCorrect / GuessTotal <= GuessRatioWorst) Then
  227.                 BinaryModelWorst = BinaryModelIndex
  228.                 GuessRatioWorst = GuessCorrect / GuessTotal
  229.             End If
  230.  
  231.         End If
  232.  
  233.         _Delay 3
  234.     Next
  235.  
  236.  
  237.  
  238. Function Analyze (TheStringIn As String, arrweight() As Double, pswitch As Integer)
  239.     Dim TheReturn As Integer
  240.     Dim As Integer n
  241.     Dim As Double r, j, k
  242.     Dim StringPhase(UBound(arrweight)) As String
  243.     Dim Partialguess(LBound(arrweight) To UBound(arrweight), 2) As Double
  244.  
  245.     StringPhase(1) = TheStringIn
  246.     For n = 2 To UBound(StringPhase) ' Phase analysis.
  247.         StringPhase(n) = Right$(StringPhase(n - 1), Len(StringPhase(n - 1)) - 1) + Left$(StringPhase(n - 1), 1)
  248.     Next
  249.  
  250.     If (pswitch = 1) Then
  251.         Print
  252.         For n = 1 To _Width
  253.             Print "-";
  254.         Next
  255.         Print
  256.     End If
  257.  
  258.     If (arrweight(1) <> 0) Then Call CreateHisto(StringPhase(), 1, Alphabet1())
  259.     If (arrweight(2) <> 0) Then Call CreateHisto(StringPhase(), 2, Alphabet2())
  260.     If (arrweight(3) <> 0) Then Call CreateHisto(StringPhase(), 3, Alphabet3())
  261.     If (arrweight(4) <> 0) Then Call CreateHisto(StringPhase(), 4, Alphabet4())
  262.     If (arrweight(5) <> 0) Then Call CreateHisto(StringPhase(), 5, Alphabet5())
  263.     If (arrweight(6) <> 0) Then Call CreateHisto(StringPhase(), 6, Alphabet6())
  264.     If (arrweight(7) <> 0) Then Call CreateHisto(StringPhase(), 7, Alphabet7())
  265.     If (arrweight(8) <> 0) Then Call CreateHisto(StringPhase(), 8, Alphabet8())
  266.     If (arrweight(9) <> 0) Then Call CreateHisto(StringPhase(), 9, Alphabet9())
  267.     If (arrweight(10) <> 0) Then Call CreateHisto(StringPhase(), 10, Alphabet10())
  268.     If (arrweight(11) <> 0) Then Call CreateHisto(StringPhase(), 11, Alphabet11())
  269.     If (arrweight(12) <> 0) Then Call CreateHisto(StringPhase(), 12, Alphabet12())
  270.     If (arrweight(13) <> 0) Then Call CreateHisto(StringPhase(), 13, Alphabet13())
  271.  
  272.     If (pswitch = 1) Then ' Set the last argument >=1 to print stats for that histogram.
  273.         If ((Len(TheStringIn) >= 1) And (arrweight(1) <> 0)) Then Call PrintHisto(Alphabet1(), 0)
  274.         If ((Len(TheStringIn) >= 2) And (arrweight(2) <> 0)) Then Call PrintHisto(Alphabet2(), 0)
  275.         If ((Len(TheStringIn) >= 3) And (arrweight(3) <> 0)) Then Call PrintHisto(Alphabet3(), 0)
  276.         If ((Len(TheStringIn) >= 4) And (arrweight(4) <> 0)) Then Call PrintHisto(Alphabet4(), 0)
  277.         If ((Len(TheStringIn) >= 5) And (arrweight(5) <> 0)) Then Call PrintHisto(Alphabet5(), 4)
  278.         If ((Len(TheStringIn) >= 6) And (arrweight(6) <> 0)) Then Call PrintHisto(Alphabet6(), 0)
  279.         If ((Len(TheStringIn) >= 7) And (arrweight(7) <> 0)) Then Call PrintHisto(Alphabet7(), 0)
  280.         If ((Len(TheStringIn) >= 8) And (arrweight(8) <> 0)) Then Call PrintHisto(Alphabet8(), 0)
  281.         If ((Len(TheStringIn) >= 9) And (arrweight(9) <> 0)) Then Call PrintHisto(Alphabet9(), 0)
  282.         If ((Len(TheStringIn) >= 10) And (arrweight(10) <> 0)) Then Call PrintHisto(Alphabet10(), 0)
  283.         If ((Len(TheStringIn) >= 11) And (arrweight(11) <> 0)) Then Call PrintHisto(Alphabet11(), 0)
  284.         If ((Len(TheStringIn) >= 12) And (arrweight(12) <> 0)) Then Call PrintHisto(Alphabet12(), 0)
  285.         If ((Len(TheStringIn) >= 13) And (arrweight(13) <> 0)) Then Call PrintHisto(Alphabet13(), 0)
  286.         Print
  287.     End If
  288.  
  289.     ' Set the last argument =1 to print guess for that histogram.
  290.     If ((Len(TheStringIn) >= 1) And (arrweight(1) <> 0)) Then Call MakeGuess(TheStringIn, 1, Alphabet1(), Partialguess(), 0)
  291.     If ((Len(TheStringIn) >= 2) And (arrweight(2) <> 0)) Then Call MakeGuess(TheStringIn, 2, Alphabet2(), Partialguess(), 0)
  292.     If ((Len(TheStringIn) >= 3) And (arrweight(3) <> 0)) Then Call MakeGuess(TheStringIn, 3, Alphabet3(), Partialguess(), 0)
  293.     If ((Len(TheStringIn) >= 4) And (arrweight(4) <> 0)) Then Call MakeGuess(TheStringIn, 4, Alphabet4(), Partialguess(), 0)
  294.     If ((Len(TheStringIn) >= 5) And (arrweight(5) <> 0)) Then Call MakeGuess(TheStringIn, 5, Alphabet5(), Partialguess(), pswitch)
  295.     If ((Len(TheStringIn) >= 6) And (arrweight(6) <> 0)) Then Call MakeGuess(TheStringIn, 6, Alphabet6(), Partialguess(), 0)
  296.     If ((Len(TheStringIn) >= 7) And (arrweight(7) <> 0)) Then Call MakeGuess(TheStringIn, 7, Alphabet7(), Partialguess(), 0)
  297.     If ((Len(TheStringIn) >= 8) And (arrweight(8) <> 0)) Then Call MakeGuess(TheStringIn, 8, Alphabet8(), Partialguess(), 0)
  298.     If ((Len(TheStringIn) >= 9) And (arrweight(9) <> 0)) Then Call MakeGuess(TheStringIn, 9, Alphabet9(), Partialguess(), 0)
  299.     If ((Len(TheStringIn) >= 10) And (arrweight(10) <> 0)) Then Call MakeGuess(TheStringIn, 10, Alphabet10(), Partialguess(), 0)
  300.     If ((Len(TheStringIn) >= 11) And (arrweight(11) <> 0)) Then Call MakeGuess(TheStringIn, 11, Alphabet11(), Partialguess(), 0)
  301.     If ((Len(TheStringIn) >= 12) And (arrweight(12) <> 0)) Then Call MakeGuess(TheStringIn, 12, Alphabet12(), Partialguess(), 0)
  302.     If ((Len(TheStringIn) >= 13) And (arrweight(13) <> 0)) Then Call MakeGuess(TheStringIn, 13, Alphabet13(), Partialguess(), 0)
  303.     If (pswitch = 1) Then Print
  304.  
  305.     If (pswitch = 1) Then
  306.         Print "Thinking:   ";
  307.         For k = LBound(Partialguess) To UBound(Partialguess)
  308.             If ((Len(TheStringIn) >= k) And (arrweight(k) <> 0)) Then
  309.                 Print Partialguess(k, 1);
  310.             Else
  311.                 Print "_ ";
  312.             End If
  313.         Next
  314.         Print
  315.     End If
  316.  
  317.     j = 0
  318.     r = 0
  319.  
  320.     ' Weighted average calculation
  321.     For k = LBound(Partialguess) To UBound(Partialguess)
  322.         If ((Len(TheStringIn) >= k) And (arrweight(k) <> 0)) Then
  323.             r = r + arrweight(k) * Partialguess(k, 1)
  324.             j = j + arrweight(k)
  325.         End If
  326.     Next
  327.     If (j <> 0) Then
  328.         r = r / j
  329.     End If
  330.  
  331.     If (pswitch = 1) Then Print "Predicting:  "; _Trim$(Str$(r))
  332.  
  333.     If (r > .5) Then
  334.         r = 1
  335.     Else
  336.         r = 0
  337.     End If
  338.  
  339.     If (pswitch = 1) Then
  340.         Print "Rounding to: "; _Trim$(Str$(r))
  341.     End If
  342.  
  343.     If (pswitch = 1) Then
  344.         For n = 1 To _Width
  345.             Print "-";
  346.         Next
  347.         Print
  348.     End If
  349.  
  350.     TheReturn = r
  351.     Analyze = TheReturn
  352.  
  353. Sub MakeGuess (TheStringIn As String, wid As Integer, arralpha() As LetterBin, arrguess() As Double, pswitch As Integer)
  354.     Dim TheReturn As Double
  355.     Dim As Integer j, k, n
  356.     TheReturn = 0
  357.     j = 1
  358.     k = 0
  359.     For n = 1 To UBound(arralpha)
  360.         If (Left$(arralpha(n).Signature, wid - 1) = Right$(TheStringIn, wid - 1)) Then
  361.             If (arralpha(n).Count >= j) Then
  362.                 If (pswitch = 1) Then Print "Order-"; Right$("0" + _Trim$(Str$(wid)), 2); " guess: "; arralpha(n).Signature; " . "; _Trim$(Str$(arralpha(n).Count))
  363.                 TheReturn = TheReturn + Val(Right$(arralpha(n).Signature, 1))
  364.                 k = k + 1
  365.                 j = arralpha(n).Count
  366.             End If
  367.         End If
  368.     Next
  369.     If (k <> 0) Then
  370.         TheReturn = TheReturn / k
  371.     Else
  372.         TheReturn = .5
  373.     End If
  374.     arrguess(wid, 1) = TheReturn
  375.     arrguess(wid, 2) = j
  376.  
  377. Sub InitializeModelIndexed (TheIndexIn As Integer)
  378.     '0 to 1023
  379.     Call InitializeModelLiteral(BIN$(TheIndexIn))
  380.  
  381. Sub InitializeModelLiteral (Weights As String)
  382.     Dim As Integer k
  383.     For k = 1 To 10
  384.         AlphaWeight(k) = Val(Mid$(Weights, k, 1))
  385.     Next
  386.     AlphaWeight(11) = 0
  387.     AlphaWeight(12) = 0
  388.     AlphaWeight(13) = 0
  389.  
  390. Sub InitializeModelCustom (Weights As String)
  391.     Dim As Integer k
  392.     If (Weights = "-1") Then
  393.         For k = LBound(AlphaWeight) To UBound(AlphaWeight)
  394.             AlphaWeight(k) = k ^ 2
  395.         Next
  396.     End If
  397.     AlphaWeight(11) = 0
  398.     AlphaWeight(12) = 0
  399.     AlphaWeight(13) = 0
  400.  
  401.     ' Butchered from the Wiki. Ugliest function ever.
  402.     Dim As Integer max, i, msb
  403.     Dim As String b
  404.     max% = 8 * Len(n%)
  405.     For i = max% - 1 To 0 Step -1
  406.         If (n% And 2 ^ i) Then msb% = 1: b$ = "1" + b$ Else If msb% Then b$ = "0" + b$
  407.     Next
  408.     b$ = b$ + "0000000000"
  409.     b$ = Left$(b$, 10)
  410.     BIN$ = b$
  411.  
  412. Sub CreateHisto (arrseqphase() As String, wid As Integer, arralpha() As LetterBin)
  413.     Dim As Integer j, k, n
  414.     For n = 1 To UBound(arralpha)
  415.         arralpha(n).Count = 0
  416.     Next
  417.     ' Uncomment this loop to enable phase analysis.
  418.     ' Hack j=1 to use base string only.
  419.     For j = 1 To 1 'wid
  420.         For k = 1 To Len(arrseqphase(j)) - (Len(arrseqphase(j)) Mod wid) Step wid
  421.             For n = 1 To UBound(arralpha)
  422.                 If (Mid$(arrseqphase(j), k, wid) = arralpha(n).Signature) Then
  423.                     arralpha(n).Count = arralpha(n).Count + 1
  424.                 End If
  425.             Next
  426.         Next
  427.     Next
  428.     Call QuickSort(arralpha(), 1, UBound(arralpha))
  429.  
  430. Sub PrintHisto (arr() As LetterBin, wid As Integer)
  431.     Dim As Integer j, n
  432.     If (wid > 0) Then
  433.         If (wid > UBound(arr)) Then
  434.             j = UBound(arr)
  435.         Else
  436.             j = wid
  437.         End If
  438.         Print "Histogram: "; _Trim$(Str$(UBound(arr))); "-letter regroup, showing top "; _Trim$(Str$(wid))
  439.         For n = 1 To j
  440.             Print arr(n).Signature; arr(n).Count
  441.         Next
  442.     End If
  443.  
  444. Sub PrintGraph (TheString As String, arrgrade() As Double)
  445.     Dim As Integer j, k
  446.     Dim As Double f, g
  447.     For k = 1 To _Width
  448.         Locate _Height - 5, k: Print "_"
  449.         Locate _Height - 5 - 10, k: Print "_"
  450.     Next
  451.     Locate _Height - 5 + 1, 1: Print "0%"
  452.     Locate _Height - 5 - 10 - 1, 1: Print "100%"
  453.     f = (_Width) / Len(TheString)
  454.     If (f > 1) Then f = 1
  455.     For j = 2 To Len(TheString)
  456.         g = Int(j * f)
  457.         If (g = 0) Then g = 1
  458.         Locate _Height - 5 - Int(10 * arrgrade(j, 1)), g
  459.         If (arrgrade(j, 2) = 1) Then
  460.             Print Chr$(251)
  461.         Else
  462.             Print "x"
  463.         End If
  464.     Next
  465.  
  466. Sub NewAlphabet (arrold() As LetterBin, arrnew() As LetterBin)
  467.     Dim As Integer j, k, n
  468.     n = 0
  469.     For k = 1 To 2
  470.         For j = 1 To UBound(arrold)
  471.             n = n + 1
  472.             arrnew(n).Signature = arrold(j).Signature
  473.         Next
  474.     Next
  475.     For j = 1 To UBound(arrnew)
  476.         If (j <= UBound(arrnew) / 2) Then
  477.             arrnew(j).Signature = "0" + arrnew(j).Signature
  478.         Else
  479.             arrnew(j).Signature = "1" + arrnew(j).Signature
  480.         End If
  481.     Next
  482.  
  483. Sub QuickSort (arr() As LetterBin, LowLimit As Long, HighLimit As Long)
  484.     Dim As Long piv
  485.     If (LowLimit < HighLimit) Then
  486.         piv = Partition(arr(), LowLimit, HighLimit)
  487.         Call QuickSort(arr(), LowLimit, piv - 1)
  488.         Call QuickSort(arr(), piv + 1, HighLimit)
  489.     End If
  490.  
  491. Function Partition (arr() As LetterBin, LowLimit As Long, HighLimit As Long)
  492.     Dim As Long i, j
  493.     Dim As Double pivot, tmp
  494.     pivot = arr(HighLimit).Count
  495.     i = LowLimit - 1
  496.     For j = LowLimit To HighLimit - 1
  497.         tmp = arr(j).Count - pivot
  498.         If (tmp >= 0) Then
  499.             i = i + 1
  500.             Swap arr(i), arr(j)
  501.         End If
  502.     Next
  503.     Swap arr(i + 1), arr(HighLimit)
  504.     Partition = i + 1
  505.  
  506. Function Pathological$ (TheSeed As String, TheLength As Integer)
  507.     Dim TheReturn As String
  508.     TheReturn = TheSeed
  509.     Dim p
  510.     Do
  511.         p = Analyze(TheReturn, AlphaWeight(), 0)
  512.         If (p = 1) Then
  513.             TheReturn = TheReturn + "0"
  514.         Else
  515.             TheReturn = TheReturn + "1"
  516.         End If
  517.     Loop Until Len(TheReturn) = TheLength
  518.     Pathological$ = TheReturn
  519.  
  520. Function QBPRNG$ (TheSeed As Double, TheLength As Integer)
  521.     Dim TheReturn As String
  522.     Dim k As Integer
  523.     Randomize TheSeed
  524.     For k = 1 To TheLength
  525.         If (Rnd > .5) Then
  526.             TheReturn = TheReturn + "1"
  527.         Else
  528.             TheReturn = TheReturn + "0"
  529.         End If
  530.     Next
  531.     QBPRNG$ = TheReturn
  532.  
  533. Function LoadTestFile (alwayszero As Integer, TheFile As String, ReversalToggle As Integer)
  534.     Dim As Integer j, k
  535.     Dim n As Integer
  536.     Dim a As String
  537.     n = alwayszero
  538.     Open TheFile For Input As #1
  539.     Do While Not EOF(1)
  540.         n = n + 1
  541.         Line Input #1, a
  542.         TestData(n) = a
  543.     Loop
  544.     Close #1
  545.     If (ReversalToggle = -1) Then
  546.         For k = 1 To n
  547.             a = TestData(k)
  548.             TestData(k) = ""
  549.             For j = Len(a) To 1 Step -1
  550.                 TestData(k) = TestData(k) + Mid$(a, j, 1)
  551.             Next
  552.         Next
  553.     End If
  554.     LoadTestFile = n
  555.  
  556. Function LoadTestData (alwayszero As Integer)
  557.     Dim n As Integer
  558.     n = alwayszero
  559.  
  560.     '''
  561.     ' Percussive cases:
  562.     '''
  563.     'n = n + 1: TestData(n) = "1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111"
  564.     'n = n + 1: TestData(n) = "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
  565.     'n = n + 1: TestData(n) = "0101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101"
  566.     'n = n + 1: TestData(n) = "1010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010"
  567.     'n = n + 1: TestData(n) = "0001110011000111001100011100110001110011000111001100011100110001110011000111001100011100110001110011000111001100011100110001110011000111001100011100110001110011"
  568.     'n = n + 1: TestData(n) = "0100010111010001011101000101110100010111010001011101000101110100010111010001011101000101110100010111010001011101000101110100010111010001011101000101110100010111"
  569.  
  570.     '''
  571.     ' Human samples:
  572.     '''
  573.     ' (from Keybone)
  574.     n = n + 1: TestData(n) = "101010101010101010101001010101010101001010111001010101010101010101010100010101010101010100101001010101001100101010001010100101010100101010100101010101010101010011011110010101010100100101010110010011001010011001010100010100101010010101010101010010101010101010010101001010101010100110010101010100101010101010011001001010100101010010101010100101010010101001010100101001010010101010111010100110011001010101010100110101001010101010100101001010111010101010101010100101001010101010010101010101001010101001010101001010100101010100101010010101010101001010101001010101010101001010101001010100101010101010010101010010010101010101010101010010100101010101001010100101001010101001111101010101010100101010110011001010101010101010110101010101101010101010100101010010101010010101010101101110010101001010101010110010100101010101001011010101010100110101010100101010010101010100101010101001010101010101001010101010011010101010101110110100101010111010101011011001011001010101001010101010101010101010011001010101010100101010101010101010010100101"
  575.     ' (from Keybone)
  576.     n = n + 1: TestData(n) = "0101110101100011010100101011001110001011001010001110101111010100111011100100101001010011110101101000101010001010101111001010111010101010100001010101000101101100101111101010010101110110111001000101000011010101010001001001001111101011101010100010110101110101100000101010101110111010100100100001110111100101011110101010001010001110010110111110110010101001001011101000101001011100011101000010101010101101010010110100101101000101111010101110111001010011101111010101000010101111100010101011110101011011110100001010110"
  577.     ' (from Loudar)
  578.     n = n + 1: TestData(n) = "1011001010010100100100110010101010101001010101010101011010010101001010101001010010100110101011010101010101011010101101010101010101010010110101010101100101010101010110101101011010010101010010100110101101001010110101011010010101101010110100101111010101010011011011010010110101010010110100101101010100101011010010101001010101010001011101011010010101011100111010010001101011110010011010001011100110101010010011010101001001010010000101010110001"
  579.     ' (from Luke)
  580.     n = n + 1: TestData(n) = "01100101001010001100001101101111011010010101010110110101001000001111001111110101000101111011010101111101010101101010101001010101011000010101010101001011010100110100110100110011010101010101110101010111111101011010100000001101111000010111000110111001000010100001101010110100000111101011111100001011001010110010110"
  581.     ' (from Sarafromct)
  582.     n = n + 1: TestData(n) = "10101010101011101000011101010111010101010101100111001010100111100001011011110101000001111010101101010000001111110011111110111101110111001110110010000100010101010101010100101011010110101010101010101001000000001111110000011110101010101010100010101110101010101101111111111111111111101010101010101000000"
  583.     ' (from Spriggs)
  584.     n = n + 1: TestData(n) = "10111010101010101010101001010101010101001010101001010101010101010101010101010101010101010101010101010101001010100100100101010101010101001010100101010101010100101010100101010101010101010101001010010110010101010010101010101010101010101010100101001001001010101010101010101010101001010101001001101010010"
  585.     ' (from Spriggs)
  586.     n = n + 1: TestData(n) = "11111011110100101011111111110100000011011110101100111100111111110111101110100111100110011111110101111111010111101111100111110111111111111011100111110111111110010000101011111001110101101010110111110"
  587.     ' (from Hotpants)
  588.     n = n + 1: TestData(n) = "01010100011001010010101010101010101000110101010111101010100100011010101010100100101110010010010100001010101001010101010110010001001011000100100110101001001001010000000001010101101111101001010100010101001001010101000100101001100100010011010101010101010111010010101011101011011010110100100010010100100100010010001001"
  589.  
  590.     '''
  591.     ' Noted sequences:
  592.     '''
  593.     ' (Wolfram rule 30)
  594.     n = n + 1: TestData(n) = "110111001100010110010011101011100111010101100001100101011010101111110000111100010101110000010010110001110001101101101000000010001111101110100111000111010111000001100100011001111001111110000001111111011001011011100000101100011011000110001110110110010101111111011010110110111101110010111011000100000000001101110010110010111100100110000111110000001011011001111001000010011111000001101001011001001011101011000001101001000101001011101011111011000100000011110101000111101001011010001101000111100001000011110001111010"
  595.  
  596.     LoadTestData = n
  597.  
  598. ''' Museum:
  599. 'Call InitializeModelIndexed(BinaryModelIndex) ' Goes with counter
  600. 'Call InitializeModelIndexed(0)                ' Always zero
  601. 'Call InitializeModelIndexed(1023)             ' Homogeneous
  602. 'Call InitializeModelIndexed(16)               ' This 5-gram case (16) works best for Gaming mode.
  603. 'Call InitializeModelIndexed(82)               ' Learning algo discoverd this is a good one against humans.
  604. 'Call InitializeModelIndexed(18)               ' Learning algo discoverd this is a good one against humans.
  605. 'Call InitializeModelCustom(-1)                ' Enables custom model(s).
  606. '''
  607.  
  608. '''
  609. ' Studies in pathology:
  610. 'BinaryModelIndex = 2   ' cracked by 124
  611. 'BinaryModelIndex = 3   ' cracked by 16
  612. 'BinaryModelIndex = 4   ' cracked by 265
  613. 'BinaryModelIndex = 5   ' cracked by 736
  614. 'BinaryModelIndex = 6   ' cracked by 49
  615. 'BinaryModelIndex = 7   ' cracked by 88
  616. 'BinaryModelIndex = 8   ' cracked by xxx
  617. 'BinaryModelIndex = 9   ' cracked by xxx
  618. 'BinaryModelIndex = 10  ' cracked by 644
  619. 'BinaryModelIndex = 11  ' cracked by 261
  620. '''
  621.  
Title: Re: Looking for old program or help recreating it
Post by: random1 on December 28, 2021, 04:24:55 pm
STxAxTIC

What if we change the output so that (0)=miss and (1)=hit and then run that string back through
the predictor to see what happens.  Repeat this process as many times as needed to produce the
highest level of accuracy that can be obtained.  Kind of a noise cancellation feedback loop. 

I think the output string shows structure with a little noise thrown in here and there, if we can remove
the noise then then who knows what the results will show.  I have been working on a couple simple
tools but have not figured out how to combine the outputs so that the accuracy improves, so far my
attempts show a negative effect.

Anyway, you seem to have a lot cooking on the back burner so maybe when time permits you can
check it out.

I will bookmark the new link so I can stay abreast of any updates.

R1     
Title: Re: Looking for old program or help recreating it
Post by: STxAxTIC on December 28, 2021, 08:54:35 pm
What if we change the output so that (0)=miss and (1)=hit and then run that string back through
the predictor to see what happens.

Ya know, this thought crossed my mind but I haven't had the nuts to try it. It's kindof a fascinating idea - for the model to study and find patterns in its own performance (it's a binary sequence after all), so that it may predict its own performance and improve upon it. There is so much to mess with there...!

This reminds me of another hunt I wanted to launch that looks for "eigenstrings". I just made up that word up, it's a play on "eigenvector" which (from linear algebra) is a vector x that would satisfy Ax=x, where A is a matrix. In our case, A is the predictor and x is the sequence. This means that the sequence would be identical to the correctness record. Crazy stuff!

Reeling things back in a second... this kind of thing gets dangerously close to alchemy, which is to say just peering into sacrificial goat entrails for patterns. We could do this for eternity and never notice when the mathematics stopped and the mad hattery began. Luckily we aren't there yet. I think the future of this work is less about the algorithms working blindly, and more about using any meta-knowledge you have about the input sequences themselves. This is to say, "where is this data coming from?"

Anyhow I'll keep writing up the interesting stuff - will let you know if anything new interesting stuff pops up.
Title: Re: Looking for old program or help recreating it
Post by: random1 on December 29, 2021, 01:59:45 am
 STxAxTIC

Mad hattery, so many rabbit holes to explore, lol.  Just hope this does not cause you
to move to Lincoln Montana and start making bombs.  My math skills ran out a ways
back and I am feeling a little parasitic feeding off your knowledge.   

I think if it can be done, you are the one to do it.  It's already surpassed my expectations
so everything right, our should I say, left of here is a bonus. 

Thanks

R1
 

   
   
Title: Re: Looking for old program or help recreating it
Post by: random1 on December 29, 2021, 03:48:44 am
Here is a simple Gap / Frequency tool.  I once used something like this as a secondary
predictor to kind of second guess the main predictors output.  Don't remember how
well if fared.  Notice that a gap of 35 shows a perfect string of (0's), 6 I think.  The
sample data string is very short and is not a real output string.  Just a simple code bit
to illustrate an idea.

Code: QB64: [Select]
  1. '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  2. 'Frequency / Gap tool.  Cartoon code                                                                                                       '
  3. 'This is a gaps analysis tool.  It is set go check every gap from 2 to 50 between any two points of the output data string  '
  4. 'The goal is to find the best gap value between two consecutive 1 or 0.                                                     '
  5. 'The first count is offset by one to sync up with the next event                                                            '
  6. '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  7. Title1$ = "Gap Analysis"
  8. _Title Title1$
  9. A& = _NewImage(600,200,32)
  10.  
  11. Dim OutString as string '<- The output from the predictor
  12. 'small sample string
  13. OutString = "01010000100010000110100100000101100110000110101100110100100000110000000010010001101101110011100001000110000001100100000001111001011011000000001000000111010100001100001000010010001110100011000111111000110000000000100000111000010000100000010011110110000000001101"
  14. Prediction$=""
  15.  
  16. Gap = 2  '<- start gap value
  17. Do while Gap <= 50
  18. NewStr$="" '<- build a result string' here for illistration only.  This string will be a condenced version of the one being processed
  19.  
  20. hit=0:mis=0
  21. L1=Gap-1 '<- offset counter by 1 so data is synced for prediction
  22.   Do while L1 <= Len(OutString)-Gap
  23.       If Mid$(OutString,L1,1)="1" Then hit=hit+1 else mis=mis+1
  24.       If Mid$(OutString,L1,1)="1" Then NewStr$=NewStr$+"1" else NewStr$=NewStr$+"0" '<- create a results string for multi processing if needed
  25.   L1=L1+Gap
  26.  
  27. 'simple analysis
  28. 'if results consist entirely of 0's or 1's then update predicted value
  29. If Instr(NewStr$,"1") < 1 Then Prediction$=Prediction$+"0"
  30. If Instr(NewStr$,"0") < 1 Then Prediction$=Prediction$+"1"
  31.  
  32. 'Print results for each gap
  33. Color _RGB32(192,192,192),_RGB32(0,0,0)
  34. _PrintString (2, 4), "Gap -> " + _Trim$(Str$(Gap))
  35. _PrintString (2,20), "Gap hit (1) -> " + _Trim$(Str$(hit))
  36. _PrintString (2,36), "Gap hit (0) -> " + _Trim$(Str$(mis))
  37. _PrintString (2,52), NewStr$
  38.  
  39. Sleep  '<- comment out to automate the process
  40. Gap=Gap+1 '<- Add 1 to gap
  41. Color _RGB32(0,0,0),_RGB32(0,0,0)
  42. If Gap < 50 Then CLS
  43.  
  44. 'overall results
  45. Color _RGB32(192,192,192),_RGB32(0,0,0)
  46. _PrintString (2,68), "Overall findings -> " + Prediction$
  47. _PrintString(2,180), "Press any key to exit"
  48.  
  49.  

R1
Title: Re: Looking for old program or help recreating it
Post by: STxAxTIC on January 01, 2022, 12:46:14 am
Hey R1,

I have a happy little update and a little storyline to go with it. So apart from all of the eggheaded things I was planning to do with this code, I was quiet about *one* endeavor - just in case it failed - and it held up production until today - it's finally finished. What I've managed to do is use my unaltered Analyze function as a random number generator. I went through serious pain to make sure it gives "real" randomness, and almost quit looking several times thinking it may be impossible. Way too much to unpack here, but the conclusion is I used what was laying around to find a full-blown PRNG.

This came about by thinking along the lines of what you said, namely
Quote
What if we change the output so that (0)=miss and (1)=hit and then run that string back through
the predictor to see what happens.
... and thought about it a lot, and realized that's kindof what's going on when I build "pathological" sequences. To refresh: suppose you have a given model W. The "pathological" sequence is the sequence that W gets *wrong* every single turn. I detailed how to build these things on the web page. Anyway, to make a random number generator, I figured, "let's build a pathological string but find a way to randomize W while building it." The way I "randomize" W is to replace W with a sample of the output sequence itself.

Just for comparison, here is how I use QB64's in-house RND function to generate a random sequence of a given length from a given seed:

Code: QB64: [Select]
  1. Function QBPRNG$ (TheSeed As Double, TheLength As Integer)
  2.     Dim TheReturn As String
  3.     Randomize TheSeed
  4.     Do
  5.         If (Rnd > .5) Then
  6.             TheReturn = TheReturn + "1"
  7.         Else
  8.             TheReturn = TheReturn + "0"
  9.         End If
  10.     Loop Until (Len(TheReturn) = TheLength)
  11.     QBPRNG$ = TheReturn

And here is the new kid in town. Also makes random sequences but without RND:

Code: QB64: [Select]
  1. Function ProtoRand$ (TheSeed As String, TheLength As Integer)
  2.     Dim TheReturn As String
  3.     Dim WorkingString As String
  4.     TheReturn = ""
  5.     WorkingString = "0100100010" + TheSeed
  6.     Do
  7.         Call InitializeModelLiteral(Right$(WorkingString, 10))
  8.         If (Analyze(WorkingString, AlphaWeight(), 0) = 1) Then
  9.             TheReturn = TheReturn + "0"
  10.             WorkingString = WorkingString + "0"
  11.         Else
  12.             TheReturn = TheReturn + "1"
  13.             WorkingString = WorkingString + "1"
  14.         End If
  15.         If (Len(WorkingString) > 80) Then WorkingString = Right$(WorkingString, 80)
  16.     Loop Until Len(TheReturn) = TheLength
  17.     ProtoRand$ = TheReturn

You can see that I "replace W with a sample of the output sequence itself" right after the DO statement. Pretty esoteric stuff if you don't remember exactly how we got to this point, but nonetheless there it is! That move puzzles things enough so that the output is just utterly jumbled. (I can explain why the number 80 appears in this code, it can really be any number bigger than a few dozen.) Now I can exhale a second time. (And write some of this stuff up. All of these notes will go up on the page soon enough.)

Alright happy new year!
Title: Re: Looking for old program or help recreating it
Post by: random1 on January 02, 2022, 07:30:44 am
STxAxTIC

Cool, can't wait for the update.  I finished the little 3 stage predictor tool have been working
on the last couple weeks.  It's more of a idea I decided to test and see what happens.

What I did was to combine three simple predictors where each one outputted a probability
which are then combined in the final prediction.

The calculations go like this, the predictors end count for 0 and 1 are converted into probabilities.
Next I add a small boost weight to the 1's and then use p^2 to both the 0's and 1's calculation. 
It then moves to the next prediction tool and repeats the process. 

After all active predictors have ran the last stage sums the probabilities and then divides by the
number of active predictors, Remember I can run any configuration of the three, 1 & 2 or 1 & 3
etc...   The value with the greatest probability is the end prediction.

The config/settings menu allows adjusting certain things like the length of the string to process,
search sample size, number of iterations, weights etc...  I was able to fine the three predictors
close to 70 percent hit rates when ran one at a time.

The problem.
Tuning the predictors one at a time for maximum hit rates seemed fine but when I run them 
combined the results dropped like a rock, around 70% down to mid 40's to low 50's mostly
because it predicts way too many ones, 60 to 80 for a average.  Lowering the boost value
does not seem to help.   This tool is designed to only predict (1's), all other value are ignored
and the data strings are non-standard so to say.   There are around 112 strings used by this
tool where around 30% repeat day to day.  The idea is to predict 20 to 25 1's out of the 112
strings with a very high accuracy.   

Anyway, that's where I am at.  Still thinking I might be able to improve it, maybe set one of the
predictors to boost (0) counts to decrease the overall 1's predicted.  I am still playing around with
the settings in the configuration menu but think I may have to go back into the code and change
a few things.

I check your links each day for updates, thanks again.  Hope you and yours have a great new year.
 
R1   
 
Title: Re: Looking for old program or help recreating it
Post by: random1 on January 03, 2022, 04:33:32 am
Hi all

I need some help with a scoring method for the above mentioned prediction tool.
Below is a picture of the scoreboard so to say but what I want to do is combine
all the data into a overall score so that I can track the overall effects of my fine
tuning.


https://i.postimg.cc/L6sKrkMs/SCORE.png
 (https://i.postimg.cc/L6sKrkMs/SCORE.png)

This results shown in the picture are based on a real data back-test.  This allows
me to analyze the predictors results to the actual event.  The first item in the pic
shows the back-test number, the second shows the number of strings processed
by the predictor.   The third is the number of predictions made by the predictor.
The forth value shows the actual number of strings that did repeat. The fifth value
shows the number of correct predictions from the possible 42 that did repeat.
The sixth line is the number of incorrect predictions made.  The seventh is a
simple probability gotten form dividing the total correct guesses by the number
of predictions made.  36/67= .5373. 

So out of 105 strings processed, there were a possible 42 correct choices for a (1)
to repeat.  Of these the predictor managed to predict 36 for 36/42=0.857 correct.

I need to combine everything in such a way that I can score the predictors overall
performance.  Also remember the predictor only predicts (1's) ie repeats.
         
overall predictions = 67/105=.638
correct predictions = 36/67=.537 but we need to factor in the 105 strings processed
at least I think this needs to be included.  etc..

Thanks in advance.

PS.  The predictor guessed correctly 36 times from a pool of the 42 possible in 67 predictions
made from analyzing 105 strings.  Calculate a score given all the variables.

R1






Title: Re: Looking for old program or help recreating it
Post by: random1 on January 03, 2022, 05:22:56 am
Hi all

I figured out my own question, since the predictor predicts both zeros and ones
even though the ones are the only values tracked.  All I had to do was count the
number of correct (0) guesses and add that to the ones then divide the sum by
the number of strings processed.  This gives me a overall hit rate which is really
all I needed.  Stupid monkey, get some sleep. LOL

R1
 
Title: Re: Looking for old program or help recreating it
Post by: STxAxTIC on January 03, 2022, 06:40:55 am
Good evening R1 -

Close call with that question you just pitched - I was about to roll up my sleeves before the alarm was suddenly silenced.

Just wanted to let you know that the page is now "fully" caught up to everything I was talking about. I'll probably notice little typos as time goes on, but the main flow is there. Doing a quick scroll up and down the page, it's a lot more dense than part 1. I know you have the link but for completeness: http://barnes.x10host.com/pages/Binary-Analyzer/Binary-Analyzer-Two.php (http://barnes.x10host.com/pages/Binary-Analyzer/Binary-Analyzer-Two.php)

I've also done a very little bit of quality-of-life cleanup to the code. It's now set to simply process a file if you drag+drop onto it, or if you don't, it can be hacked by band. All of the delays and limits are commented out. Right now it's default thing is to crank through the "troublesome" sequence you pasted on (I think) the 16's of Dec. I'm still running it right now, but that string is at least 63% predictable so far.

I'm basically happy with zipping up this project for long-term storage at this point. (The game I play is, pretend I forget all the details and rediscover my own project later on - will it still make sense? My answer right now is "prolly".) I'll attach the "final" code at the bottom. It can of course be butchered for its Analyze() function. Everything in the main loop can be deleted and the core will still do its job.

You said some interesting stuff above, particularly when combining models. Isn't it funny how the results drop when you do that? It reminds me of how hurricanes are modeled on the news. You always see this bundle of possible trajectories on the statewide map which represent competing models. You might say, "hey, why not bundle those lines together and just imagine one thick bold line?" Sure, but then you have to combine uncertainies too. The possible trajectory widens to a huge cone, and you're back to wondering at random where the hurricane's gonna go. It might be better to just pick one model from the many and not melt them all together.

I'm not sure how exactly you're optimizing your solution, but imagine a search in parameter space. Lemme freestyle this... Suppose your models are M1, M2, and M3. Then the nth digit in your sequence is predicted by each model, denoted as M1(n), M2(n), M3(n). Okay, so you talked about switching these on or off. Did you try blending them? Like this:

P(n) = w(1)*M1(n) + w(2)*M2(n) + w(3)*M3(n)

This means the total prediction of the nth bit is the weighted average of all three models, and the question becomes what the hell do we do with w(1), w(2), and w(3)? The most prudent thing possible is to imagine a sphere... actually ya know what? Let me do this in two dimensions first. Suppose for clarity you have only two models. Then we can skip the third everything:

P(n) = w(1)*M1(n) + w(2)*M2(n)

Now check this out. Suppose w(1) = cos(q), w(2)=sin(q). If you're trigonometrically inclined, I'm now imagining a circle of radius 1, and the weights w(1), w(2) are the x,y coordinates of a point on this circle at angle q. Then, if you want to cycle through all possible combinations of models M1 and M2, let the q-variable step from 0 to 2pi at a fine interval. (Adjust the interval to avoid negative weights but the gist is there.)

Tell me if I'm out in right field. If this sounds appealing, we can develop the 3d case based on a sphere.


Code: QB64: [Select]
  1. ' Version: 2022-01-03
  2.  
  3.  
  4. _TITLE "Binary Analyzer"
  5.  
  6. SCREEN _NEWIMAGE(120, 40)
  7.  
  8. TYPE LetterBin
  9.     Signature AS STRING
  10.     Count AS INTEGER
  11.  
  12. DIM SHARED Alphabet1(2) AS LetterBin ' 0 1
  13. DIM SHARED Alphabet2(4) AS LetterBin ' 00 01 10 11
  14. DIM SHARED Alphabet3(8) AS LetterBin ' 000 001 010 011 100 101 110 111
  15. DIM SHARED Alphabet4(16) AS LetterBin ' etc.
  16. DIM SHARED Alphabet5(32) AS LetterBin
  17. DIM SHARED Alphabet6(64) AS LetterBin
  18. DIM SHARED Alphabet7(128) AS LetterBin
  19. DIM SHARED Alphabet8(256) AS LetterBin
  20. DIM SHARED Alphabet9(512) AS LetterBin
  21. DIM SHARED Alphabet10(1024) AS LetterBin
  22. DIM SHARED Alphabet11(2048) AS LetterBin
  23. DIM SHARED Alphabet12(4096) AS LetterBin
  24. DIM SHARED Alphabet13(8192) AS LetterBin
  25.  
  26. Alphabet1(1).Signature = "0"
  27. Alphabet1(2).Signature = "1"
  28. CALL NewAlphabet(Alphabet1(), Alphabet2())
  29. CALL NewAlphabet(Alphabet2(), Alphabet3())
  30. CALL NewAlphabet(Alphabet3(), Alphabet4())
  31. CALL NewAlphabet(Alphabet4(), Alphabet5())
  32. CALL NewAlphabet(Alphabet5(), Alphabet6())
  33. CALL NewAlphabet(Alphabet6(), Alphabet7())
  34. CALL NewAlphabet(Alphabet7(), Alphabet8())
  35. CALL NewAlphabet(Alphabet8(), Alphabet9())
  36. CALL NewAlphabet(Alphabet9(), Alphabet10())
  37. CALL NewAlphabet(Alphabet10(), Alphabet11())
  38. CALL NewAlphabet(Alphabet11(), Alphabet12())
  39. CALL NewAlphabet(Alphabet12(), Alphabet13())
  40.  
  41. ' Specification of weight model.
  42. DIM SHARED AlphaWeight(1 TO 13) AS DOUBLE
  43.  
  44. ' Array for test sequences.
  45. REDIM SHARED TestData(256 ^ 2) AS STRING
  46.  
  47. ' Statistics and metrics:
  48. DIM GuessPredicted AS INTEGER
  49. DIM GuessCorrect AS DOUBLE
  50. DIM GuessTotal AS DOUBLE
  51. DIM GuessRatioBest AS DOUBLE
  52. DIM GuessRatioWorst AS DOUBLE
  53. DIM GuessStreak AS INTEGER
  54. DIM GuessStreakMax AS INTEGER
  55. DIM GuessStreakBest AS INTEGER
  56. DIM Grade(256 ^ 2, 2) AS DOUBLE
  57. DIM BinaryModelIndex AS INTEGER
  58. DIM BestBinaryModel AS INTEGER
  59. DIM WorstBinaryModel AS INTEGER
  60.  
  61. ' Working varaibles:
  62. DIM TheString AS STRING
  63. DIM AS INTEGER k, m, n
  64.  
  65. ' Load test data from file or from sub.
  66.     REDIM _PRESERVE TestData(LoadTestFile(0, COMMAND$(1), 1))
  67.     '''
  68.     ' Load test cases at bottom of code:
  69.     'ReDim _Preserve TestData(LoadTestData(0))
  70.     '''
  71.  
  72.     '''
  73.     ' Play area:
  74.     REDIM _PRESERVE TestData(1)
  75.     'Call InitializeModelCustom("-1")
  76.     'Call InitializeModelLiteral("0010101000")
  77.     'Call InitializeModelIndexed(23)
  78.     TestData(1) = "00101000111101101011000010000100001100110110100001100001100000000010011001000101000010001000000111011100000100000000010111010110000000010001110010110111000001011010111100101101010000011101110011010000110010011101011111000001000011001000000010011110011000000010101010011100100000010100010010111100100100100001000010011001101101001101110100011001100000010100000010001000010110100010100011000010001010101011110000000000110000011001000000100001110000100100010000001110000010100000101010100010001101000010"
  79.     'TestData(1) = Pathological$("1", 25000)
  80.     'TestData(1) = ProtoRand$("", 1000)
  81.     'TestData(1) = QBPRNG$(1, 1000)
  82.     '''
  83.  
  84. GuessRatioBest = 0
  85. GuessRatioWorst = 1
  86. GuessStreakBest = 0
  87. WorstBinaryModel = 1
  88.  
  89. ' This outer loop is for cycling through models.
  90. BinaryModelIndex = -1
  91. DO WHILE (BinaryModelIndex < 1024)
  92.  
  93.     '''
  94.     ' Automatic increment of model index number.
  95.     BinaryModelIndex = BinaryModelIndex + 1
  96.     CALL InitializeModelIndexed(BinaryModelIndex)
  97.     '''
  98.  
  99.     ' This enclosed loop is for looping through test strings.
  100.     FOR m = 1 TO UBOUND(TestData)
  101.  
  102.         GuessPredicted = -1
  103.         GuessCorrect = 0
  104.         GuessTotal = 0
  105.         GuessStreak = 0
  106.         GuessStreakMax = 0
  107.  
  108.         ' This core loop goes through ine (literal) bit of a test string per iteration.
  109.         ' Set upper limit to infinity for game mode.
  110.         FOR n = 1 TO LEN(TestData(m)) '9999
  111.  
  112.             '''
  113.             ' Auto-feed Mode:
  114.             TheString = LEFT$(TestData(m), n)
  115.             '''
  116.  
  117.             '''
  118.             ' Gaming Mode:
  119.             'Call InitializeModelIndexed(16)               ' This 5-gram case (16) works well for game mode.
  120.             'Call InitializeModelIndexed(18)               ' Learning algo discoverd this is good against humans.
  121.             'Call InitializeModelIndexed(82)               ' Learning algo discoverd this is good against humans.
  122.             'Call InitializeModelLiteral("0000101000")     ' Experimental default.
  123.             'Cls
  124.             'Locate 1, 1
  125.             'Print "Press LEFT or RIGHT."
  126.             'k = 0
  127.             'Do: k = _KeyHit: Loop Until ((k = 19200) Or (k = 19712))
  128.             'Select Case k
  129.             '    Case 19200
  130.             '        TheString = TheString + "0"
  131.             '    Case 19712
  132.             '        TheString = TheString + "1"
  133.             'End Select
  134.             '_KeyClear
  135.             '''
  136.  
  137.             CLS
  138.             COLOR 7
  139.             LOCATE 1, 1
  140.             FOR k = 1 TO _WIDTH
  141.                 PRINT "_";
  142.             NEXT
  143.             PRINT "Model";
  144.             PRINT " ("; _TRIM$(STR$(BinaryModelIndex)); ")";
  145.             PRINT ":";
  146.             FOR k = 1 TO 10 'UBound(AlphaWeight)
  147.                 PRINT AlphaWeight(k);
  148.             NEXT
  149.             PRINT
  150.             PRINT
  151.             PRINT "Sequence (index "; _TRIM$(STR$(m)); ") (length "; _TRIM$(STR$(LEN(TheString))); "):"
  152.             PRINT RIGHT$(TheString, 400);
  153.             COLOR 8
  154.             PRINT LEFT$(RIGHT$(TestData(m), LEN(TestData(m)) - n), 400);
  155.             COLOR 7
  156.             PRINT
  157.  
  158.             ' Reconciliation
  159.             IF (GuessPredicted <> -1) THEN
  160.                 PRINT
  161.                 PRINT "I predicted "; _TRIM$(STR$(GuessPredicted)); " and you typed "; RIGHT$(TheString, 1); "."
  162.                 IF (GuessPredicted = VAL(RIGHT$(TheString, 1))) THEN
  163.                     PRINT "I am RIGHT this round."
  164.                     GuessCorrect = GuessCorrect + 1
  165.                     GuessStreak = GuessStreak + 1
  166.                     IF (GuessStreak > GuessStreakMax) THEN GuessStreakMax = GuessStreak
  167.                     Grade(n, 2) = 1
  168.                 ELSE
  169.                     PRINT "I am WRONG this round."
  170.                     GuessStreak = 0
  171.                     Grade(n, 2) = 0
  172.                 END IF
  173.                 GuessTotal = GuessTotal + 1
  174.                 Grade(n, 1) = GuessCorrect / GuessTotal
  175.             END IF
  176.  
  177.             IF (GuessTotal > 0) THEN
  178.                 PRINT
  179.                 PRINT "I'm on a "; _TRIM$(STR$(GuessStreak)); "-round winning streak."
  180.                 PRINT "My best streak has been "; _TRIM$(STR$(GuessStreakMax)); "."
  181.                 IF (GuessTotal <> 0) THEN
  182.                     PRINT "My correctness rate is "; _TRIM$(STR$(INT(100 * GuessCorrect / GuessTotal))); "% in "; _TRIM$(STR$(GuessTotal)); " trials."
  183.                 END IF
  184.             END IF
  185.  
  186.             GuessPredicted = Analyze(TheString, AlphaWeight(), 0)
  187.  
  188.             '''
  189.             ' Reverse polarity if needed for any reason.
  190.             'If (GuessPredicted = 0) Then
  191.             '    GuessPredicted = 1
  192.             'Else
  193.             '    GuessPredicted = 0
  194.             'End If
  195.             '''
  196.  
  197.             PRINT
  198.             'Print "I have made a new prediction."
  199.             'Print "Press LEFT or RIGHT to test me."
  200.             PRINT "The best performer was model #"; _TRIM$(STR$(BestBinaryModel)); ", rated "; _TRIM$(STR$(INT(GuessRatioBest * 100))); "%, best streak of "; _TRIM$(STR$(GuessStreakBest)); "."
  201.             PRINT "The worst performer was model #"; _TRIM$(STR$(WorstBinaryModel)); ", rated "; _TRIM$(STR$(INT(GuessRatioWorst * 100))); "%."
  202.  
  203.             ' Draw bottom graph if there's enough room.
  204.             IF (CSRLIN <= 23) THEN
  205.                 IF (GuessTotal <> 0) THEN
  206.                     CALL PrintGraph(TheString, Grade())
  207.                 END IF
  208.             END IF
  209.  
  210.             _DISPLAY
  211.             '_Delay .02
  212.             '_Limit 240
  213.         NEXT
  214.  
  215.         IF (GuessTotal > 0) THEN
  216.             IF (GuessCorrect / GuessTotal >= GuessRatioBest) THEN
  217.                 BestBinaryModel = BinaryModelIndex
  218.                 GuessRatioBest = GuessCorrect / GuessTotal
  219.                 GuessStreakBest = GuessStreakMax
  220.             END IF
  221.             IF (GuessCorrect / GuessTotal <= GuessRatioWorst) THEN
  222.                 WorstBinaryModel = BinaryModelIndex
  223.                 GuessRatioWorst = GuessCorrect / GuessTotal
  224.             END IF
  225.         END IF
  226.  
  227.         '_Delay 3
  228.     NEXT
  229.  
  230.  
  231.  
  232. FUNCTION Analyze (TheStringIn AS STRING, arrweight() AS DOUBLE, pswitch AS INTEGER)
  233.     DIM TheReturn AS INTEGER
  234.     DIM AS INTEGER n
  235.     DIM AS DOUBLE r, j, k
  236.     DIM StringPhase(UBOUND(arrweight)) AS STRING
  237.     DIM Partialguess(LBOUND(arrweight) TO UBOUND(arrweight), 2) AS DOUBLE
  238.  
  239.     StringPhase(1) = TheStringIn
  240.     'For n = 2 To UBound(StringPhase) ' Phase analysis.
  241.     '    StringPhase(n) = Right$(StringPhase(n - 1), Len(StringPhase(n - 1)) - 1) + Left$(StringPhase(n - 1), 1)
  242.     'Next
  243.  
  244.     IF (pswitch = 1) THEN
  245.         PRINT
  246.         FOR n = 1 TO _WIDTH
  247.             PRINT "-";
  248.         NEXT
  249.         PRINT
  250.     END IF
  251.  
  252.     IF (arrweight(1) <> 0) THEN CALL CreateHisto(StringPhase(), 1, Alphabet1())
  253.     IF (arrweight(2) <> 0) THEN CALL CreateHisto(StringPhase(), 2, Alphabet2())
  254.     IF (arrweight(3) <> 0) THEN CALL CreateHisto(StringPhase(), 3, Alphabet3())
  255.     IF (arrweight(4) <> 0) THEN CALL CreateHisto(StringPhase(), 4, Alphabet4())
  256.     IF (arrweight(5) <> 0) THEN CALL CreateHisto(StringPhase(), 5, Alphabet5())
  257.     IF (arrweight(6) <> 0) THEN CALL CreateHisto(StringPhase(), 6, Alphabet6())
  258.     IF (arrweight(7) <> 0) THEN CALL CreateHisto(StringPhase(), 7, Alphabet7())
  259.     IF (arrweight(8) <> 0) THEN CALL CreateHisto(StringPhase(), 8, Alphabet8())
  260.     IF (arrweight(9) <> 0) THEN CALL CreateHisto(StringPhase(), 9, Alphabet9())
  261.     IF (arrweight(10) <> 0) THEN CALL CreateHisto(StringPhase(), 10, Alphabet10())
  262.     IF (arrweight(11) <> 0) THEN CALL CreateHisto(StringPhase(), 11, Alphabet11())
  263.     IF (arrweight(12) <> 0) THEN CALL CreateHisto(StringPhase(), 12, Alphabet12())
  264.     IF (arrweight(13) <> 0) THEN CALL CreateHisto(StringPhase(), 13, Alphabet13())
  265.  
  266.     IF (pswitch = 1) THEN ' Set the last argument >=1 to print stats for that histogram.
  267.         IF ((LEN(TheStringIn) >= 1) AND (arrweight(1) <> 0)) THEN CALL PrintHisto(Alphabet1(), 0)
  268.         IF ((LEN(TheStringIn) >= 2) AND (arrweight(2) <> 0)) THEN CALL PrintHisto(Alphabet2(), 0)
  269.         IF ((LEN(TheStringIn) >= 3) AND (arrweight(3) <> 0)) THEN CALL PrintHisto(Alphabet3(), 0)
  270.         IF ((LEN(TheStringIn) >= 4) AND (arrweight(4) <> 0)) THEN CALL PrintHisto(Alphabet4(), 0)
  271.         IF ((LEN(TheStringIn) >= 5) AND (arrweight(5) <> 0)) THEN CALL PrintHisto(Alphabet5(), 4)
  272.         IF ((LEN(TheStringIn) >= 6) AND (arrweight(6) <> 0)) THEN CALL PrintHisto(Alphabet6(), 0)
  273.         IF ((LEN(TheStringIn) >= 7) AND (arrweight(7) <> 0)) THEN CALL PrintHisto(Alphabet7(), 0)
  274.         IF ((LEN(TheStringIn) >= 8) AND (arrweight(8) <> 0)) THEN CALL PrintHisto(Alphabet8(), 0)
  275.         IF ((LEN(TheStringIn) >= 9) AND (arrweight(9) <> 0)) THEN CALL PrintHisto(Alphabet9(), 0)
  276.         IF ((LEN(TheStringIn) >= 10) AND (arrweight(10) <> 0)) THEN CALL PrintHisto(Alphabet10(), 0)
  277.         IF ((LEN(TheStringIn) >= 11) AND (arrweight(11) <> 0)) THEN CALL PrintHisto(Alphabet11(), 0)
  278.         IF ((LEN(TheStringIn) >= 12) AND (arrweight(12) <> 0)) THEN CALL PrintHisto(Alphabet12(), 0)
  279.         IF ((LEN(TheStringIn) >= 13) AND (arrweight(13) <> 0)) THEN CALL PrintHisto(Alphabet13(), 0)
  280.         PRINT
  281.     END IF
  282.  
  283.     ' Set the last argument =1 to print guess for that histogram.
  284.     IF ((LEN(TheStringIn) >= 1) AND (arrweight(1) <> 0)) THEN CALL MakeGuess(TheStringIn, 1, Alphabet1(), Partialguess(), 0)
  285.     IF ((LEN(TheStringIn) >= 2) AND (arrweight(2) <> 0)) THEN CALL MakeGuess(TheStringIn, 2, Alphabet2(), Partialguess(), 0)
  286.     IF ((LEN(TheStringIn) >= 3) AND (arrweight(3) <> 0)) THEN CALL MakeGuess(TheStringIn, 3, Alphabet3(), Partialguess(), 0)
  287.     IF ((LEN(TheStringIn) >= 4) AND (arrweight(4) <> 0)) THEN CALL MakeGuess(TheStringIn, 4, Alphabet4(), Partialguess(), 0)
  288.     IF ((LEN(TheStringIn) >= 5) AND (arrweight(5) <> 0)) THEN CALL MakeGuess(TheStringIn, 5, Alphabet5(), Partialguess(), pswitch)
  289.     IF ((LEN(TheStringIn) >= 6) AND (arrweight(6) <> 0)) THEN CALL MakeGuess(TheStringIn, 6, Alphabet6(), Partialguess(), 0)
  290.     IF ((LEN(TheStringIn) >= 7) AND (arrweight(7) <> 0)) THEN CALL MakeGuess(TheStringIn, 7, Alphabet7(), Partialguess(), 0)
  291.     IF ((LEN(TheStringIn) >= 8) AND (arrweight(8) <> 0)) THEN CALL MakeGuess(TheStringIn, 8, Alphabet8(), Partialguess(), 0)
  292.     IF ((LEN(TheStringIn) >= 9) AND (arrweight(9) <> 0)) THEN CALL MakeGuess(TheStringIn, 9, Alphabet9(), Partialguess(), 0)
  293.     IF ((LEN(TheStringIn) >= 10) AND (arrweight(10) <> 0)) THEN CALL MakeGuess(TheStringIn, 10, Alphabet10(), Partialguess(), 0)
  294.     IF ((LEN(TheStringIn) >= 11) AND (arrweight(11) <> 0)) THEN CALL MakeGuess(TheStringIn, 11, Alphabet11(), Partialguess(), 0)
  295.     IF ((LEN(TheStringIn) >= 12) AND (arrweight(12) <> 0)) THEN CALL MakeGuess(TheStringIn, 12, Alphabet12(), Partialguess(), 0)
  296.     IF ((LEN(TheStringIn) >= 13) AND (arrweight(13) <> 0)) THEN CALL MakeGuess(TheStringIn, 13, Alphabet13(), Partialguess(), 0)
  297.     IF (pswitch = 1) THEN PRINT
  298.  
  299.     IF (pswitch = 1) THEN
  300.         PRINT "Thinking:   ";
  301.         FOR k = LBOUND(Partialguess) TO UBOUND(Partialguess)
  302.             IF ((LEN(TheStringIn) >= k) AND (arrweight(k) <> 0)) THEN
  303.                 PRINT Partialguess(k, 1);
  304.             ELSE
  305.                 PRINT "_ ";
  306.             END IF
  307.         NEXT
  308.         PRINT
  309.     END IF
  310.  
  311.     j = 0
  312.     r = 0
  313.  
  314.     ' Weighted average calculation
  315.     FOR k = LBOUND(Partialguess) TO UBOUND(Partialguess)
  316.         IF ((LEN(TheStringIn) >= k) AND (arrweight(k) <> 0)) THEN
  317.             r = r + arrweight(k) * Partialguess(k, 1)
  318.             j = j + arrweight(k)
  319.         END IF
  320.     NEXT
  321.     IF (j <> 0) THEN
  322.         r = r / j
  323.     END IF
  324.  
  325.     IF (pswitch = 1) THEN PRINT "Predicting:  "; _TRIM$(STR$(r))
  326.  
  327.     IF (r > .5) THEN
  328.         r = 1
  329.     ELSE
  330.         r = 0
  331.     END IF
  332.  
  333.     IF (pswitch = 1) THEN PRINT "Rounding to: "; _TRIM$(STR$(r))
  334.  
  335.     IF (pswitch = 1) THEN
  336.         FOR n = 1 TO _WIDTH
  337.             PRINT "-";
  338.         NEXT
  339.         PRINT
  340.     END IF
  341.  
  342.     TheReturn = r
  343.     Analyze = TheReturn
  344.  
  345. SUB MakeGuess (TheStringIn AS STRING, wid AS INTEGER, arralpha() AS LetterBin, arrguess() AS DOUBLE, pswitch AS INTEGER)
  346.     DIM TheReturn AS DOUBLE
  347.     DIM AS INTEGER j, k, n
  348.     TheReturn = 0
  349.     j = 1
  350.     k = 0
  351.     FOR n = 1 TO UBOUND(arralpha)
  352.         IF (LEFT$(arralpha(n).Signature, wid - 1) = RIGHT$(TheStringIn, wid - 1)) THEN
  353.             IF (arralpha(n).Count >= j) THEN
  354.                 IF (pswitch = 1) THEN PRINT "Order-"; RIGHT$("0" + _TRIM$(STR$(wid)), 2); " guess: "; arralpha(n).Signature; " . "; _TRIM$(STR$(arralpha(n).Count))
  355.                 TheReturn = TheReturn + VAL(RIGHT$(arralpha(n).Signature, 1))
  356.                 k = k + 1
  357.                 j = arralpha(n).Count
  358.             END IF
  359.         END IF
  360.     NEXT
  361.     IF (k <> 0) THEN
  362.         TheReturn = TheReturn / k
  363.     ELSE
  364.         TheReturn = .5
  365.     END IF
  366.     arrguess(wid, 1) = TheReturn
  367.     arrguess(wid, 2) = j
  368.  
  369. SUB InitializeModelIndexed (TheIndexIn AS INTEGER)
  370.     '0 to 1023
  371.     CALL InitializeModelLiteral(BIN$(TheIndexIn))
  372.  
  373. SUB InitializeModelLiteral (Weights AS STRING)
  374.     DIM AS INTEGER k
  375.     FOR k = 1 TO 10
  376.         AlphaWeight(k) = VAL(MID$(Weights, k, 1))
  377.     NEXT
  378.     AlphaWeight(11) = 0
  379.     AlphaWeight(12) = 0
  380.     AlphaWeight(13) = 0
  381.  
  382. SUB InitializeModelCustom (Weights AS STRING)
  383.     DIM AS INTEGER k
  384.     IF (Weights = "-1") THEN
  385.         FOR k = LBOUND(AlphaWeight) TO UBOUND(AlphaWeight)
  386.             AlphaWeight(k) = k ^ 2
  387.         NEXT
  388.     END IF
  389.     AlphaWeight(11) = 0
  390.     AlphaWeight(12) = 0
  391.     AlphaWeight(13) = 0
  392.  
  393.     ' Butchered from the Wiki. Ugliest function ever.
  394.     DIM AS INTEGER max, i, msb
  395.     DIM AS STRING b
  396.     max% = 8 * LEN(n%)
  397.     FOR i = max% - 1 TO 0 STEP -1
  398.         IF (n% AND 2 ^ i) THEN msb% = 1: b$ = "1" + b$ ELSE IF msb% THEN b$ = "0" + b$
  399.     NEXT
  400.     b$ = LEFT$(b$ + "0000000000", 10)
  401.     BIN$ = b$
  402.  
  403. SUB CreateHisto (arrseqphase() AS STRING, wid AS INTEGER, arralpha() AS LetterBin)
  404.     DIM AS INTEGER j, k, n
  405.     FOR n = 1 TO UBOUND(arralpha)
  406.         arralpha(n).Count = 0
  407.     NEXT
  408.     ' Hack j=1 to use base string only.
  409.     ' Let the loop's upper limit =wid for phase analysis.
  410.     FOR j = 1 TO 1 'wid
  411.         FOR k = 1 TO LEN(arrseqphase(j)) - (LEN(arrseqphase(j)) MOD wid) STEP wid
  412.             FOR n = 1 TO UBOUND(arralpha)
  413.                 IF (MID$(arrseqphase(j), k, wid) = arralpha(n).Signature) THEN
  414.                     arralpha(n).Count = arralpha(n).Count + 1
  415.                 END IF
  416.             NEXT
  417.         NEXT
  418.     NEXT
  419.     CALL QuickSort(arralpha(), 1, UBOUND(arralpha))
  420.  
  421. SUB PrintHisto (arr() AS LetterBin, wid AS INTEGER)
  422.     DIM AS INTEGER j, n
  423.     IF (wid > 0) THEN
  424.         IF (wid > UBOUND(arr)) THEN
  425.             j = UBOUND(arr)
  426.         ELSE
  427.             j = wid
  428.         END IF
  429.         PRINT "Histogram: "; _TRIM$(STR$(UBOUND(arr))); "-letter regroup, showing top "; _TRIM$(STR$(wid))
  430.         FOR n = 1 TO j
  431.             PRINT arr(n).Signature; arr(n).Count
  432.         NEXT
  433.     END IF
  434.  
  435. SUB PrintGraph (TheString AS STRING, arrgrade() AS DOUBLE)
  436.     DIM AS INTEGER j, k
  437.     DIM AS DOUBLE f, g
  438.     FOR k = 1 TO _WIDTH
  439.         LOCATE _HEIGHT - 5, k: PRINT "_"
  440.         LOCATE _HEIGHT - 5 - 10, k: PRINT "_"
  441.     NEXT
  442.     LOCATE _HEIGHT - 5 + 1, 1: PRINT "0%"
  443.     LOCATE _HEIGHT - 5 - 10 - 1, 1: PRINT "100%"
  444.     f = (_WIDTH) / LEN(TheString)
  445.     IF (f > 1) THEN f = 1
  446.     FOR j = 2 TO LEN(TheString)
  447.         g = INT(j * f)
  448.         IF (g = 0) THEN g = 1
  449.         LOCATE _HEIGHT - 5 - INT(10 * arrgrade(j, 1)), g
  450.         IF (arrgrade(j, 2) = 1) THEN
  451.             PRINT CHR$(251)
  452.         ELSE
  453.             PRINT "x"
  454.         END IF
  455.     NEXT
  456.  
  457. SUB NewAlphabet (arrold() AS LetterBin, arrnew() AS LetterBin)
  458.     DIM AS INTEGER j, k, n
  459.     n = 0
  460.     FOR k = 1 TO 2
  461.         FOR j = 1 TO UBOUND(arrold)
  462.             n = n + 1
  463.             arrnew(n).Signature = arrold(j).Signature
  464.         NEXT
  465.     NEXT
  466.     FOR j = 1 TO UBOUND(arrnew)
  467.         IF (j <= UBOUND(arrnew) / 2) THEN
  468.             arrnew(j).Signature = "0" + arrnew(j).Signature
  469.         ELSE
  470.             arrnew(j).Signature = "1" + arrnew(j).Signature
  471.         END IF
  472.     NEXT
  473.  
  474. SUB QuickSort (arr() AS LetterBin, LowLimit AS LONG, HighLimit AS LONG)
  475.     DIM AS LONG piv
  476.     IF (LowLimit < HighLimit) THEN
  477.         piv = Partition(arr(), LowLimit, HighLimit)
  478.         CALL QuickSort(arr(), LowLimit, piv - 1)
  479.         CALL QuickSort(arr(), piv + 1, HighLimit)
  480.     END IF
  481.  
  482. FUNCTION Partition (arr() AS LetterBin, LowLimit AS LONG, HighLimit AS LONG)
  483.     DIM AS LONG i, j
  484.     DIM AS DOUBLE pivot, tmp
  485.     pivot = arr(HighLimit).Count
  486.     i = LowLimit - 1
  487.     FOR j = LowLimit TO HighLimit - 1
  488.         tmp = arr(j).Count - pivot
  489.         IF (tmp >= 0) THEN
  490.             i = i + 1
  491.             SWAP arr(i), arr(j)
  492.         END IF
  493.     NEXT
  494.     SWAP arr(i + 1), arr(HighLimit)
  495.     Partition = i + 1
  496.  
  497. FUNCTION Pathological$ (TheSeed AS STRING, TheLength AS INTEGER)
  498.     DIM TheReturn AS STRING
  499.     TheReturn = TheSeed
  500.     DO
  501.         IF (Analyze(TheReturn, AlphaWeight(), 0) = 1) THEN
  502.             TheReturn = TheReturn + "0"
  503.         ELSE
  504.             TheReturn = TheReturn + "1"
  505.         END IF
  506.     LOOP UNTIL LEN(TheReturn) = TheLength
  507.     Pathological$ = TheReturn
  508.  
  509. FUNCTION ProtoRand$ (TheSeed AS STRING, TheLength AS INTEGER)
  510.     DIM TheReturn AS STRING ' Actual output.
  511.     DIM WorkingString AS STRING ' So-called working string.
  512.     TheReturn = ""
  513.     WorkingString = "0100100010" + TheSeed ' ...in case user sends blank seed.
  514.     DO
  515.         ' Change prediction model based on working string.
  516.         CALL InitializeModelLiteral(RIGHT$(WorkingString, 10))
  517.         ' Make prediction based on working string.
  518.         ' Store the opposite result.
  519.         IF (Analyze(WorkingString, AlphaWeight(), 0) = 1) THEN
  520.             TheReturn = TheReturn + "0" ' Analyze returned a 1.
  521.             WorkingString = WorkingString + "0"
  522.         ELSE
  523.             TheReturn = TheReturn + "1" ' Analyze returned a 0.
  524.             WorkingString = WorkingString + "1"
  525.         END IF
  526.         ' Keep working string reasonably short so runtime remains O(L).
  527.         IF (LEN(WorkingString) > 80) THEN WorkingString = RIGHT$(WorkingString, 80)
  528.     LOOP UNTIL LEN(TheReturn) = TheLength
  529.     ProtoRand$ = TheReturn
  530.  
  531. FUNCTION QBPRNG$ (TheSeed AS DOUBLE, TheLength AS INTEGER)
  532.     DIM TheReturn AS STRING
  533.     RANDOMIZE TheSeed
  534.     DO
  535.         IF (RND > .5) THEN
  536.             TheReturn = TheReturn + "1"
  537.         ELSE
  538.             TheReturn = TheReturn + "0"
  539.         END IF
  540.     LOOP UNTIL (LEN(TheReturn) = TheLength)
  541.     QBPRNG$ = TheReturn
  542.  
  543. FUNCTION LoadTestFile (alwayszero AS INTEGER, TheFile AS STRING, ReversalToggle AS INTEGER)
  544.     DIM AS INTEGER j, k
  545.     DIM n AS INTEGER
  546.     DIM a AS STRING
  547.     n = alwayszero
  548.     OPEN TheFile FOR INPUT AS #1
  549.     DO WHILE NOT EOF(1)
  550.         n = n + 1
  551.         LINE INPUT #1, a
  552.         TestData(n) = a
  553.     LOOP
  554.     CLOSE #1
  555.     IF (ReversalToggle = -1) THEN
  556.         FOR k = 1 TO n
  557.             a = TestData(k)
  558.             TestData(k) = ""
  559.             FOR j = LEN(a) TO 1 STEP -1
  560.                 TestData(k) = TestData(k) + MID$(a, j, 1)
  561.             NEXT
  562.         NEXT
  563.     END IF
  564.     LoadTestFile = n
  565.  
  566. FUNCTION LoadTestData (alwayszero AS INTEGER)
  567.     DIM n AS INTEGER
  568.     n = alwayszero
  569.  
  570.     '''
  571.     ' Percussive cases:
  572.     '''
  573.     n = n + 1: TestData(n) = "1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111"
  574.     n = n + 1: TestData(n) = "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
  575.     n = n + 1: TestData(n) = "0101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101"
  576.     n = n + 1: TestData(n) = "1010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010"
  577.     n = n + 1: TestData(n) = "0001110011000111001100011100110001110011000111001100011100110001110011000111001100011100110001110011000111001100011100110001110011000111001100011100110001110011"
  578.     n = n + 1: TestData(n) = "0100010111010001011101000101110100010111010001011101000101110100010111010001011101000101110100010111010001011101000101110100010111010001011101000101110100010111"
  579.  
  580.     '''
  581.     ' Human samples:
  582.     '''
  583.     ' (from Keybone)
  584.     n = n + 1: TestData(n) = "101010101010101010101001010101010101001010111001010101010101010101010100010101010101010100101001010101001100101010001010100101010100101010100101010101010101010011011110010101010100100101010110010011001010011001010100010100101010010101010101010010101010101010010101001010101010100110010101010100101010101010011001001010100101010010101010100101010010101001010100101001010010101010111010100110011001010101010100110101001010101010100101001010111010101010101010100101001010101010010101010101001010101001010101001010100101010100101010010101010101001010101001010101010101001010101001010100101010101010010101010010010101010101010101010010100101010101001010100101001010101001111101010101010100101010110011001010101010101010110101010101101010101010100101010010101010010101010101101110010101001010101010110010100101010101001011010101010100110101010100101010010101010100101010101001010101010101001010101010011010101010101110110100101010111010101011011001011001010101001010101010101010101010011001010101010100101010101010101010010100101"
  585.     ' (from Keybone)
  586.     n = n + 1: TestData(n) = "0101110101100011010100101011001110001011001010001110101111010100111011100100101001010011110101101000101010001010101111001010111010101010100001010101000101101100101111101010010101110110111001000101000011010101010001001001001111101011101010100010110101110101100000101010101110111010100100100001110111100101011110101010001010001110010110111110110010101001001011101000101001011100011101000010101010101101010010110100101101000101111010101110111001010011101111010101000010101111100010101011110101011011110100001010110"
  587.     ' (from Loudar)
  588.     n = n + 1: TestData(n) = "1011001010010100100100110010101010101001010101010101011010010101001010101001010010100110101011010101010101011010101101010101010101010010110101010101100101010101010110101101011010010101010010100110101101001010110101011010010101101010110100101111010101010011011011010010110101010010110100101101010100101011010010101001010101010001011101011010010101011100111010010001101011110010011010001011100110101010010011010101001001010010000101010110001"
  589.     ' (from Luke)
  590.     n = n + 1: TestData(n) = "01100101001010001100001101101111011010010101010110110101001000001111001111110101000101111011010101111101010101101010101001010101011000010101010101001011010100110100110100110011010101010101110101010111111101011010100000001101111000010111000110111001000010100001101010110100000111101011111100001011001010110010110"
  591.     ' (from Sarafromct)
  592.     n = n + 1: TestData(n) = "10101010101011101000011101010111010101010101100111001010100111100001011011110101000001111010101101010000001111110011111110111101110111001110110010000100010101010101010100101011010110101010101010101001000000001111110000011110101010101010100010101110101010101101111111111111111111101010101010101000000"
  593.     ' (from Spriggs)
  594.     n = n + 1: TestData(n) = "10111010101010101010101001010101010101001010101001010101010101010101010101010101010101010101010101010101001010100100100101010101010101001010100101010101010100101010100101010101010101010101001010010110010101010010101010101010101010101010100101001001001010101010101010101010101001010101001001101010010"
  595.     ' (from Spriggs)
  596.     n = n + 1: TestData(n) = "11111011110100101011111111110100000011011110101100111100111111110111101110100111100110011111110101111111010111101111100111110111111111111011100111110111111110010000101011111001110101101010110111110"
  597.     ' (from Hotpants)
  598.     n = n + 1: TestData(n) = "01010100011001010010101010101010101000110101010111101010100100011010101010100100101110010010010100001010101001010101010110010001001011000100100110101001001001010000000001010101101111101001010100010101001001010101000100101001100100010011010101010101010111010010101011101011011010110100100010010100100100010010001001"
  599.     ' (from [banned user])
  600.     n = n + 1: TestData(n) = "11011011011101011010001011001110001101011001001111110000110111011101100100101110110001110011001100111110011011001110100000101001011010001100011100011100011100010011100101110100011011001101000111001111100110111011101110110000111011101010010010011000101100011010001111100100100011100111001100011110001"
  601.  
  602.     LoadTestData = n
  603.  
Title: Re: Looking for old program or help recreating it
Post by: random1 on January 03, 2022, 03:09:25 pm
 STxAxTIC

Thanks, it will take me a while to digest everything so as to decide what will best fit
what I am doing right now.  You mentioned my combining the tools but last night I
got to thinking and had the though, what if I added a negative value as the weight.
I set M1 positive but M2 and M3 both to a negative value and guess what?  I saw a
improvement right off.  After toying around I was able to get above 70% and the
big thing was the overall predicted (1's) dropped but the hit ratio improved.

Most days after a data update I check to see how many values repeat from the previous
update.  I have several sets of data but the one set I use most often normally has around
35 to 40 repeats out of 105 strings I track.  Setting the M2 and M3 weights to a negative
value gave the thing a big push.  I am seeing around 35 (1's) in the output with a hit rate
close to 70%.  In one test the program came up with 38 predictions and 32 were correct,
Wow, never seen that coming.   Anyway, still tinkering with the settings, must be millions
of ways to adjust things, each run takes a few minutes so it's a slow slow process and already
thinking of how to automate it.  I have six or seven old Dell 6000 that were configured for
max performance just setting in my closet collecting dust.  I may have to dig them out and
put them to work.  Come to think of it, a couple of them are in like new condition which were
never used.       

Anyway, mucho gracias and will let you know how it all works out.

R1
Title: Re: Looking for old program or help recreating it
Post by: random1 on January 06, 2022, 12:53:57 am
I think I got everything put together, the picture show the results before any fine tuning
and without the weights set.  Looking good so far.
R1


https://i.postimg.cc/6q3V8W0F/RESULTS.png
 (https://i.postimg.cc/6q3V8W0F/RESULTS.png)
Title: Re: Looking for old program or help recreating it
Post by: random1 on January 06, 2022, 10:51:50 am
STxAxTIC


Quote
I'm not sure how exactly you're optimizing your solution, but imagine a search in parameter space. Lemme freestyle this... Suppose your models are M1, M2, and M3. Then the nth digit in your sequence is predicted by each model, denoted as M1(n), M2(n), M3(n). Okay, so you talked about switching these on or off. Did you try blending them? Like this:

P(n) = w(1)*M1(n) + w(2)*M2(n) + w(3)*M3(n)

This means the total prediction of the nth bit is the weighted average of all three models, and the question becomes what the hell do we do with w(1), w(2), and w(3)? The most prudent thing possible is to imagine a sphere... actually ya know what? Let me do this in two dimensions first. Suppose for clarity you have only two models. Then we can skip the third everything:

P(n) = w(1)*M1(n) + w(2)*M2(n)

I'm still working on several methods, I added a setting to the configuration so that I and have more
that one option.  Right now it allows up to 4 different methods to be used.  what I did was add the
raw data output, ie, probabilities from each predictor to an array which can be passed directly to the
method set in the config utility.  This way I can test them against each other.  I also automated the
test option so that it's possible to run 100's of test unsupervised.  The results are written to a text
file which can then be analyzed by hand.

If your still tinkering around with this and have some suggestions then I will try them out.  I am in
the process of adding the methods mentioned above.

R1

Picture of the config setting for selecting the blending method.  I suppose it's only limited to the
imagination, but right now it's set to allow 4 different methods.  Who knows, maybe some kind
of crazy strange code will take it over the top.  I am open to anything.   


https://i.postimg.cc/DZ8Yst1N/BLEND.png
 (https://i.postimg.cc/DZ8Yst1N/BLEND.png)
Title: Re: Looking for old program or help recreating it
Post by: random1 on January 07, 2022, 12:11:57 pm
I have been tinkering with fine tuning the prediction tool and wanted to post the test results
of my last test run.  So far the best hit rate I have been able to achieve was 38 of 40 correct
for a score of  95% for  40 strings.  Most test show mid 70's with a few 80's in the results
but I am just getting started with the fine tuning.  Below I attached a file showing the results
of 50 back-test that I use to evaluate my configuration settings.  This is not the best but one
the many I have tried so far.  I also attached a picture that shows to read the results. 

Anyway, anyone interested in how the project is going can take a peek.

R1

Picture instructions on reading the results

https://i.postimg.cc/Pq4BR3Kj/TEST.png
 (https://i.postimg.cc/Pq4BR3Kj/TEST.png)   

The results file
Title: Re: Looking for old program or help recreating it
Post by: random1 on January 07, 2022, 04:33:11 pm
Best score today

Test # 76
Total Strings = 40
[P1 =10]  [Hits = 8]  [Misses = 2]
[P0 =30]  [Hits =29]  [Misses = 1]
Actual 1's = 9   H-Ratio =.8888
Actual 0's =31   H-Ratio =.9354
Overall hits=37 of 40
Predictors score =.925
1's Missed on string =24,32
0's Missed on string =23
A=0000-0001-0001-0011-0001-0010-0001-0000-0000-0011
P=0000-0001-0001-0011-0001-0001-0001-0001-0000-0011

Still tinkering

R1
Title: Re: Looking for old program or help recreating it
Post by: random1 on January 10, 2022, 08:48:31 am
All set up to do some serious fine tuning, wife walked in and laughed.
Ever see a old nerd's man cave.  On the bright side,  all seven of the
dell inspiron 6000 booted without a hitch.  Some have not been booted
for five or six years, even the batteries seem to have taken a full charge.
Anyway, I am ready to do some serious testing.

https://i.postimg.cc/prLkPy01/posted.png (https://i.postimg.cc/prLkPy01/posted.png) 
 

R1
Title: Re: Looking for old program or help recreating it
Post by: STxAxTIC on January 10, 2022, 09:37:20 am
Dude that is a serious mancave, you should pull up a matrix screensaver on each machine and recreate the setup from the movies!

Happy tuning btw!
Title: Re: Looking for old program or help recreating it
Post by: random1 on January 11, 2022, 03:12:52 pm
STxAxTIC

LOL, I had to drag out another portable table and make a u-shaped configuration.
It was too time consuming closing the lids so I could get to the back row to make
adjustments.  Overall the test yielded nothing, after 5 hours the best was around
90% and the overall average was in the high 70's.  Going to have to try something
else.

I hate to bother you with another request but today I came up with another idea
for tuning.  If interested the attached file contains comma delimited entries of
the raw outputs of the 3 predictors plus a 4th that shows the overall hit shows for
both 0's and 1,s and the last entry in each line is the correct prediction value.

This data is compiled by taking the 3 predictors output probabilities and then using
P^2, and nothing else.  The data contains 100 test with a blank line at the end of
each run to separate them.  I used 40 strings in the test so each run contains 40
results.   

The first 4 columns are the (0) output probabilities, the second 4 are for the (1's).
The last entry is the actual value that showed in the next update.  The lines that
have all 1'a are the strings that are made up of all zeros, ie, no ones in the string
being processed. 

The idea is to try to find a small range that could be added at the end of each
prediction represented by each row.  As it is now I add the 3 predictors outputs
and then divide by 3 for both 0's and 1's then take whichever is higher and use
that value as the prediction.

Here is one of the best results from yesterday's test.  I was hoping for high 90's or maybe
even 100% No such luck
 
Test # 64
Total Strings = 40
[P1 =18]  [Hits =14]  [Misses = 4]
[P0 =22]  [Hits =22]  [Misses = 0]
Actual 1's =14   H-Ratio =1
Actual 0's =26   H-Ratio =.8461
Overall hits=36 of 40
Predictors score =.9
1's Missed on string/s ->12,27,31,38
0's Missed on string/s ->
A=0001-0111-0000-0011-0001-0011-0001-0001-0001-0011
P=0001-0111-0001-0011-0001-0011-0011-0011-0001-0111
End of prediction.............


The goal of the file below would be to use it as a training set in order to calculate  lower and
upper threshold range that can be applied in the final stage to tip the output in the direction
so to increase the overall hits.  This data was calculated without my so called boost weights.

Anyway, if you have the time to mess with it, otherwise please don't feel any obligation.  Just
throwing it out there.  I am going to calculate a running average then calculate a tipping value
which would be the value needed to off set the predicted enough to swing the prediction in
favor of the correct value.  Sounds simple enough but may need a new training set after each
update.       
 

 File image, explains the data structure.
 
https://i.postimg.cc/zDdmYrTx/help.png (https://i.postimg.cc/zDdmYrTx/help.png)

     

Title: Re: Looking for old program or help recreating it
Post by: random1 on January 12, 2022, 05:51:09 pm
Hi all

I was getting a bit discouraged with my project and decided to do a random test.
I set the prng to generate a integer between 0 and 100 and then used mod 2 to
get a odd / even value, even=0 and odd<>0 =1.  I ran 100 test and it's best hit
rate was 70% with a overall average or just over 50%.

The project's best so far is in the mid 90's with a overall average of .775.  The overall
is showing around 27 points higher on average, maybe I am making more progress
than I thought.   

R1
Title: Re: Looking for old program or help recreating it
Post by: STxAxTIC on January 12, 2022, 06:04:38 pm
Hey random1,

I've been trying to cook up a response but have been swamped with all other kinds of self-induced distractions. You brought up a lot of different things and I'm admittedly way far behind. Everyone else is still in last year with respect to this discussion, I think. It's just you and me.

I'm trying to understand what's happening in your latest update. Are you saying that you used QB64 to generate random data, and then through your models, you can get prediction scores in the 70s? How long are these samples? Because when I do this, I get 50% plus or minus a standard deviation. See why I'm picking on this discrepancy though? Something's responsible for 70%. What are those details?

Since the details are really piling on - and maybe you'll benefit from doing this the same way I did - are you able to write up (in some preservable format) what's happening on your end? Would it be too much for me to say "I'll take the answer to my question off the air, and instead wait for your book"? Just kidding...
Title: Re: Looking for old program or help recreating it
Post by: random1 on January 13, 2022, 10:28:28 am
STxAxTIC

It's my fault because I have been jumping around all over the place with respect to
just about everything.  I am working with several different data-sets and with two
different predictors.

Ok, for clarity I will stick to one data set attached file below named Temp.txt.  This file
contains 40 strings each with 750 entries or data-points.

What I did for the random test was to use my prng function that's old as the hills and
needs updated.  It uses a time based seed with a few extra things thrown in to try and
make it more random.

For the test mentioned in that post I simply added the prng at the end of the prediction
process.  What it does is ignore the predicted value and generates a random value.  The
Prng  generates a value from 1 to 100 which I will call (r).  After the value is generated
I use r=r mod 2.  If r > 0 then the prediction is (1), if r=(0) then the prediction is 0.
 
Because the prng is time based I allow the predictors to run I just swap out the prediction
with the randomly generated value.  I could have used Rand(0,1) to get the value but
by allowing it to first generate a value between 1 and 100 then using mod to get a odd
even value it seems to be more random.  The plan is to swap out the old prng with the
one you posted, just haven't got to it yet.

In the random test the prng managed one 70% correct prediction across the entire 40 string
run.  Most however were in the high 40's but some were as low as 30% correct.  With the
prng I am using the test results were expected.  The overall average gotten from storing the
individual results and then dividing to get a average came out to be something like 50%.  Since
working with 0 or 1 as the prediction I would think the results "were as" expected.

I have been playing around with the 3 in 1 predictor I mentioned early in the topic, specifically
with blending outputs into a single prediction via playing with the weights.  I have two weights
for each predictor, one of which is a sort of static boost that is used when processing strings where
zeros outnumber the ones by a large margin.  Without these boost-weights the zero biased strings
will always be predicted (0).  Probably not a good method, just another rabbit hole grasping a straws
to try and improve the overall.

There is a forth value that is generated for each string which is the population of 0's and 1's within
the entire string being analyzed.  I haven't figured how to use it but think it might be processed into
the main predictions to help with the zero biased strings.

The best test score for the 3 in 1 predictor was one 38 out of 40 or a 95% correct.  Being the
stupid monkey that I am, I did not save the configuration settings for that run.  My best score
since then has been been 92.5%, 37 out of 40 correct.  These 90% plus hits are few and far
between, sad to say.   In general, running 100 test I end up with an average overall score of
77% and a best of 90%. Very few show better than 90%

It seems that I have hit a wall and can't fine tune beyond my current level.  I do however have
hope that I can somehow include the 4th value, ie, the overall counts for both 0's and 1's into
the prediction and push it a little higher.   

If I compare the random test vs the 3 in 1 results then it does seem that I have made some
progress but it turns out it's not enough to meet my needs. 

A couple post back I posted a file that contains the raw outputs for each of the 3 in 1 predictors
plus the 4th overall 0 and 1 counts.  This was generated to allow me to try and fine tune the
predictor without running it.  The first four values are the 0's values, the second 4 are the 1's.
The last entry is the correct value, ie, the value that should be predicted.

The file is comma delimited which makes it easy to load the 3 in 1 predictors outputs which I then
play around with trying to configure the weights in such a way to increase the hits.  Doing a 40
string 100 event test takes several minutes but doing it this way, it takes less than a second when
just working with the predictors raw outputs.

I did find your thoughts on dissipation of patterns interesting.  Patterns emerge, run for some
extended length and then dissolve for some unknown length of time only to reappear.  Will they
start up again and if so when; that's the million dollar question.  Lets say we are working with a
6 digit binary pattern.  The pattern has finite arrangements of 000000 to 111111 6^2=64.  If
dealing with random strings one would expect each to appear 1 in 64 on average +/-  some small
standard deviation. 

Whenever we see patterns repeating at a greater than expected average then it seems that some
thing else may be going on that's not easily derived.  Also the lack of some patterns adds to the
dilemma.   

Anyway this is getting long so I will close. 

R1



   
 
Title: Re: Looking for old program or help recreating it
Post by: random1 on January 13, 2022, 11:50:12 am
STxAxTIC

I am posting a test from the strings posted above.  The attached pic shows the Mal-9K
predictor tool so that you can see the user settings and the overall results which are
the last line in the lower window.

The user settings are divided by predictors, ie, the 3 in 1 tool.  The first column is for
predictor 1, the second for predictor 2 etc..

The top entries control the string length for each predictor.
The second and third cells in the first column control the length of the pattern, low/high alphas
So for this setup it uses lengths of 4 to 5 digits.

Bwt's = the static boost weights for all 3 predictors

Lm1 to lm3 are _limit values in the main iteration loops used only to make the left process bars
look normal.  These are set to 7000 for speed reasons, makes the bar graph unreadable, just 
flickers.

The lowest rows first cell set the number of back-test, the 2nd sets the blending method and
the third activates the predictors.  It allows setting active any or all three prediction tool active.
Here it is set to use all 3.

The second column 2nd cell sets the sample size and the 3rd sets the iterations for predictor 2

The second and 3rd values in the third column sets the 3rd predictors gap start and finish.  Here
it is set to just look at every 10th to every 60th value in the string.  The predictor first goes through'
the string counting only every 10th entry then every 11th etc up to gaps of 60. Very simple tool.

https://i.postimg.cc/B6QSbPD1/test-run.png (https://i.postimg.cc/B6QSbPD1/test-run.png)

The save button causes the program to write the predictor test data to a file.  These are the two
attached files below. 

The first file shows the raw data output with the boost value added.  The second shows the stats
for the 100 test predictions. 

Anyway, just throwing this out if your interested.  Might help you understand my post.  I have a
place dug out for your predictor once your totally finished with it.  Waiting patiently

R1   

Title: Re: Looking for old program or help recreating it
Post by: random1 on January 13, 2022, 11:59:36 am
P.S.

In the test above it's set to add the boost weight to the predictors (0) output values.
which is part of blending method 1, blending method 2 adds the boost to the 1's output.
Just wanted to clear that up.  There are 5 different blending methods of which #5 is the
random test option.  The blending methods can also be combined but I have never tested
that option yet.

R1
Title: Re: Looking for old program or help recreating it
Post by: random1 on January 13, 2022, 02:50:13 pm
Here's something interesting, for a while now I have noticed when scrolling through the
mal.txt file that many of the predictors missed (1) predictions fall on every 4th string, ie 
4,8,12,16,20,24,28,32,36,40.  This got me to thinking that I need to add a reevaluation
algorithm for these strings, a second look so to say that's based on some other type of
analysis whenever a (1) is predicted for these strings.  Maybe do the same thing for
other strings that produce the most missed (0) predictions.

https://i.postimg.cc/xqVJxr62/t44.png (https://i.postimg.cc/xqVJxr62/t44.png)

R1
   
Title: Re: Looking for old program or help recreating it
Post by: random1 on January 15, 2022, 12:59:21 pm
STxAxTIC

I think I have reached the end and although the overall results are better than I expected
they fall short of my needs.  The best result for a single 40 string run have been 38 of 40
correct for a hit rate of 95% but the overall average for 100 back-test runs has been .77%

I think I have exhausted my options for the predictors I am working on and don't see anyway
to improve it beyond it"s current rate.  Predictors 1 and 2 closely mimic the one you built
with minor differences so unless you find something magical to add then I think we can call
it finished.

Anyway, thanks for everything.

R1