Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
chess_programming
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Radia EL HAMDOUNI
chess_programming
Commits
e8c46c05
Commit
e8c46c05
authored
Oct 28, 2020
by
Radia EL HAMDOUNI
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added header file => contains data structures
parent
aa6d59d8
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
139 additions
and
0 deletions
+139
-0
board.h
board.h
+139
-0
No files found.
board.h
0 → 100644
View file @
e8c46c05
/* ---------------------------------------------------------
============================================================
Chess Engine in C Language
==========================
8 |_|#|_|#|_|#|_|#|
7 |#|_|#|_|#|_|#|_|
6 |_|#|_|#|_|#|_|#|
5 |#|_|#|_|#|_|#|_|
4 |_|#|_|#|_|#|_|#|
3 |#|_|#|_|#|_|#|_|
2 |_|#|_|#|_|#|_|#|
1 |#|_|#|_|#|_|#|_|
a b c d e f g h
-----------------------------------------------------------
BY
Radia EL HAMDOUNI
MLOD - Mini-Projet
====================================================
\---------------------------------------------------*/
/************************************************************\
;------------------------------------------------------------;
; Chess engine in C ;
; ;
;------------------------------------------------------------;
; TODO : ;
; [x] Bitboard representation ;
; [x] Moving pieces ;
; [] Fen implementation ;
; [] Move generator ;
; [] Search ;
; [] Evaluation ;
\************************************************************/
/*
Compile and run the program
$gcc chess_engine.c -o chess_engine && ./chess_engine
*/
// libraries
#include<stdio.h>
/* Piece encoding */
// for the mapping
enum
pieces
{
e
,
// empty square
P
,
// white pond
N
,
// white knight
B
,
// white bishop
R
,
// white rook
Q
,
// white queen
K
,
// white king
p
,
// black pond
n
,
// black knight
b
,
// black bishop
r
,
// black rook
q
,
// black queen
k
,
// black king
o
,
// board limit
};
// unicode pieces
char
*
chess_pieces
[]
=
{
" . "
,
" ♙ "
,
" ♘ "
,
" ♗ "
,
" ♖ "
,
" ♕ "
,
" ♔ "
,
" ♟︎ "
,
" ♞ "
,
" ♝ "
,
" ♜ "
,
" ♛ "
,
" ♚ "
};
// character indexes
int
char_pieces
[]
=
{
[
'P'
]
=
P
,
[
'N'
]
=
N
,
[
'B'
]
=
B
,
[
'R'
]
=
R
,
[
'Q'
]
=
Q
,
[
'K'
]
=
K
,
[
'p'
]
=
p
,
[
'n'
]
=
n
,
[
'b'
]
=
b
,
[
'r'
]
=
r
,
[
'q'
]
=
q
,
[
'k'
]
=
k
,
};
// chess board representation 0x88
int
board
[
128
]
=
{
r
,
n
,
b
,
q
,
k
,
b
,
n
,
r
,
o
,
o
,
o
,
o
,
o
,
o
,
o
,
o
,
p
,
p
,
p
,
p
,
p
,
p
,
p
,
p
,
o
,
o
,
o
,
o
,
o
,
o
,
o
,
o
,
e
,
e
,
e
,
e
,
e
,
e
,
e
,
e
,
o
,
o
,
o
,
o
,
o
,
o
,
o
,
o
,
e
,
e
,
e
,
e
,
e
,
e
,
e
,
e
,
o
,
o
,
o
,
o
,
o
,
o
,
o
,
o
,
e
,
e
,
e
,
e
,
e
,
e
,
e
,
e
,
o
,
o
,
o
,
o
,
o
,
o
,
o
,
o
,
e
,
e
,
e
,
e
,
e
,
e
,
e
,
e
,
o
,
o
,
o
,
o
,
o
,
o
,
o
,
o
,
P
,
P
,
P
,
P
,
P
,
P
,
P
,
P
,
o
,
o
,
o
,
o
,
o
,
o
,
o
,
o
,
R
,
N
,
B
,
Q
,
K
,
B
,
N
,
R
,
o
,
o
,
o
,
o
,
o
,
o
,
o
,
o
,
};
// mapping the board to algebraic notation
char
*
algebraic_board
[]
=
{
"a8"
,
"b8"
,
"c8"
,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h6
,
a5
=
48
,
b5
,
c5
,
d5
,
e5
,
f5
,
g5
,
h5
,
a4
=
64
,
b4
,
c4
,
d4
,
e4
,
f4
,
g4
,
h4
,
a3
=
80
,
b3
,
c3
,
d3
,
e3
,
f3
,
g3
,
h3
,
a2
=
96
,
b2
,
c2
,
d2
,
e2
,
f2
,
g2
,
h2
,
a1
=
112
,
b1
,
c1
,
d1
,
e1
,
f1
,
g1
,
h1
};
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment