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
fd2dbde5
Commit
fd2dbde5
authored
Oct 27, 2020
by
Radia EL HAMDOUNI
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update chess_engine.c
parent
ab34bfc8
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
1 addition
and
156 deletions
+1
-156
chess_engine.c
chess_engine.c
+1
-156
No files found.
chess_engine.c
View file @
fd2dbde5
/* ---------------------------------------------------------
(
^
'
)
ފ
pjx
.
j
============================================================
\ No newline at end of file
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
,....,
,::::::<
,::/^\"``.
,::/, ` e`.
,::; | '.
,::| \___,-. c)
;::| \ '-'
;::| \
;::| _.=`\
`;:|.=` _.=`\
'|_.=` __\
`\_..==`` /
.'.___.-'.
/ \
('--......--')
/'--......--'\
`"--......--"
====================================================
---------------------------------------------------*/
/*
Compile and run the program
$gcc chess_engine.c -o chess_engine && ./chess_engine
*/
// Libraries
#include<stdio.h>
// Upper Case letters => White pieces .
// Lower Case letters => Black pieces .
// for the mapping
enum
{
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
[]
=
{
" . "
,
" ♙ "
,
" ♘ "
,
" ♗ "
,
" ♖ "
,
" ♕ "
,
" ♔ "
,
" ♟︎ "
,
" ♞ "
,
" ♝ "
,
" ♜ "
,
" ♛ "
,
" ♚ "
};
// 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
,
};
// Print the board to the console
void
show_board
(){
// pint new line
printf
(
"
\n\n\n
"
);
// A rank is a line
// A file is a column
for
(
int
i
=
0
;
i
<
8
;
i
++
){
//loop over the ranks
for
(
int
j
=
0
;
j
<
16
;
j
++
){
// loop over the files
int
square
=
16
*
i
+
j
;
if
(
j
==
0
){
printf
(
"%d "
,
8
-
i
);
// print ranks
}
// print the board's valid quares
if
(
!
(
square
&
0x88
)){
printf
(
"%s"
,
chess_pieces
[
board
[
square
]]);
}
}
printf
(
"
\n
"
);
}
printf
(
"
\n
a b c d e f g h
\n\n\n
"
);
// print files
}
// Main
int
main
(){
show_board
();
return
1
;
}
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