# Beginner - Chess at C

#### Elion Highest

Helo,
I'm new to programming, I'm in the first semester of Computer Science. I need to deliver a project by the end of November: developing a complete chess game in just C. I would like to know if anyone has any tips, sources, books, guidance because, honestly, I don't know where to start and the topics I need The teacher hasn't told us yet. Some guidance or a complete code for me to base myself on (I will need to explain my code in detail).
I thank.

#### WhiteCube

Its difficult to write a program that play chess well.

Its easy to write a program that plays chess like a beginner.

All two player board games use the same logic. Chess and tic tac toe are the same.

You have a number of valid moves to choose from. Give each of them a score from 0 (bad) to 1 (good). Play the move with the highest score.

What's the best move?

Use recursion, play a move, turn the board around, ask the same question.

My best move is when my opponent's best reply scores the lowest.

If my move causes my opponent's best next move to score 0.7 then I score my move as 0.3 (1-0.7)

You can't recurse forever, at some point you need to score a move based on just the board.

In the case of chess that would be adding up the value of the pieces, or testing for a check mate.

Just my opinion.

#### WhiteCube

Code:
``````The general idea:

best_move(player,level)
B = the other player
S = 0
FOR all valid moves
do move
IF level = 0
x = score board
ELSE
(x,m)=best_move(B,level-1)
x = 1-x
undo move
IF S < x
S = x
M = move
return (S,M)``````

#### naburgondux

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.