K
K
krll-k2015-01-29 03:12:32
JavaScript
krll-k, 2015-01-29 03:12:32

Developing a chess game in JavaScript: where to start?

How to store information about the movement of pieces on the field?
So if you imagine chess as just a set of states of game pieces on the field, then the question arises - How to implement this very different state using JavaScript?
What would experienced igrodely who already write in EcmaScript advise?
If the question is suddenly not clear - feel free to write comments

Answer the question

In order to leave comments, you need to log in

4 answer(s)
M
maaGames, 2015-01-29
@krll-k

There is a wonderful book "Programming chess and other logic games". Very thin, though written for C++ programmers. I highly recommend, you will figure out how to represent the moves in memory and how to write a recursive algorithm more or less tolerably.

K
krll-k, 2015-01-29
@krll-k

Forsythe-Edwards Notation (FEN)
FEN describes a position on a chessboard as a string of ASCII characters.
Starting position of the chess game:
rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1
rnbqkbnr — location of pieces on the 8th horizontal from left to right, / — separator,
pppppppp — location of the pieces on the 7th horizontal ,
8/8/8/8 - empty 6-5-4-3 ranks,
PPPPPPPP - arrangement of pieces on the 2nd rank,
RNBQKBNR - arrangement of pieces on the 1st rank,
w - white moves ahead, KQkq - possible short and long castles of white and black, there was no previous two-square pawn move (-), there were no last moves without captures or movement of pawns (0), the first move is ahead (1)

W
Weziw, 2015-01-29
@Weziw

Можно использовать матрицы :)

Владлен Грачев, 2015-01-29
@gwer

Сделать объект поля. У него множество объектов фигур. Каждый из объектов фигур, в свою очередь, помимо особенностей фигуры (например, возможные ходы) содержит координаты на поле. Состояние — это совокупность всех фигур на поле с их координатами.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question