A viewless library to control/validate matches of The Game of the Amazons.
Explore the docs »
Report Bug
·
Request Feature
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:
- It's a Haskell-like strongly-typed functional programming language with excellent features (algebraic data types, pattern matching, higher kinded types, typeclasses...).
- 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.
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.
Spago:
spago install amazons
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 ...
-}
- 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).
GAPE needs your help, and it'll be greatly appreciated! Go to the documentation to learn how can you help.
GAPE is distributed under the BSD 2-Clause License. See LICENSE for more information.
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]
The Game of the Amazons PureScript Engine