Giter VIP home page Giter VIP logo

ghost's Introduction

Ghost

Functional Specification: Optimal Ghost

In the game of Ghost, two players take turns building up an English word from left to right. Each player adds one letter per turn. The goal is to not complete the spelling of a word: if you add a letter that completes a word, or if you add a letter that produces a string that cannot be extended into a word, you lose. (Bluffing plays and "challenges" may be ignored for the purpose of this puzzle.)

This is a program that allows a user to play Ghost against the computer.

  • The computer play optimally given a dictionary.
  • Allow the human to play first.
  • If the computer thinks it will win, it should play randomly among all its winning moves; if the computer thinks it will lose, it should play so as to extend the game as long as possible (choosing randomly among choices that force the maximal game length).

Technical Specification

Java web application that provides a basic UI for a human to play against the optimal computer player from inside a web browser. The web page makes use of AJAX to update the page as the game progresses. The web framework is JSF.

Despite this project is quite old (2012), it has been used as a proof of concept for playing around with Docker and Google Cloud. Some dependencies have been updated in version 2. However, JSF libraries are still quite old.

Run

Run locally

mvn package
java -jar target/dependency/jetty-runner.jar --port 8080 --path /ghost --config src/main/resources/jetty-realm.xml target/ghost.war

Run on Heroku

https://optimal-ghost.herokuapp.com/ghost/

Run on Local Docker

Build the image locally

If you are on a Windows OS, run Docker QuickStart Terminal. On the root folder (where the Dockerfile is placed), run:

docker build . -t ghost:1.0.0

Run the image

docker run --rm -p 8081:8080 ghost:1.0.0

Run on Docker

https://localhost:8081/

Run on Google App Engine

Deploy the app

gcloud app deploy --promote --stop-previous-version

Run on GCP

Example

gcloud app browse

Changelog

  • 2012-11-27 Version 1.0 Initial skeleton
  • 2012-12-27 Version 1.1 Added site report
  • 2012-12-01 Version 1.2 Initial Release
  • 2012-12-01 Version 1.3 Lombok, java 8 and bugfixing.
  • 2019-02-26 Version 2.0 Upgraded some libs, including spring, dockerized app and moved to java 11.
  • 2019-03-27 Version 2.1.0 Dockerized and setup files for google cloud app engine.

Areas of improvement

This software can be optimized in several ways:

  • Lazy load of the dictionary: the dictionary is loaded after first input from the user, so it contains only the words that start with the input of the user.
    • The software uses 27 times less memory (the charset).
    • There are not caveats in performance.
  • There is not dictionary: Each time the player input the new character, the computer looks for the words in the file, and creates an structure suitable.
    • The use of memory is minimum.
    • The performance is reduced because the I/O operations in the file.

ghost's People

Contributors

luchoct avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.