Automating SaltyBet - My Live and Ongoing Adventure - DONE!!

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 database to track as many statistics as I can in order to predict fight outcomes.
  • Record wins/losses
  • Allow 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.

No one can touch Alien Queen!

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.

I wonder if this will actually ring true. My data does not show they have fought yet.

Current prediction stats after implementing new rules:

WinsLosses
All Predictions1438164%
New Rule Set19773%
New Rule Set - Without Falling Back to Random Choice17480%

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)

FightWagerWinnerPayoutDate (EST)
Rubber soul vs Haggar600 on HaggarHaggar12August 13, 2013 6:23pm
Flandre scarlet vs Kim600 on KimKim4538August 13, 2013 6:20pm
Kujo jotaro vs Goku sb1600 on Kujo jotaroKujo jotaro31August 13, 2013 6:16pm
Robo-kyii vs Lei lei600 on Lei leiLei lei57August 13, 2013 6:12pm
Regina vs Kamiccolo600 on KamiccoloKamiccolo209August 13, 2013 6:08pm
Venom vs Dan600 on DanDan411August 13, 2013 6:03pm
Neco-arc vs Renamon600 on Neco-arcNeco-arc19August 13, 2013 5:59pm
Lei-lei vs Frieza600 on FriezaFrieza1319August 13, 2013 5:56pm
Change dragon vs Dragon claw600 on Dragon clawDragon claw6August 13, 2013 5:52pm
Gohan fight money vs Jay garrick600 on Jay garrickJay garrick207August 13, 2013 5:45pm
Minoriko aki vs Red ranger600 on Red rangerMinoriko aki-600August 13, 2013 5:43pm
Team reimisen vs Namor600 on Team reimisenTeam reimisen39August 13, 2013 5:39pm
The joker vs Misty600 on MistyMisty94August 13, 2013 5:35pm
Batman beyond vs Kenshiro600 on Batman beyondBatman beyond17August 13, 2013 5:32pm
Dio brando vs Silversamurai600 on SilversamuraiSilversamurai5August 13, 2013 5:29pm
Jason todd vs Nayuki minase600 on Nayuki minaseJason todd-600August 13, 2013 5:26pm
Visbou vs Fat albert600 on Fat albertFat albert26August 13, 2013 5:22pm
Harley quinn vs Jiroubou600 on Harley quinnHarley quinn123August 13, 2013 5:17pm
Gotenks gt vs Rogue600 on RogueGotenks gt-600August 13, 2013 5:14pm
Flash vs Kszsk-shuko600 on Kszsk-shukoFlash-600August 13, 2013 5:09pm
Ella vs (sman)600 on EllaElla507August 13, 2013 5:06pm
Dio vs Recoome600 on DioDio34August 13, 2013 5:01pm
The atom vs Goku ssj5600 on The atomThe atom44August 13, 2013 4:59pm
Trunks vs Mega weapon600 on Mega weaponMega weapon5August 13, 2013 4:55pm
Vegeta vs Dio600 on VegetaVegeta217August 13, 2013 4:52pm
Missmarvel vs Ash600 on AshMissmarvel-600August 13, 2013 4:49pm
Zombie vs Arrange_unknown600 on Arrange_unknownArrange_unknown11August 13, 2013 4:45pm
Ultraman vs Ky600 on KyUltraman-600August 13, 2013 4:42pm
Ryu vs Kaio shin600 on RyuRyu56August 13, 2013 4:38pm
Marvin vs Marrow600 on MarvinMarvin373August 13, 2013 4:34pm
Dark psylocke vs K' xiii600 on Dark psylockeDark psylocke309August 13, 2013 4:30pm
Kuma vs Jack frost600 on KumaJack frost-600August 13, 2013 4:26pm
Billy lee vs Asahina mikuru600 on Billy leeBilly lee26August 13, 2013 4:23pm
Rouge vs Harpagos600 on HarpagosHarpagos1786August 13, 2013 4:20pm
Ssj gohan vs Axl600 on AxlSsj gohan-600August 13, 2013 4:17pm
Uryuu vs Setsuna600 on SetsunaSetsuna16August 13, 2013 4:12pm
Think vs Neco600 on NecoNeco31August 13, 2013 4:09pm
Hotaru vs Ryu600 on RyuRyu388August 13, 2013 4:02pm
Bison vs Helion600 on HelionBison-600August 13, 2013 3:54pm
Milan flare vs Senna vp600 on Milan flareSenna vp-600August 13, 2013 3:51pm
Karen na hito vs Archer600 on ArcherArcher233August 13, 2013 3:44pm
Aura vs Exocist(dnf)600 on AuraAura10August 13, 2013 3:41pm
Batgirl vs Koryu600 on KoryuKoryu7August 13, 2013 3:38pm
Great s. man vs Batgirl600 on Great s. manGreat s. man225August 13, 2013 3:30pm
Namazu vs Yuri di aaaaaaa600 on NamazuNamazu18August 13, 2013 3:26pm
Mystique vs Chibi ubuu600 on MystiqueMystique66August 13, 2013 3:23pm
2k vs Kamek600 on KamekKamek14August 13, 2013 3:19pm
Psycho weapon vs Lex luthor600 on Lex luthorLex luthor34August 13, 2013 3:16pm

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.

83 Comments