King.com Keyword Game Bot

This “bot” (currently more of a calculator) was created to play the game “Keyword” at King.com. The game board is a 5 x 5 grid of letter tiles, the aim in each round is to create the 3 highest scoring words by linking adjacent (horizontal, vertical and diagonal) tiles. Tiles can not be reused.

The main challenges are primarily creating the highest scoring word, but also thoughtfully selecting tiles so as to not block potential 2nd and 3rd words. E.g. it may be more beneficial to play 3 words with mid-range scores, than 1 high scoring word that blocks tiles leaving only low scoring words for the last 2.

For my implementation, I created a WinForms application in C#. The algorithm isn’t too intensive so the overheads of the .Net framework and memory management are acceptable. C# simplifies the coding and WinForms allows quick creation of a GUI. A large dictionary of words stored in a text file is parsed in to a data structure called a Directed Acyclic Word Graph. A DAWG allows quick searching of thousands of potential words. My word list currently contains over 178000 words and a list of every single combination of tiles that produces a valid word in produced in the blink of an eye.

Future improvements:
-Calculating optimum selection for all 3 words.
-Automatic reading in of the game board.

To be continued…

Posted in: Uncategorized by Tom Doidge No Comments , , , , ,

Using POST with AJAX

Nearly all tutorials on using AJAX explain how to implement it using GET. But what if you want to use POST with your AJAX? One reason for using POST over GET is that there is a (large) limit on the length of GET data. A possibly more useful reason is that POST does not have the issues caused by caching that GET does.

The first step is to create an instance of the XMLHttpRequest object. This is the basis of AJAX.

var xmlhttp = new XMLHttpRequest();

Next we set up the variables for our request.

var url = "ajax_post.php";
var content = "param1=val1&param2=val2";

(more…)

Posted in: AJAX, Javascript, PHP by Tom Doidge 2 Comments , , ,