Automating SaltyBet - My Live and Ongoing Adventure - DONE!!
By TyCobb 83 Comments
Updated with Version DONE!! (2013.08.13) - See bottom of post.
I have been needing something to keep me busy lately and I always try to think of something to program since for the past several months my job as a developer has turned into the world's highest paid support job. Today I decided to try and automate SaltyBet. You may want to ask why. My preemptive reply to you is, why not?
Originally I was planning on just using Selenium and popping Java open, but quickly found I can do everything I want with the WebBrowser control in WPF (sure it's IE, but I can easily embed it into the application).
Quick rundown of what my current goals are. (Strike = Done!)
Allow betting from inside my application.Setup a databaseto track as many statistics as I can in order to predict fight outcomes.Record wins/lossesAllow certain stats to be manually entered to help calculate odds.Attempt to find a way to handle characters that have the same name.(Not going to actually happen)Make it so I don't have to log into SaltyBet.com every damn time I open to application.(Screw it)
The trickiest part of all is how I am going to handle splitting up stats based on characters with the same name. The information that is available is severely limited. I can get the name of the fighters, betting status (open and locked), and whatever else appears in standard text on the screen. My best shot is probably attempting to capture parts of the character avatar next to the health meter. This will cause me to try and force the Twitch player into running at a specific size so all my captured avatars are the same size no matter what size the window is. If that fails, I may just check a box to not bet when a character with several variations are found.
So yea, that's what I am trying to do and I plan on keeping this updated as I go.
Version 0.01:
Currently I can make my bets through the application for either Player 1 or Player 2. Now that the necessary prerequisites are fulfilled, I can start on all of the fun pieces.
Version 0.02:
Bet States are now being tracked. Database has also been created so I can now start logging fight results. My StreamPlayer is now constantly checking for updates on a background thread. It is currently keeping track of the fight and knows if the bets are open or locked. It's also checking for results.

I am also capturing fight lengths. Currently once betting becomes closed it will set the start time and once the results are posted it will save and determine the length in seconds. I am not sure how I am going to weigh this data, but figured I would get it in there now.
Below is what I just captured before updating this blog. The records that show 0 seconds are ones that I started recording in the middle of the fight. I built in logic to not record the times for those since it would be wrong.

Version 0.03:
Currently this whole time while I have been doing stuff here and there and implementing the current set of changes, Version 0.02 has been running and logging all results without issue. So far I have recorded 68 fights and Mature is leading 2-0 having fought against Kyosuke Kagami (Although it's Kagami Kyosuke on SaltyBet) and Spawn.
So what have I done so far? I implemented a quick character editor in order to start playing around with implementing rules for betting. My plan is to have Rank relate to a tier list (pretty sure it will be renamed Tier in the next update). This will be for implementing rules based on tiers instead of individual characters. Right now, I just have the following:
- Standard (For weighing character stats)
- Always Bet (You know you have favorite characters)
- Never Bet (Why waste the time and chance when you know they will just suck!)

That's about it. My goal for tomorrow (if I have time after work) will be to start writing the rules. I am hoping I have plenty of data by then. This baby will be running all night all day (if nothing crashes...) mining me my salt data. I may set up a Google Doc tomorrow that will contain all the data I found so far.
Stat Update!
It's been logging fights all night. Currently I have recorded 232 fights. Cyclops, Lavos Spawn, Saint Kyo, and Super Skrull all have 3-0 records since I started recording yesterday.
I also added my results so far to this Google Doc: https://docs.google.com/spreadsheet/ccc?key=0As6_wRKX9cgtdFFTaXpxYnZIRHE4QlNrVG12a0xQSGc&usp=sharing
The ResultDate in the spreadsheet is in UTC so you if you are actually wanting to use it for something, you may want to convert them to your time zone first.
Version 0.04
Well, I broke 500 fights being recorded and over 600 characters logged. Unfortunately, this is missing the most recent 7 hours of fights because my internet went down about 5 minutes after I went to bed.
Currently I have it giving me fight records at the top and a predicted outcome. The predicted winner and reason is saved with the fight. I plan on using this to refine the logic on who to bet on. My goal is to also use this in order to give me stats on how good the predictions are. It is automatically betting for me right now, but it isn't very good yet and won't be until I start filling in the character editor above to tell it to just not bet on certain people. I really need to implement the tier system, but probably won't get to that until later in this week.

The Google Doc has also been updated with my current fight results. Still really pissed about missing the last 7 hours though....
Version 0.05
Was able to get in some of the rules I wanted to implement last night, but couldn't. I added in logic to check for new challengers (characters I haven't logged yet). If one of the characters is up against a new challenger, I now weigh on the fact if they have previously won a match and their win percentage is at 50% or more. If not then I will automatically bet the new challenger.
I was able to also import @itwongo's fight results so I have more data to work with. That has currently put me at over 800 fight results to use as data. This is mostly all before my current rules were in place. Most of it was relying on random bets if I didn't have enough data to work with. I am hoping that once I get the ranking and tier system implemented I can hit a 70% win rate. Currently I am just betting $100 and sitting at $3250 which I started at $684.
Version 0.06 (2013.08.07)
Completely cleaned up the rules I had quickly implemented earlier. Since I was planning on adding more and making it configurable down the line, I figured it was best to refactor them out into their own little system.
It also allowed me to quickly whip a small form to test the currently programmed rules. Yes, I could have wrote some unit tests, but I wanted a form in order to easily play around with configuration options later. Also will let me play around with setting wager types and tiers on characters.

Current prediction stats after implementing new rules:
Wins | Losses | ||
---|---|---|---|
All Predictions | 143 | 81 | 64% |
New Rule Set | 19 | 7 | 73% |
New Rule Set - Without Falling Back to Random Choice | 17 | 4 | 80% |
I am curious what those numbers will be tomorrow morning. When I say "Falling Back", I am referring to the fact that none of my rules determined a winner. This can be if both characters have 0 wins or if someone new showed up that I do not have data and is fighting against someone with a win-loss ratio less than 50%.
Now that I have all of this, I believe it is time to start implementing ranks/tiers. But we shall see. I'll probably get sidetracked by something else.
Version 0.07 (2013.08.10)
Well, development had been halted for a few days. Video card fried and my computer apparently does not boot unless there is a good video card installed. Well, last night I used a brand new GTX 770 to watch SaltyBet instead of testing out with games.
So, what did I do? I implemented a new fight rule. This will try to determine the winner based on if Player 1 has defeated someone that Player 2 lost to. It is currently checking 100 levels deep. I went with 100 because I was having a hard time actually finding a scenario where this rule would hit. Basically when I say 100 levels deep, I am referring to checking all of Player 2's loss winners and then checking their loss winners to see if Player 1 possibly has a chance. It only triggered twice last night while sleeping and predicted the winner once. I've already noticed an issue while writing this that I will need to correct.
I cannot tell if auto-balancing is going to kick my ass in this project or severely help me out. I am still at only 70% prediction rate, but starting at $700 last night and betting $50 has put me at $1600. Usually I would be lower than this because the payout odds are so one sided I can win 6 matches in a row and only have like +$25 and then the very next match lose and be at -$25. The only real safe bet is $1 or $2, but that's just dumb.
I think I just need more data. Those last 2 days of not recording any stats has really put a dent in things. With the auto-balance now, I am curious if my win ratio will stay close to 72% which is where I have always floated around.
Auto-balancing has made me rethink implementing ranks. It almost feels as though it will have zero impact.
Version 0.08 (2013.08.13)
Rankings! They have been introduced. After spending a couple of days slamming my head into my desk, I finally got base rankings sorted out. Thanks to my good friend Jameson and Bacardi, I was able to pull through my issues.
Basically it worked like this:
- Seed certain characters with specific rank values. This being who I thought was better or worse than another character. I think I seeded something like 20 or so characters out of 1,200+.
- Once those were in place, I looped through all my recorded fights. Roughly about 2,600 last night when I did it. I basically just started checking winner and loser ranks to determine if the winner should move up or if the loser should move down. I didn't just loop through once though. I replayed all the fights about 30 times in order to help spread out the characters and ranks as much as I could.
- After that, I re-predicted all my recorded fights without using the Rematch Rule (if x character beat y character, bet on x). I achieved a 97% prediction rate. This means something was done correctly =)
So what does the bot currently do? It bets based on ranks and if the ranks match, it runs other rules based on wins and percentages. It is also checking fight outcomes and trying to determine if the character should be moved up a rank if it won or down if it lost. I think my logic on this is a little too safe, meaning it takes specific circumstances to change a rank. However, I think this is better than the horrible outcomes that could happen considering how much time I spent getting the ranks set to begin with.
So, how has it been working out? in the last 48 recorded fights since I made the last little code change this morning, I have won 38 fights. So roughly about 79% which is very close to my 80% goal. Of course this could end up being 70% very shortly.
Here are the fight results. (Sorry there may be a second Spoiler Block you have to click on)
Only time will tell how it works out. I'll update later tonight once I have much fights under my belt with the new version. However, this does look promising.
Version DONE!!
After 115 matches since this morning, I am sitting at 87 wins and actual positive cash flow coming in.
I believe I have successfully accomplished my goal. Not the 80% I was looking for, but my 75% is now much more lucrative. Before it was 72% on easy bets and was constantly losing money over a period of time. Basically, bet $600, win like $200 after 5 matches and then lose the next 3 matches. That $200, just turned into ($1600). =/
So far since last night constantly betting $600 and starting at $7,000, I am at $22,000. Probably chump change to a lot of players, but I wasn't doing this to make a million dollars in Salty Bux. I just wanted the challenge and I got that considering of how much information I had to go off of. After all is said and done, it boils down to Player 1's name, Player 2's name, and who won and a date. That is all the information I actually used.
There are still some things I would like to do with the application, but I not sure if I will or not. I am calling this a successful project and will continue to record the fights. With the system auto ranking, this whole thing could come crumbling down if my logic is off slightly. So yea, it will probably end up slowly killing itself with shitty rankings. =)
My best bet so far was Fat Boo vs Koopa Troopa ($600 -> $3,817). There have been some really close upsets that would have made me a lot of money. If this thing bets on any of those, I will surely let you know.
Thanks to all for the help.