All Projects → vitogit → Vue Chessboard

vitogit / Vue Chessboard

Licence: gpl-3.0
Chessboard vue component to load positions, create positions and see threats

Projects that are alternatives of or similar to Vue Chessboard

Game Server
Distributed Java game server, including cluster management server, gateway server, hall server, game logic server, background monitoring server and a running web version of fishing. State machine, behavior tree, A* pathfinding, navigation mesh and other AI tools
Stars: ✭ 916 (+740.37%)
Mutual labels:  chess
Chessli
A free and open source chess improvement app that combines the power of Lichess and Anki.
Stars: ✭ 64 (-41.28%)
Mutual labels:  chess
Stockfish
Integrates the Stockfish chess engine with Python
Stars: ✭ 75 (-31.19%)
Mutual labels:  chess
Cc65 Chess
Portable chess game in C. Commodore 64, Apple 2, Atari, Oric, Commander X16, curses terminal, etc.
Stars: ✭ 21 (-80.73%)
Mutual labels:  chess
Lichobile
lichess.org mobile application
Stars: ✭ 1,043 (+856.88%)
Mutual labels:  chess
Pgn2gif
A small tool that generates gif of a chess game
Stars: ✭ 65 (-40.37%)
Mutual labels:  chess
Chess Variants Training
Chess Variants Training is a website where you can improve at chess variants.
Stars: ✭ 18 (-83.49%)
Mutual labels:  chess
Chess Inspector
Visualize move, protection and threat status
Stars: ✭ 94 (-13.76%)
Mutual labels:  chess
Galvanise zero
Learning from zero (mostly based off of AlphaZero) in General Game Playing.
Stars: ✭ 60 (-44.95%)
Mutual labels:  chess
Lila
♞ lichess.org: the forever free, adless and open source chess server ♞
Stars: ✭ 10,315 (+9363.3%)
Mutual labels:  chess
Countergo
UCI chess engine (golang)
Stars: ✭ 32 (-70.64%)
Mutual labels:  chess
Ostinato
A chess library that runs on the server (Scala) and on the browser (ScalaJS).
Stars: ✭ 42 (-61.47%)
Mutual labels:  chess
Lichs
♟ Play chess against real players in your terminal using Lichess
Stars: ✭ 70 (-35.78%)
Mutual labels:  chess
Colamone js
A two-player strategy board game /オリジナルのボードゲームを作ってみる。
Stars: ✭ 13 (-88.07%)
Mutual labels:  chess
Arasan Chess
Arasan chess engine
Stars: ✭ 75 (-31.19%)
Mutual labels:  chess
Ancientbeast
Turn Based Strategy Game. Master your beasts! 🐺
Stars: ✭ 907 (+732.11%)
Mutual labels:  chess
Download
UI mod for Dota 2 Auto Chess that adds several QoL improvements to the UI
Stars: ✭ 65 (-40.37%)
Mutual labels:  chess
Python Chess
A chess library for Python, with move generation and validation, PGN parsing and writing, Polyglot opening book reading, Gaviota tablebase probing, Syzygy tablebase probing, and UCI/XBoard engine communication
Stars: ✭ 1,341 (+1130.28%)
Mutual labels:  chess
Allie
Allie: A UCI compliant chess engine
Stars: ✭ 89 (-18.35%)
Mutual labels:  chess
React Chessground
React wrapper of Chessground
Stars: ✭ 71 (-34.86%)
Mutual labels:  chess

vue-chessboard

npm npm vue2

Chessboard vue component to load positions, create positions and see threats

  • It uses chess.js for chess movements and validations
  • It uses chessground for chessboard UI chessground

http://g.recordit.co/40JDuy8tAk.gif

Check live examples: http://vitomd.com/vue-chessboard-examples/

Table of contents

Installation

npm install --save vue-chessboard

Default component import

import {chessboard} from 'vue-chessboard'
import 'vue-chessboard/dist/vue-chessboard.css'

Then use it in your template

    <chessboard/>

Browser

<div id="app">
  <chessboard></chessboard>
</div>

<link rel="stylesheet" href="vue-chessboard/dist/vue-chessboard.css"/>

<script src="vue.js"></script>
<script src="vue-chessboard/dist/vue-chessboard.browser.js"></script>

<script>
new Vue({
  el: '#app',
  components: {
    VueChessboard
  }
});
</script>

Examples

Check live examples: http://vitomd.com/vue-chessboard-examples/

Check live examples repository: https://github.com/vitogit/vue-chessboard-examples

Check full application using the component: Chess Guardian

Simple Chessboard with legal moves

  <chessboard/>

Simple Chessboard with free moves

  <chessboard :free="true"/>

Simple Chessboard with black orientation. Default is white

  <chessboard orientation="black"/>

Simple Chessboard that shows threats for current position and player

  <chessboard :showThreats="true"/>

Fen binded to the chessboard (load position when click on a new position)

  <chessboard :fen="currentFen"/>
  <button class="button is-light" @click="loadFen(fen)" v-for="fen in fens">
    {{fen}}
  </button>

Chessboard with onmove callback. Returns positional info { "legal_black": 20, "checks_black": 0, "threat_black": 0, "turn": "black" } after each move.

It also returns the fen and the history data.

  <chessboard @onMove="showInfo"/>
  <div>
    {{this.positionInfo}}
  </div>
showInfo(data) {
  this.positionInfo = data
}

Chessboard with onpromote callback

When there is a promotion it will execute the callback. Just return the first letter of the piece: q:Queen, r:Rook, k:Knight, b:Bishop

  <chessboard :onPromotion="promote"/>
promote() {
  return 'r' // This will promote to a rook
}

Extended Component (Play vs random AI).

You can extend the chessboard component to add new methods

  // newboard.vue
  <script>
  import { chessboard }  from 'vue-chessboard'

  export default {
    name: 'newboard',
    extends: chessboard,
    methods: {
      userPlay() {
        return (orig, dest) => {
          if (this.isPromotion(orig, dest)) {
            this.promoteTo = this.onPromotion()
          }
          this.game.move({from: orig, to: dest, promotion: this.promoteTo}) // promote to queen for simplicity
          this.board.set({
            fen: this.game.fen()
          })
          this.calculatePromotions()
          this.aiNextMove()
        };
      },
      aiNextMove() {
        let moves = this.game.moves({verbose: true})
        let randomMove = moves[Math.floor(Math.random() * moves.length)]
        this.game.move(randomMove)

        this.board.set({
          fen: this.game.fen(),
          turnColor: this.toColor(),
          movable: {
            color: this.toColor(),
            dests: this.possibleMoves(),
            events: { after: this.userPlay()},
          }
        });
      },
    },
    mounted() {
      this.board.set({
        movable: { events: { after: this.userPlay()} },
      })
    }
  }
  </script>

Want to see all my chess related projects?

Check My projects for a full detailed list.

License

GPL-3.0

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