Richard did an excellent job optimizing the algorithm. I just take the low hanging fruit of adding one line to build the array for the frequency of numbers in the inner loop of Richard's repeat loop. Thus obviating the need to go through the data again for the frequency. Also I locked the screen.
Code: Select all
-- This is an optimized version on mouseUp answer "This is a Greatly Optimized Version" & cr &\ "In order to see the optimization between the Load Matrix code you need to analyze at least 1000 Games" put empty into field "tNums" put empty into field "tRCount" put empty into field "totNumsFtr" if field "nums" is empty then answer "You need to import Past Games in order in order to Anaylze Games" exit mouseUp end if -- Bypass ask to use fixed value for timing: ask "how Many Games do you want to Analyze" # get 5000 put it into tGames2Analyze -- Capture start time: put the millisecs into t -- -- Load Matrix set itemdel to tab set the cursor to watch put field "nums" into vNums put 1 into tCounter lock screen -- added BN -- New method using a template line which is filled in -- each time through the loop to avoid item counts: -- -- Load template line: put empty into tTemplateLine repeat 39 put space & tab after tTemplateLine end repeat -- Use a copy for each line, filling in appropriate columns -- as it goes: repeat for each line tRow in vNums put tTemplateLine into tThisLine repeat with tPicks = 6 to 10 put word tPicks of tRow into tColumn add 1 to tA[tColumn] -- added BN put "X" into byte (tColumn *2)-1 of tThisLine end repeat put tThisLine & cr after tMatrix add 1 to tCounter if tCounter >tGames2Analyze then exit repeat end if end repeat -- put tMatrix into field "tNums" repeat with i = 1 to 39 put tA[i] &tab after tVals end repeat put tVals into fld "totNumsFtr" -- -- Display elapsed time: unlock screen -- added BN answer " It took"&& the millisecs - t && " milliseconds to complete the analysis" end mouseUp
I removed old/unused code.
Now if only Dick would chime in...