Data Structures and Algorithms

Before starting with actual encoding of chess data, its good if you know the basic concept of Data Structure and Algorithm. Hence I have put it first. Also it is good if you know some well known techniques of encoding data. I have added some explanation in "Coding Techniques" page. After that the real encoding starts from "Board Representation"

Data structures and Algorithms

Data Structure:

In computer programming parlance a particular format of information that can be interpreted by a computer would be a data structure. In other words all encoding of information done for computer processing is a data structure.

E. g. For chess programming we will assign numerical values for chess colour - white will be 0, black will be 1 etc. This process would be called encoding and the particular piece of information (chess colour in this case) would be a data structure.

Algorithm:

Algorithms are the actions that are performed either "on" the data structure or "by" the data structure.

E.g. a chess piece moves on a chess board. For computer, chess piece will be a data structure and chess board will be a data structure. This action is performed by one data structure (piece) on other data structure (chess board).

Data structures and algorithms are closely related.

The art of programming lies in designing the best data structure so that the algorithm is executed effectively (correctly) and efficiently (fast).

Consider this example: I give you a table having numerical data about the sales of a particular company for 10 different years and ask you to tell me in which year the sales were maximum and in which year they were minimum?

Now I give you the same information in a graphical format and you can give me the same answer in less time. I just changed the format of the same information but you became more efficient. The same has to be done while programming - find the best format (encoding/data structure) such that the actions (algorithms/functions) are efficient.

When we are programming the chess engine, this will be our ultimate pursuit i.e. to design and construct Data Structures such that the algorithms are executed effectively and efficiently.

Hence we have to first determine what are the basic algorithms (or processes) a chess engine will comprise of. Notice that even FEN is a Board Representation.

But, it wont be efficient to represent the chess position in FEN format for a chess engine.

FEN format is more useful for human readable text form.

Often chess engines have a FEN to internal Board Representation converters.