Skip to content

A viewless library to control/validate matches of The Game of the Amazons ♕ Pure & free from side effects

License

Notifications You must be signed in to change notification settings

Forensor/purescript-amazons

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LICENSE Issues Version Purs


Logo

The Game of the Amazons PureScript Engine

A viewless library to control/validate matches of The Game of the Amazons.
Explore the docs »

Report Bug · Request Feature

Contents

About The Project and The Game

Walter Zamkauskas of Argentina devised The Game of the Amazons (El Juego de las Amazonas) in 1988, and it was first published (in Spanish) in issue number 4 of the puzzle magazine El Acertijo in December 1992. It's a territorial strategy game in which both players try to keep their opponent's pieces from moving. Although the game's principles are basic, mastering it takes a lifetime.

The Game of the Amazons PureScript Engine (GAPE) is a project that intends to increase the number of individuals who appreciate the beauty of this magnificent game while also allowing them to contribute in a coordinated manner. That is why, for two key reasons, we believe PureScript is the right language:

  1. It's a Haskell-like strongly-typed functional programming language with excellent features (algebraic data types, pattern matching, higher kinded types, typeclasses...).
  2. It compiles to JavaScript, one of the most widely used programming languages (see GitHut Stats).

There's also an unmaintained TypeScript-based pre-release version here.

back to top

Getting Started

Prerequisites

You will need Node to install the PureScript compiler.

npm install -g purescript

Spago is the recommended package manager and build tool for PureScript.

If you don't have Spago installed, install it now:

npm install -g spago

Complete quickstart guide available here.

Installation

Spago:

spago install amazons

back to top

Usage

Here's a simple example of a random game generator:

module Main where

import Effect
import Effect.Console (log)
import Effect.Random (randomInt)
import Prelude
import Amazons
import Data.Array (index, length)
import Data.Maybe (Maybe(..))

match :: Game -> Effect Unit
match amzns =
  if ended amzns then do
    log $ ascii amzns
    log $ "Game ended. " <> (show $ turn amzns) <> " lost!"
    log $ pgn amzns
  else do
    i <- randomInt 0 (length movs - 1)
    case index movs i of
      Just san -> match $ move amzns san
      Nothing -> log $ "Invalid movement."
  where
  movs = legalMoves amzns

main :: Effect Unit
main = match amazons

Output:

{-
+---------------------+
| . . . x x x b x . x | 10
| x x x . . x x x . x | 9
| . . x x x x x x x x | 8
| x x . . x x x x x . | 7
| b x x x x w x . x x | 6
| x x x . x x x x x w | 5
| . . x x x x . x x . | 4
| x x w x x x . . x . | 3
| b x x x w x x x . . | 2
| b x x . . . x . x x | 1
+---------------------+
  a b c d e f g h i j
Game ended. Black lost!
1. g1g3/e5 d10d3/i8 2. g3f4/d2 g10h10/h4 3. f4d4/g1 d3f1/f5 
4. j4i5/i1 j7f3/b7  5. d4e3/g5 f3e4/f4   6. d1i6/h5 f1b1/d3 
7. i6c6/b6 ...
-}

back to top

Roadmap

  • Refactor piece movement functions
  • Testing with purescript-quickcheck
  • Discuss new names for functions/values
  • Refactor case of case of ... nests in move functions

See the open issues for a full list of proposed features (and known issues).

back to top

Contributing

GAPE needs your help, and it'll be greatly appreciated! Go to the documentation to learn how can you help.

back to top

License

GAPE is distributed under the BSD 2-Clause License. See LICENSE for more information.

back to top

Contact

For inquires about bugs or new feature requests go to contributor's guide. For everything else feel free to DM or send an email! 🙂

Álvaro Sánchez - @Forensor - [email protected]

back to top


The Game of the Amazons PureScript Engine

About

A viewless library to control/validate matches of The Game of the Amazons ♕ Pure & free from side effects

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published