PDA

View Full Version : BASIC Pace app for thoroughbreds


traynor
04-29-2013, 06:34 PM
Part2 needs to be pasted on the end of Part1 (using NotePad) or any text processor that doesn't put a lot of junk in the code (DON'T use Word!) Plain vanilla, should be able to easily convert to VBA in Excel, Visual Basic, or use as is in QBASIC. It would also be trivial to convert to Python or similar.

traynor
04-29-2013, 06:40 PM
The code is an expanded (longer variable names, mostly) version of an app I used in a hand-held Sharp pocket computer. While "manual entry" may seem barbaric to those who handicap as if playing video games, it is quite convenient for those wagering on only one or two tracks, a limited number of races, only a couple of days a week, or any combination thereof.

It is also adaptable for the TI graphing calculators, so one can handicap races while pretending to do homework at the library or in class.

traynor
04-29-2013, 06:48 PM
When I started with the "sophisticated software" of the Sartin Methodology, it was so clunky that one had to convert times before entering. 1:10.2 had to be entered as 70.4. When the initial study (by Sartin's group) was done for harness, they used Phase III and Ultra Scan, entering as a mile race. Times over two minutes required several backflips to prevent the app from choking. That was the motivation to write this app.

Time conversions (also works for harness, entering minutes and fifths) below. Should be trivial to convert the times to enter as tenths or hundredths.

SUB TimeConversion
TimeFirstCall(x) = INT(TimeFirstCall(x)) + ((TimeFirstCall(x) - INT(TimeFirstCall(x))) * 2)
TimeSecondCall(x) = INT(TimeSecondCall(x)) + ((TimeSecondCall(x) - INT(TimeSecondCall(x))) * 2)
TimeThirdCall(x) = INT(TimeThirdCall(x)) + ((TimeThirdCall(x) - INT(TimeThirdCall(x))) * 2)
TimeAtFinish(x) = INT(TimeAtFinish(x)) + ((TimeAtFinish(x) - INT(TimeAtFinish(x))) * 2)

IF TimeSecondCall(x) > 100 THEN
TimeSecondCall(x) = TimeSecondCall(x) - 40
END IF
IF TimeThirdCall(x) > 100 THEN
TimeThirdCall(x) = TimeThirdCall(x) - 40
END IF
IF TimeAtFinish(x) > 200 THEN
TimeAtFinish(x) = TimeAtFinish(x) - 40
END IF
IF TimeAtFinish(x) > 100 THEN
TimeAtFinish(x) = TimeAtFinish(x) - 40
END IF
END SUB

traynor
04-29-2013, 07:02 PM
If you want to adapt this for harness races, let me know. It only requires a minimal mount of tweaking to create a nice pace app for weekend harness bettors. As rough as it may seem, it is also a great training tool for novice handicappers. Working with a simple pace app (no bells, no whistles, no hand holding) will also do wonders for teaching pattern recognition skills.

Sinner369
04-29-2013, 07:42 PM
If you want to adapt this for harness races, let me know. It only requires a minimal mount of tweaking to create a nice pace app for weekend harness bettors. As rough as it may seem, it is also a great training tool for novice handicappers. Working with a simple pace app (no bells, no whistles, no hand holding) will also do wonders for teaching pattern recognition skills.

Yes, do it for us harness fans Traynor.

Much appreciated..........thanks.......!

traynor
04-29-2013, 10:29 PM
Yes, do it for us harness fans Traynor.

Much appreciated..........thanks.......!

I will add adjustments for post position changes, park out, etc. Will probably take a week or so. I will post it as soon as it is completed.

traynor
05-03-2013, 01:16 PM
Adjustments for post position change and parkouts are such a subjective topic that the best approach seems to be giving the user the option of entering his or her own values (whatever he or she considers appropriate for those factors at the local track).

Copy the text below, including the REM **********************


REM ************************************************** ***
SUB VariantAdjustment
DIM SHARED Adjustment(10) AS SINGLE
PRINT TAB(10); "Input Adjustment (in feet)";
PRINT
(+ values credit - values penalize ";
INPUT Adjustment(x)
DIM TempVar AS SINGLE
TempVar = 5280 + Adjustment(x)
ntv = 5280 / TempVar
REM Suggested adjustments for half-mile and five-eighths tracks are
REM -5 for each Post Position change OUT from pace line race, 5 for each Post
REM Position IN from pace line race. (Example: Was PP5, now PP2 3 x 5 = 15)
REM Suggested adjustment for Parked Out is 14 for each quarter parked wide.
REM (Example--same race as above--parked wide two quarters, 14 x 2 = 28)
REM (Amount of adjustment for PP = 15, for Parked Out = 28, TOTAL 43)
EarlyPace(x) = EarlyPace(x) * ntv
SustainedPace(x) = SustainedPace(x) * ntv
AveragePace(x) = AveragePace(x) * ntv
TurnTime(x) = TurnTime(x) * ntv
FactorXPace(x) = FactorXPace(x) * ntv
END SUB
REM ************************************************** *****

Find the line (in the code you downloaded, near the bottom of the listing provided) that says:
"SUB VariantAdjustment." Mark it, including that line, down to the NEXT line that says, "END SUB." Paste the text you copied in the step above, and save it. It should work. If not, let me know.

traynor
05-03-2013, 01:42 PM
Modified for harness.

Capper Al
05-03-2013, 03:55 PM
Wow! Can't wait to check this out. You're a better man than I. I would never open up my code to the public. Thanks

traynor
05-03-2013, 09:45 PM
Wow! Can't wait to check this out. You're a better man than I. I would never open up my code to the public. Thanks

Let me know if it works okay. All my computers are 64-bit and I can't run QBASIC without a major do (downloading OS clones to make a virtual OS, blah blah). I think I could have ported it over to Visual Basic with a spiffy little GUI in about the same amount of time. Perhaps less.

traynor
05-03-2013, 10:07 PM
This is a manual entry GUI we used for Australian harness races. If anyone is interested in using it, I will clean it up and modify it for US/Canadian races and post it. The buttons enable times, positions, and beaten lengths to be entered by clicking with a mouse (instead of typing). When clicked, the buttons turn blue, and the values are entered in the appropriate textboxes to be scooped up later when calculating the race.

File size uploading constraints required low-resolution graphic.

Capper Al
05-04-2013, 07:19 AM
Let me know if it works okay. All my computers are 64-bit and I can't run QBASIC without a major do (downloading OS clones to make a virtual OS, blah blah). I think I could have ported it over to Visual Basic with a spiffy little GUI in about the same amount of time. Perhaps less.

I doubt that I'll ever have the time to convert the program. When I do get some time, I'll study the algorithm and let you know what I found.

Thanks

traynor
05-04-2013, 09:48 AM
I doubt that I'll ever have the time to convert the program. When I do get some time, I'll study the algorithm and let you know what I found.

Thanks

I think it would be nice to have (and to give free to anyone who wants it) a simple application that would enable recreational/novice/non-professional racing fans the opportunity to play around with generating pace figures, speed figures, or whatever--with all information available from the racing program or DRF.

One of the biggest deterrents to "new" racing fans is the "entry bar." While it may seem reasonable to a hardcore bettor to invest $150 a month + cost of software + months (if not more) of learning to "use" that software in order to (in a best case scenario) break even or lose less, that smacks faintly of madness to anyone not already a confirmed "horse player." The average prospective bettor is more likely to consider it expensive foolishness. And shake their heads and walk away from those who believe it takes "years of dedicated effort to learn how to win"--and then only sometimes, and only on a good day, and only after immense effort has been expended to "earn the right to win."

On the other hand, giving a prospective bettor something that he or she can use almost instantly with a minimal set of instructions, and in short order learn the basics of race analysis sufficient to start picking a few winners is likely to generate an interest in pursuing the matter further. In psychological terms, the initial processes reinforce the interest rather than extinguishing it.

Crassius
05-04-2013, 10:56 AM
I think it would be nice to have (and to give free to anyone who wants it) a simple application that would enable recreational/novice/non-professional racing fans the opportunity to play around with generating pace figures, speed figures, or whatever--with all information available from the racing program or DRF.

One of the biggest deterrents to "new" racing fans is the "entry bar." While it may seem reasonable to a hardcore bettor to invest $150 a month + cost of software + months (if not more) of learning to "use" that software in order to (in a best case scenario) break even or lose less, that smacks faintly of madness to anyone not already a confirmed "horse player." The average prospective bettor is more likely to consider it expensive foolishness.

Thanks for sharing this... I have great respect for the time and effort the programmers have put into their commercial products, but with the ongoing cost of data to feed them on top of the acquisition, it isn't very enticing to someone you wants to play a few choice races a week while enjoying the intellectual challenge of trying to beat what may well be an unbeatable game given the ridiculous takeout.

I would very much appreciate the GUI if you get around to it.

Another benefit I see is that one may get their hands dirty, be closer to the actual process, thereby learning how to actually do the work, rather than learning how to operate slick software.

Your generosity in opening the code allows people to work with, and understand the logic of the "work" that is being computerized. No one with commercial ambitions can do that, so your gift is a rare and valuable thing, for someone willing to but some sweat equity in in order to get something valuable out.

traynor
05-04-2013, 11:45 AM
Thanks for sharing this... I have great respect for the time and effort the programmers have put into their commercial products, but with the ongoing cost of data to feed them on top of the acquisition, it isn't very enticing to someone you wants to play a few choice races a week while enjoying the intellectual challenge of trying to beat what may well be an unbeatable game given the ridiculous takeout.

I would very much appreciate the GUI if you get around to it.

Another benefit I see is that one may get their hands dirty, be closer to the actual process, thereby learning how to actually do the work, rather than learning how to operate slick software.

Your generosity in opening the code allows people to work with, and understand the logic of the "work" that is being computerized. No one with commercial ambitions can do that, so your gift is a rare and valuable thing, for someone willing to but some sweat equity in in order to get something valuable out.

I think one of the most useful things to learn (that one tends to learn really fast if entering data by hand) is that the numbers that go in determine the numbers that come out. That applies to the most sophisticated, "automated" software as much as to hand entry in a minimalist application. The numbers may be massaged in more complex ways (in more complex applications), but little is added--what comes out depends on what goes in.

That bit of insight--in turn--often leads to the development of pattern-recognition skills that enable analysts to rely less and less on the software (a good thing) and more and more on their own decision-making processes (another good thing).

Longshot6977
05-04-2013, 01:14 PM
This is a manual entry GUI we used for Australian harness races. If anyone is interested in using it, I will clean it up and modify it for US/Canadian races and post it. The buttons enable times, positions, and beaten lengths to be entered by clicking with a mouse (instead of typing). When clicked, the buttons turn blue, and the values are entered in the appropriate textboxes to be scooped up later when calculating the race.

File size uploading constraints required low-resolution graphic.

That would be awesome. I'd love to try out something like this. Thanks for sharing your hard work with us.
I'm sure you already realize that just because only 1 or 2 people respond to your offer, many more would like it but just don't speak up.

traynor
05-04-2013, 01:50 PM
That would be awesome. I'd love to try out something like this. Thanks for sharing your hard work with us.
I'm sure you already realize that just because only 1 or 2 people respond to your offer, many more would like it but just don't speak up.


The question is in regard to clicking buttons with a mouse, rather than typing in numbers. We developed this for use in-house, essentially for speeding up data entry. We found that using buttons was not only faster, it cut down on errors--that is why the buttons turn blue when clicked. It is easy to detect errors at a glance (sometimes not so easy when the numbers go in a textbox, tab to the next, enter the numbers, blah blah). It came from a study tracking eye movement when entering data.

Anyway, I am all for anything that helps occasional bettors get to the point of making a few dollars from their hobby. Better yet, making lots of dollars.

Big Bill
05-05-2013, 02:55 PM
traynor,

I downloaded the two pace app files you provided in this thread and put them in Qbasic in two separate programs.

When I tried to run the first app I got this message:

STATUS Expected CALL sub-name [(...)] on line 106

When I tried to run the second app I got this message:

STATUS string required for function on line 219

Since I couldn't start/run either app/program I assume it is because of the two errors listed above. I don't know what corrections to the programs need to be made (or how to make them) for the programs to run, and so I'm hoping you can provide the help needed.

Will there be subsequent errors after these are fixed when I try to run the programs? If so, I don't want to keep bothering you. Is there a way you can check to see if there are additional errors that would keep the programs from running in my Qbasic?

Big Bill

traynor
05-05-2013, 03:15 PM
traynor,

I downloaded the two pace app files you provided in this thread and put them in Qbasic in two separate programs.

When I tried to run the first app I got this message:

STATUS Expected CALL sub-name [(...)] on line 106

When I tried to run the second app I got this message:

STATUS string required for function on line 219

Since I couldn't start/run either app/program I assume it is because of the two errors listed above. I don't know what corrections to the programs need to be made (or how to make them) for the programs to run, and so I'm hoping you can provide the help needed.

Will there be subsequent errors after these are fixed when I try to run the programs? If so, I don't want to keep bothering you. Is there a way you can check to see if there are additional errors that would keep the programs from running in my Qbasic?

Big Bill


Copy the second part and paste it to the end of the first part. I had to split it because of constraints on the size of file uploads. It is not two apps--only one.

Longshot6977
05-05-2013, 06:56 PM
Traynor,

I added part 1 and part 2 in Notepad and changed the file extension to .BAS. I got the T-Bred version to work in a QBasic.exe program. However, it never asks about WPS and earnings info even though the code lists this.

Also, the harness version doesn't work. When I hit Run, it says Expected Statement in a light blue box and has a flashing cursor under the 1st parenthesis symbol as shown in bold below.

SUB VariantAdjustment
DIM SHARED Adjustment(10) AS SINGLE
PRINT TAB(10); "Input Adjustment (in feet)";
PRINT
(+ values credit - values penalize ";
INPUT Adjustment(x)
DIM TempVar AS SINGLE


Any ideas? Or should i just wait for your GUI version? Thanks

traynor
05-05-2013, 10:47 PM
Traynor,

I added part 1 and part 2 in Notepad and changed the file extension to .BAS. I got the T-Bred version to work in a QBasic.exe program. However, it never asks about WPS and earnings info even though the code lists this.

Also, the harness version doesn't work. When I hit Run, it says Expected Statement in a light blue box and has a flashing cursor under the 1st parenthesis symbol as shown in bold below.

SUB VariantAdjustment
DIM SHARED Adjustment(10) AS SINGLE
PRINT TAB(10); "Input Adjustment (in feet)";
PRINT
(+ values credit - values penalize ";
INPUT Adjustment(x)
DIM TempVar AS SINGLE


Any ideas? Or should i just wait for your GUI version? Thanks

For starters, REM out the line bolded above, or put a PRINT command in front of it and move it above the INPUT:

SUB VariantAdjustment
DIM SHARED Adjustment(10) AS SINGLE

PRINT TAB(10); "Input Adjustment (in feet)";
PRINT TAB(10); "(+ values credit - values penalize)";
PRINT
INPUT Adjustment(x)
DIM TempVar AS SINGLE

traynor
05-05-2013, 10:57 PM
Replace the similar text at the top of Part 1 with this (only one line has been changed, and that is in the middle of the block, marked in bold):

CLS
COLOR 14, 3
CALL DistanceToday
FOR x = 1 TO noh
CALL PaceLineDistance
CALL Times
CALL TimeConversion
CALL BeatenLengths
CALL CalcFractions
CALL PaceOfRace
CALL CalcVelocities
CALL DistanceAdjustment
CALL VariantAdjustment
CALL WinPlaceShowData
NEXT x
CALL RoundFactors
CALL CreateRatings
CALL SortRatings
CALL ScreenDisplay
END

traynor
05-05-2013, 11:06 PM
Find the text below (SUBs are listed alphabetically, so it will be near top of Part 1):

SUB CalcWPSData
WinPercent(noc) = Wins(x) / Starts(x)
PRINT TAB(10); "Input Number of Starts ";
INPUT Starts(x)
PRINT
PRINT TAB(10); "Input Number of Wins ";
INPUT Wins(x)
PRINT
PRINT TAB(10); "Input Number of Places ";
INPUT Places(x)
PRINT
PRINT TAB(10); "Input Number of Shows ";
INPUT Shows(x)
PRINT
PRINT TAB(10); "Input Amount of Earnings ";
INPUT Earnings(x)
END SUB

You can delete that entire block of code (from--and including SUB to END SUB).

Longshot6977
05-06-2013, 08:55 AM
1. I got the T-Bred version to work and it now asks for WPS/earnings info. However, the results screen just shows the pace info. Is it supposed to show any other data like a rating? If not, is there a reason to enter the WPS/earnings info?

2. I still have a problem with the harness version. When it starts, an error called Illegal in procedure or DEF FN is displayed and the 1st DIM is highlighted in the following block of code:

SUB VariantAdjustment
DIM SHARED Adjustment(10) AS SINGLE
PRINT TAB(10); "Input Adjustment (in feet)";
PRINT TAB(10); "(+ values credit - values penalize)";
PRINT
INPUT Adjustment(x)
DIM TempVar AS SINGLE
TempVar = 5280 + Adjustment(x)
ntv = 5280 / TempVar

I tried your instructions several times to ensure I did them correctly. Any ideas? Could you possibly repost the corrected harness file again. Since I hate to keep bothering you, should we just wait for your GUI version you mentioned? Thanks again.

traynor
05-06-2013, 10:45 AM
1. I got the T-Bred version to work and it now asks for WPS/earnings info. However, the results screen just shows the pace info. Is it supposed to show any other data like a rating? If not, is there a reason to enter the WPS/earnings info?

2. I still have a problem with the harness version. When it starts, an error called Illegal in procedure or DEF FN is displayed and the 1st DIM is highlighted in the following block of code:

SUB VariantAdjustment
DIM SHARED Adjustment(10) AS SINGLE
PRINT TAB(10); "Input Adjustment (in feet)";
PRINT TAB(10); "(+ values credit - values penalize)";
PRINT
INPUT Adjustment(x)
DIM TempVar AS SINGLE
TempVar = 5280 + Adjustment(x)
ntv = 5280 / TempVar

I tried your instructions several times to ensure I did them correctly. Any ideas? Could you possibly repost the corrected harness file again. Since I hate to keep bothering you, should we just wait for your GUI version you mentioned? Thanks again.

Quick version--move the bolded statement to the top of the code, in the same area as other DIM SHARED statements. QBASIC may have a scope problem with globals declared within subs. I will look at the display and see what is up with it. Back shortly.

traynor
05-06-2013, 10:58 AM
I will put in a block of code to display the earnings info (APV, etc.). The display was bypassed because we used another app for that. Probably take a couple of days. Apologies for the glitches.

traynor
05-06-2013, 02:23 PM
Harness app displays APV and Quirin-formula APV (0.2, 0.45, .0.8).

If you locate the term CALL MakeModel, and create a file on your hard drive and put that path into the line to replace the path in bold below, the output of each race will be dumped into that file:


SUB MakeModel
OPEN "C:\PROTO\MODEL\HORSE\"


Toward the bottom of the listing, find the lines below and delete the apostrophe from the start of the line bolded:

SUB ScreenDisplay
'CALL MakeModel
StartScreenDisplay:

You must have a valid path set in the first step above, because the app will look for that file to dump the output. No file, it bonks. If you don't want the output saved to a file, ignore both steps above.

traynor
05-06-2013, 02:34 PM
Paste Part2 to the end of this (changed) Part1. APV and QPV are dumped into a file as output, rather than appearing onscreen. See posting above to set path to that file and to activate SUB MakeModel.

traynor
05-06-2013, 02:39 PM
If you want the thoroughbred version to display APV and QPV, find the code block preceded by REM below in the SUB ScreenDisplay, mark it, and paste this over it:

REM COLOR 15, 3
REM PRINT TAB(5); "TurnTime";
REM PRINT TAB(45); "PercentEarly"
REM COLOR 10, 3
REM FOR ttt = 1 TO 4
REM PRINT TAB(4); TurnTimeSorted(ttt);
REM PRINT TAB(44); PercentEarlySorted(ttt)
REM NEXT ttt
REM PRINT
REM PRINT

COLOR 15, 3
PRINT TAB(5); "APV";
PRINT TAB(45); "QPV"
COLOR 10, 3
FOR ttt = 1 TO 4
PRINT TAB(4); ApvSorted(ttt);
PRINT TAB(44); QpvSorted(ttt)
NEXT ttt
PRINT
PRINT

traynor
05-06-2013, 02:47 PM
The thing that is lost in all those spiffy software apps is the realization that computer code is little more than a set of simple instructions to do simple things. If you actually look at the code, it should not be too difficult to determine what does what, and to tweak it however you want to tweak it, to have it output whatever you want it to output.

So, rather than a frustrating attempt trying to get a dysfunctional app to function, consider it a BASIC lesson in handicapping by computer. Personally, I think anyone who does not understand exactly what the output "means," and what numbers it massaged to get there is foolish to bet real money on that output.