All Projects → Daenyth → taklib

Daenyth / taklib

Licence: AGPL-3.0 License
A scala library for the Tak board game

Programming Languages

scala
5932 projects

Projects that are alternatives of or similar to taklib

Wolf.engine
The Wolf is a comprehensive set of C/C++ open source libraries for realtime rendering, realtime streaming and game developing
Stars: ✭ 230 (+1337.5%)
Mutual labels:  game-engine
Panda3d
Powerful, mature open-source cross-platform game engine for Python and C++, developed by Disney and CMU
Stars: ✭ 3,035 (+18868.75%)
Mutual labels:  game-engine
Nico
Nim Game Framework based on Pico-8
Stars: ✭ 254 (+1487.5%)
Mutual labels:  game-engine
Openpal3
仙三开源版 - The efforts to create an open-source implementation of Chinese Paladin 3
Stars: ✭ 239 (+1393.75%)
Mutual labels:  game-engine
Ecere Sdk
Ecere SDK (eC Language, Ecere IDE, Cross platform GUI, graphics, and more) — http://ec-lang.org —
Stars: ✭ 244 (+1425%)
Mutual labels:  game-engine
Octopuskit
2D ECS game engine in 100% Swift + SwiftUI for iOS, macOS, tvOS
Stars: ✭ 246 (+1437.5%)
Mutual labels:  game-engine
Nebula
Nebula is an open-source and free-to-use modern C++ game engine.
Stars: ✭ 224 (+1300%)
Mutual labels:  game-engine
TakServer
Server to handle online TAK games
Stars: ✭ 33 (+106.25%)
Mutual labels:  tak
Ml Games
Machine learning games. Use combination of genetic algorithms and neural networks to control the behaviour of in-game objects.
Stars: ✭ 247 (+1443.75%)
Mutual labels:  game-engine
Fxtutorials
A collection of JavaFX tutorials from my channel on YouTube
Stars: ✭ 252 (+1475%)
Mutual labels:  game-engine
Luascript
Lua language support for Godot Engine
Stars: ✭ 240 (+1400%)
Mutual labels:  game-engine
Polymer
🎨 graphics + interaction engine
Stars: ✭ 243 (+1418.75%)
Mutual labels:  game-engine
Px3d
Experimental pixel 3d engine
Stars: ✭ 252 (+1475%)
Mutual labels:  game-engine
Inline Engine
Game engine written in C++ with ease of use and next-gen parallel computing in focus.
Stars: ✭ 237 (+1381.25%)
Mutual labels:  game-engine
Cocos2d X
Cocos2d-x is a suite of open-source, cross-platform, game-development tools used by millions of developers all over the world.
Stars: ✭ 15,713 (+98106.25%)
Mutual labels:  game-engine
Vulkanlearn
Render lab built on top of vulkan, aiming to create a real time planet scale large scene. Also some widely adopted techs are implemented, such as deferred rendering, physical based rendering, bloom, screen space ambient occlusion, screen space reflection, depth of field, skeleton animation, etc
Stars: ✭ 232 (+1350%)
Mutual labels:  game-engine
Gdevelop
🎮 GDevelop is an open-source, cross-platform game engine designed to be used by everyone.
Stars: ✭ 3,221 (+20031.25%)
Mutual labels:  game-engine
RamenEngine
A game engine written in SwiftForth.
Stars: ✭ 53 (+231.25%)
Mutual labels:  game-engine
FreeTAKUAS
DJI drone flying app with integrations for FreeTAKServer
Stars: ✭ 41 (+156.25%)
Mutual labels:  tak
Simplerenderengine
Small C++14 render engine
Stars: ✭ 253 (+1481.25%)
Mutual labels:  game-engine

taklib

A scala library for the Tak board game

Build Status Coverage Status Codacy Badge

Example usage

