General Game Playing
Javascript Code Base
General
Artificial
Intelligence


This module is a Javascript implementation of a simple but fully functional general game player. It is intended as a basis for building more interesting players.

In its current form, it plays only legal moves. More interesting behavior can be obtained by redefining the handlers for the five basic communication actions (info, start, play, abort, stop). See descriptions in Chapter 3 of the notes.

The module includes methods that can be used in defining these handlers. Toplevel methods include findroles, findbases, findinputs, findinits, findnexts, findlegalp, findlegalx, findlegals, findnexts, findterminalp, and findreward, as well as the utility methods doesify, undoesify, truify, and untruify (which simply add does and true to expressions). See descriptions in Chapter 4 of the notes.

These methods are, in turn, defined in terms of lower level subroutines, which may be ignored at first but which may be of use in optimizing the player in more advanced players. No documentation on lower level methods; see the code.

To run the player, you need to have nodeJS installed on your machine. To install, see the documentation and installer links at the following site.

https://nodejs.org/en/download/

To download the player, copy the following files to your machine. Be sure that both files are in the same folder/directory on your machine.

http://ggp.stanford.edu/players/javascript/epilog.js http://ggp.stanford.edu/players/javascript/player.js

Once you have installed nodeJS (in nodejsdirectory) and the player code (in playerdirectory), you can start the player by calling the node application with player.js and an optional port number as arguments. In Unix, you would execute the following.

cd playerdirectory
nodejsdirectory/node player.js port

Once you have done this, the server will start on the specified port (or 9147 if no port specified).

Bear in mind that starting your player this way will work but will not produce top performance. You may want to use the REPL and load files that way. The improvement could be as much as an order of magnitude!

To build a better player, modify the definitions in the player.js file. Better yet, create copies of player.js with different strategies and try them all. And you may want to use the capabilities in the following files to further improve the performance of your player.

http://ggp.stanford.edu/players/javascript/grounder.js http://ggp.stanford.edu/players/javascript/ground.js http://ggp.stanford.edu/players/javascript/complier.js http://ggp.stanford.edu/players/javascript/compile.js

Yes, the spelling complier.js here is correct. The ordinary version of the compiler (compiler.js) assumes data indexing. complier.js works for the unindexed datasets / state descriptions that we begin with in this code base. Once you have mastered data indexing, you can switch form complier.js to compiler.js.


Comments and complaints to genesereth@stanford.edu.