GithubHelp home page GithubHelp logo

steshaw / hsgames Goto Github PK

View Code? Open in Web Editor NEW

This project forked from abailly/hsgames

0.0 1.0 0.0 95.67 MB

A client-server Haskell implementation of an old boardgame

License: Apache License 2.0

Haskell 18.80% HTML 39.72% Elm 10.30% CSS 2.60% Shell 0.07% Dockerfile 0.33% Idris 27.95% Python 0.23%

hsgames's Introduction

Acquire in Haskell + Elm

This is an implementation of the Acquire boardgame as a client-server online game, using Haskell as a backend and game engine, and Elm . It is a not-so-quick-still-dirty implementation but in the few tests I already make, it appears playable at least locally.

An instance is deployed on Clever Cloud. Open this page to start playing Acquire online.

Overview

The game can be played in two different ways:

  • As a pure text-based client-server, using an ANSI capable terminal,
  • Using an HTML interface.

The core game server itself is of course agnostic about which front-end it is played with:

  • It can host several games concurrently,
  • Client players can create a new game or list existing games,
  • Client players can join an existing non-started game.

Building

Run stack build in top-level directory, this will build all needed executables.

Command-Line Mode

Getting Started

To play in solo mode against robots, run the following commands in the source tree, assuming you are using stack to build code (works equally well with cabal with more incantations):

Start a Server

$ stack init
$ stack build
$ stack exec hsg -- server

The server supports a single option -p <port> to select the port it listens to. If passed 0, it will listen on a random port and print it on stdout:

$ stack exec hsg -- server -p 0
[2016-10-05 14:07:20.538190000000 +0000] garbage collecting
[2016-10-05 14:07:20.534807000000 +0000] Server started on port 54824

Create a New Game

Open another terminal and run:

$ stack exec hsg --  newGame -H 1 -R 5
created new game DBEGXBIZ

This creates a new game with one human and five robot players.

The newGame command supports the following option:

Usage: hsg newGame [-h|--host HOST] [-p|--port PORT] [-H|--num-humans NUMBER]
                   [-R|--num-robots NUMBER]

To check a game is available, use the list command:

$ stack exec hsg -- list
DBEGXBIZ 3 humans, 3 robots, []

The list command supports the following option:

Usage: hsg list [-h|--host HOST] [-p|--port PORT]

Start Playing

Assuming you created the above defined solo game, you can connect as a player to start playing the game:

$ stack exec hsg -- player -g DBEGXBIZ -n arnaud
registering arnaud with server at address 127.0.0.1:7890
registered player arnaud with game DBEGXBIZ
starting game DBEGXBIZ

The player command as the following options:

Usage: hsg player [-h|--host HOST] [-p|--port PORT] (-n|--player NAME)
                  (-g|--game GAME ID) [-t|--player-type PLAYER-TYPE]

The --player name and --game ID parameters are mandatory.

You should see something like the following:

To play, type the selected number before the list of possible plays and press Enter. Refer to the rules of the game for further directions.

Web-based UI

To start web server, run the following command:

$ stack exec server

There currently aren't any option. Server starts on port 9090 and should be accessed locally

Building UI

$ cd ui
$ elm-make src/Acquire.elm --output=acquire.js

Playing

  • Point your browser at http://localhost:9090/index.html to load the UI.
  • Enter your Player Name in the related field,
  • Click on List Games. If there are saved games, you should see them listed, otherwise you can create a new game, selecting the number of humans and robot players and clicking on New Game,
  • To start playing a game, click on Join. If the required number of human players is connected, the game starts and the board is displayed.
  • If its your turn to play, you should see boxes appearing in the Possible Plays area: Click on a box to select that play,
  • On the top right, there is Messages box whose visibility can be toggled on and off: It lists all messages sent by server and notably all other player's plays, most recent first.

Screenshots

Some details

  • Server saves game state between each order in a file .acquire.<game-id>.bak in its working directory,
  • If a saved game exists in working directory, server loads it and continues game from the saved point. This means if something goes wrong, it's enough to restart server and get back to last play,

hsgames's People

Contributors

abailly avatar symbiont-arnaud-bailly avatar steshaw avatar

Watchers

 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.