Code Monkey home page Code Monkey logo

lpb-client's Introduction

About Letterpress Battle

Letterpress is a great iPhone/iPad game by Loren Brichter.

After playing Letterpress happily for several hours, @baotuo and I decided to build a cheater to get all usable words in one game. And the faster one wins.

And after the solver project, which @baotuo's won the first round and I won the second, we decided to continue the competition with game AIs. A tool to monitor and tune the AIs is need by both of us, and that's why ‘Letterpress Battle’ (aka LPB) comes from.

The main purpose of LPB is to let the game AIs build by me and @baotuo to battle together with a common set of APIs. You can fight the AIs too if you like.

LPB Client API

Two class is provided in this API.

One is LPBClient, which support the following server API

  • create - Create a game with a 25-characters board
  • list - List all games
  • join - Join a game
  • move - Take a move
  • resign - Resign a game
  • show - Show game statistics

The other is LPBConsole, which is a interactive to play the game in console.

Example

An runnable example can be found in Letterpress Solver project.

The main concept is like below:

var program = require('commander')
  , lpb = require('lpb-client');

program
  .version('0.0.1')
  .option('-s, --server [url]', 'Base URL of the server')
  .option('-p, --player [player]', 'Unique player ID')
  .parse(process.argv);

...

if (program.server && program.player) {
  c = lpb.LPBConsole(program.server, program.player);

  // logic to handle the move
  function takeMove() {
  	...
  }

  // logic to init the game board
  function prepareBoard(data) {
  	...
  }

  // logic to init the game board
  function applyMove(data) {
  	...
  }

  c.on('join', prepareBoard);

  c.on('ourmove', takeMove);

  c.on('theirmove', function(move) {
    applyMove();
    c.emit('ourmove');
  });

  c.start();
} else {
  program.outputHelp();
}

lpb-client's People

Contributors

rjyo avatar

Watchers

 avatar  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.