Giter Site home page Giter Site logo

kpi19 / jsxiangqi Goto Github PK

View Code? Open in Web Editor NEW

This project forked from leidzhang/jsxiangqi

0.0 0.0 0.0 337 KB

Chinese chess game built in HTML, CSS, and JavaScript, currently unable to against AI

License: Apache License 2.0

JavaScript 77.46% CSS 3.37% HTML 19.17%

jsxiangqi's Introduction

JSXiangqi

Introduction

I created This simple web-based Xiangqi game with JavaScript, HTML, and CSS. Xiangqi is a traditional Chinese board game that is similar to chess but with some unique rules and pieces. You can play this game against a friend on the same device, and the function against a basic AI opponent is developing.

Features

  • A 9x10 board with 32 pieces representing two armies: red and black.
  • Click interface for moving the pieces.
  • Basic rules enforcement and checkmate detection.
  • A reset button to start a new game.
  • The game will stop if one of the general is checkmated.

How to Play

To start the game with Node.js backend, run npm install and npm start in the terminal, then open VS Code and open with live server. To start the game without Node.js backend, click https://leidzhang.github.io/JSXiangqi/. To move a piece, click it and then click an empty or occupied intersection on the board. If the move is valid, the piece will be placed there. If not, the piece will stay at its original position. The goal of the game is to checkmate the opponent’s general, who resides in a 3x3 palace at the center of the back rank. To start a new game, click on the "New Game" button.

Project Preview

Initial pieces layout.

The chessboard is assembled with two stacked tables, one for the visible grid and one for the invisible nodes, since the pieces are placed on the intersections of the grid lines. the gray table on the right records the moves of both players.

Check Detection

The red cannon is checking the black general, but the black side can use chariot to kill the cannon to rescue the general, so the red side did not win.

Checkmate Detection

Now the black general is checked by a red chariot, and there is no way that a black piece can rescue the general, so the black side is checkmated and the red side wins the game.

Endgame Selection

By choosing the options of the dropdown menu, various endgames on the board can be selected.

License

This project is licensed under the Apache-2.0 license - see the LICENSE file for details.

Feedback

If you have any feedback or suggestions for this project, feel free to open an issue on GitHub. I hope you enjoy playing this game!

jsxiangqi's People

Contributors

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