GreyWyvern.com

Keyboard Milestone & A New Widget

Jun 11, 2009

Today my Virtual Keyboard Interface javascript reached the 10,000 install milestone at userscripts.org. It was originally posted on the site about 23 months ago, so a rate of 435 downloads per month is not too shabby ;) At that time, the script came with about a dozen different keyboard layouts. Since then, that number has almost tripled to 34 different layouts! Big thanks to all of the contributors for making this a truly excellent international effort.

I don't really have any more big plans for the script, but I will continue to keep updating it and adding more keyboards as they are offered to me. I'm very happy so many people have found it useful, even if that use is not what I originally designed the script for. I got a lot of linking from various tech sites a few months ago which presented the script as a defense against keyloggers. However, I still maintain that its most useful features are a) the ability to use a "keyboard" even if only a mouse is hooked up to the computer, and b) the ability to easily key special characters into forms.

Thanks to everyone for your support!

In other news, after a two and a half year hiatus from the widget arena, I decided to throw my hat into the ring once more. This time around, I built a colourful video poker widget that plays like the real thing, except not for real money ;)

ImageIt turned out to be more of a challenge than I originally anticipated, especially after I made the decision to include a trainer algorithm adapted from strategy lists at The Wizard of Odds website. As a human being scanning a selection of five cards, it's easy to spot the patterns that differentiate a winning hand from a losing hand. However, teaching a computer to recognize those patterns is pretty much an exercise in brute force examination. In fact, not counting the base64 embedded audio/x-wav samples, the strategy trainer function takes up roughly half of the entire widget javascript!

Hrms... things that I learned from this. It seems everytime I build a widget (or some tight and complex app), I end up running into some quirk of the HTML or DOM specifications which I turn to TarquinWJ to explain to me :D This time it was generated content (::before and ::after) on <img> elements. Apparently, the specifications expressly forbid generated content on "replaced" elements like <img> because the browser treats them differently than normal block-level elements. However, Opera supports generated content on <img> elements (for now) which is why I was confused when I set up the widget as a webpage and found that it didn't work in Firefox and Chrome. I didn't know why either, other than drawing the conclusion that Opera was awesome and Firefox and Chrome were so much compiled junk :D

Not so! TarquinWJ informed me. Actually both Firefox and Chrome get it right, and Opera could be accused of jumping the gun on implementing a feature that was eventually decided against. Anyway, I was fooled, and ended up scrapping the generated content and doing things another way in version 1.1 of the widget.

Another thing I learned was that the rules governing which cards are the best to hold to maximize your expected return in video poker are very complex. In some cases, the cards you throw away might have a large enough effect on the weighted return, that it may make sense to keep them instead. For example, in Deuces Wild, if your intial poker hand consists of three wild cards and a pair, you should keep the pair only if they are 10 or higher.

:? Huh? At first, this seems odd because you don't get any special bonus in Deuces Wild for a Five of a Kind 10 or higher. Five of a Kind threes pays the same as Five of a Kind kings; so why keep a high Five of a Kind, but discard a low one? The answer lies in the cards you would have to throw away.

The highest hand you can get with three wild cards in Deuces Wild is a Wild Royal Flush, and to get one, you need two suited cards, 10 or higher. If you discard a pair of 10s or higher in order to try for such a hand, those cards are no longer in the pool of cards from which new cards will be selected to replace the discard. Because both cards were potentially part of a Wild Royal Flush themselves this lowers the chance of getting a Wild Royal Flush by just enough that it is better strategy, in the long run, to keep the Five of a Kind. On the other hand, if the pair you have is 9 or lower, discarding them does not reduce your chances of getting a Wild Royal Flush, so it makes sense, over the long run, to discard that pair and try for a better hand. Kudos to whoever calculated the odds on that one, because my brain is hurting already!

Not surprisingly, the rules get even more complex than that, and the absolute optimum strategy was just too complex to implement without extending development time threefold or more :) So I ended up using the intermediate strategies for each game as offered on The Wizard of Odds website. Before you consider this a travesty, note that the difference in expected return between the intermediate and optimum strategies are a few hundredths of a percent at most!

Anyway, I hope you like the new widget! I had a lot of fun building it and, have to admit, got a little bit addicted to playing it while I should have been developing it, so it took a little longer to release than I expected ;)

Now it's on to bigger and better things! In particular... :O

Single line JavaScript integer variable swap HEAD Request Nonsense

Comments closed

Recent posts

  1. Iguana no Musume / Iguana Girl Aug 2016
  2. What I'd Like To See In The Elder Scrolls VI - Part 2 Aug 2015
  3. What I'd Like To See In The Elder Scrolls VI Jul 2015
  4. Cyprus, and what capitalists want Mar 2013
  5. Let interest rates on housing rise Sep 2012
  6. Archive

Items of Interest

Webcomics Reading List

Good Eats

Twitter RSS 2.0 Valid XHTML 1.0! Copyright © 2017 Brian Huisman AKA GreyWyvern
ContactSite mapSearch