import com.github.daenyth.taklib._
val invalid: Either[String, Game] = Game.fromTps("invalid")
// invalid: Either[String,com.github.daenyth.taklib.Game] = Left(`[' expected but `i' found)
val game = Game.fromTps("[ 1,2,1,2,1/2,1,2,1,2/1,2,1,2,1/2,1,2,1,2/1,2,1,2,1 12 2 ]").getOrElse(throw new Exception)
// game: com.github.daenyth.taklib.Game = com.github.daenyth.taklib.Game@78c4cfdd
val winner = game.winner
// winner: Option[com.github.daenyth.taklib.GameEndResult] = Some(FlatWin(White))
val game = Game.ofSize(6).getOrElse(throw new Exception())
// game: com.github.daenyth.taklib.Game = com.github.daenyth.taklib.Game@5cf72de5
val winner = game.winner
// winner: Option[com.github.daenyth.taklib.GameEndResult] = None
val next: MoveResult[Game] = game.takeTurn(PlayFlat(Black, BoardIndex(1, 1)))
// next: com.github.daenyth.taklib.MoveResult[com.github.daenyth.taklib.Game] = OkMove(com.github.daenyth.taklib.Game@66f6a349)

Release status

Taklib is currently alpha status - there may be bugs and the api is not stable yet

What you can do now

  • Create new games with an empty board
  • Create a new game from a TPS string
  • Create a (potentially completed) game from a PTN file, including games beginning with TPS tags
  • Play moves that are checked for validity
  • Detect all game-ending conditions
  • Run a rudimentary interactive mode on the command line
  • Add your own custom game rules
  • Run an HTTP REST server that accepts tps and move input, returning tps.

Interactive game on the command line

sbt takcli/run

TPS Server

sbt tpsserver/run

The server runs on localhost:8080 and listens for POST requests to /tpsMove with a json payload like

{
  "tps" : "x6/x6/x6/x6/x6/x6 1 1",
  "move" : "a1"
}

For example:

# python
import requests
requests.post("http://localhost:8080/tpsMove", json={
  "tps" : "x6/x6/x6/x6/x6/x6 1 1",
  "move" : "a1"
}).json()
# {u'OkMove': {u'nextState': u'1,x,x,x,x,x/x,x,x,x,x,x/x,x,x,x,x,x/x,x,x,x,x,x/x,x,x,x,x,x/x,x,x,x,x,x 2 1'}}

requests.post("http://localhost:8080/tpsMove", json={
  "tps" : "invalid",
  "move" : "a1"
}).json()
# {u'errors': [u"TPS: string matching regex `(1|2)+[SC]?' expected but `i' found"]}

requests.post("http://localhost:8080/tpsMove", json={
  "tps" : "1,1,1,1,1,x/x6/x6/x6/x6/x6 1 1",
  "move" : "a6"
}).json()
# {u'GameOver': {u'finalState': u'1,1,1,1,1,1/x,x,x,x,x,x/x,x,x,x,x,x/x,x,x,x,x,x/x,x,x,x,x,x/x,x,x,x,x,x 2 1',
#   u'result': {u'RoadWin': {u'player': {u'White': {}}}}}}

The exact json structure is likely going to be changed. Right now it's automatically derived from the internal representation, rather than being designed to be easy to use directly.

Add custom rules

Create a RuleSet to make new games with

scala> Game.ofSize(7, DefaultRules)
res0: Either[String,com.github.daenyth.taklib.Game] = scala.Left(Bad game size: 7)

// A new variant with a size-7 board that has 40 flatstones and 7 capstones per player!
scala> Game.ofSize(7, new RuleSet {
     | val rules = DefaultRules.rules
     | val expectedStoneColor = DefaultRules.expectedStoneColor
     | val stoneCounts = DefaultRules.stoneCounts + ((7, (40, 7)))
     | })
res1: Either[String,com.github.daenyth.taklib.Game] = scala.Right(com.github.daenyth.taklib.Game@517564bf)

Goals

  • Easy to use
  • Type safe interface
  • Thread safe - taklib is fully based off immutable data structures, so is inherantly thread safe
  • Able to support branching history with arbitrary rollback/rollforward (not implemented yet)

Non-goals

  • Not aiming to be the fastest runtime - I'm not benchmarking anything until the project is much more stable.
  • Stable API - for now. This is a new library, and so the api can change without notice as I find better ways to do things.
  • Supporting scala.js - for now. It should be possible with little effort but it's not a priority. Patches welcome
  • Scalaz usage. Taklib will only support cats

Testing

sbt test

License

Taklib is under the AGPL3. For more information, see COPYING

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].