Skip to content

ascheman/tictactoe

Repository files navigation

Library update status: Dependency Status (Powered by VersionEye)

Groovy/Gradle Tic Tac Toe project

This is a simple Tic Tac Toe project implemented (mostly) in Groovy (in fact it is a so called Groovlet). The project can be build and executed with Gradle.

Start

You may simply check out the project from GitHub and run the command

gradlew jettyRun

This will load all necessary stuff from the Internet, compile everything and start a Jetty Servlet Engine on localhost (Port 58080, Context /tictactoe-web).

HTTP Get Requests

Now you can connect your browser to http://localhost:58080/tictactoe-web/simple.groovy and see what happens.

The application understands a number of commands as HTTP Get Requests. Simply use the URL encoded CMD parameter, e.g. http://localhost:58080/tictactoe-web/simple.groovy?CMD=HELP:

Error handling

The simple.groovy implementation only provides restricted error handling, it only checks whether

  • a CMD is valid
  • a field is already occupied
  • a coordinate is valid
  • a stone value is valid

Output formats

Per default the simple implementation returns a single line with the Board (only used fields with their contents) or an error or other status. Only for the HELP command you will see some more lines. If the optional parameter FORMAT is set to HTML the result is sent in very simple HTML code (please, don’t validate!).

Session handling/Cookies

Since the implementation is Groovlet (the Groovy variant of Java Servlets) based, it make use of a JSESSIONID cookie to allow for multiple users to play a game on their own.

Variants

Currently there is only the simple.groovy implementation which just provides a Board and only checks that there is only one stone on a field – Nothing else!
Feel free to improve and implement other variants, e.g.,

  • HTML pretty printer which will draw a nice 3×3 playground
  • Forms or JavaScript to place stones
  • Computer player
  • URL encoded session handling
  • Socket variant
  • Plain Java

Runtime environments

The implementation has been tested on different runtimes:

About

Simple tictactoe implementation

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages