Dimitri-Bit / Simple-Chess-Engine

Simple minimax chess engine in C++
1 stars 0 forks source link

can not compile on Linux #1

Open tissatussa opened 6 months ago

tissatussa commented 6 months ago

although your engine is simple, i like to compile it but this fails .. i used the following command to compile :

$ clang++-16 *.cpp -O3 -o mychessengine -lpthread -lm
In file included from engine.cpp:6:
In file included from ./search.hpp:1:
./evaluation.hpp:22:35: error: no member named 'VALUE' in namespace 'POSITIONAL_VALUE'; did you mean 'MATERIAL_VALUE::VALUE'?
        evaluation = evaluation + POSITIONAL_VALUE::VALUE[piece][squareInt];
                                  ^~~~~~~~~~~~~~~~~~~~~~~
                                  MATERIAL_VALUE::VALUE
./constants.hpp:29:15: note: 'MATERIAL_VALUE::VALUE' declared here
    const int VALUE[12] = {
              ^
In file included from engine.cpp:6:
In file included from ./search.hpp:1:
./evaluation.hpp:22:65: error: subscripted value is not an array, pointer, or vector
        evaluation = evaluation + POSITIONAL_VALUE::VALUE[piece][squareInt];
                                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~
2 errors generated.

indeed in constants.hpp no VALUE array is defined inside the POSITIONAL_VALUE structure .. at the end of this file you commented-out such code, it's not complete .. i tried to fix it but i have no clue (i'm not into C++). Can it be solved ?

[ i'm on Xubuntu 22.04 ]

Dimitri-Bit commented 6 months ago

Hello,

I appreciate your interest in my engine! Unfortunately its currently not working, I started to do some refactoring, which messed up the code-base, and haven't finished it. I will start working on it again as soon as my exams end in a month or so. I can update this PR after its functioning again.

tissatussa commented 6 months ago

..and haven't finished it..

OK, nevermind. success with the exams!

https://github.com/Dimitri-Bit/Simple-Chess-Engine/assets/1109281/31d70a4c-fd03-4d44-9d97-19f6fc039449

i'll receive all your GitHub notices, so .. and i can test, but only on Linux :)

Dimitri-Bit commented 3 weeks ago

Heyy!! Sorry for being so late to reply to this, I have serious commitment issues with projects haha. The source code on the main branch should be a up to date working version of the chess engine which you can compile. I'm using the following command when compiling g++ -o engine engine.cpp library/chess.hpp you can of course use optimization flags as well.

If have the time, and find it interesting, please try the engine out and let me know if you find any bugs/issues!

tissatussa commented 3 weeks ago

hi, i just compiled the new source as you proposed and it created a valid binary without any warnings and errors. Then i played a game with White. I won effortlessly, here's the ZIPped terminal log : sce-some-game.zip

And here's the game :

sce-ApronusDiagram1730275212

[Event "human vs engine"]
[Site "Holland"]
[Date "2024.10.30"]
[Round "1"]
[White "Roelof Berkepeis"]
[Black "Simple Chess Engine"]
[Result "1-0"]
[ECO "B00"]
[GameDuration "00:06:48"]
[Opening "Fred"]
[PlyCount "23"]

1. e4 f5 {1.7s} 2. exf5 {1.2s} a6 {31s} 3. Qh5+ {20s} g6 {23s} 4. fxg6 {3.1s}
Nf6 {12s} 5. g7+ {4.7s} Nxh5 {17s} 6. gxh8=Q {3.1s} Kf7 {28s} 7. Qxh7+ {54s}
Ke6 {20s} 8. Qxh5 {8.6s} d6 {14s} 9. Qg6+ {79s} Ke5 {13s} 10. Nc3 {23s} e6 {10s}
11. Nf3+ {11s} Kf4 {13s} 12. d3# {14s, White mates} 1-0

Bugs : no (it can even let me promote !) Issues : yes, it plays bad ..

Dimitri-Bit commented 3 weeks ago

Hi, I'm glad everything works! Even though it does not work well haha, I know the engine plays pretty poorly but I hope to improve it. I am currently adding piece square tables and plan to add lazy evaluation and transportation tables. Do you have any suggestions in how I could improve the engine? :)

tissatussa commented 3 weeks ago

Do you have any suggestions in how I could improve the engine?

Although your engine plays really bad at the moment, i take it serious .. i'm a programmer, but not of any engine yet, but i know the basics of creating a chess engine, i follow many authors on GitHub and gather and test their versions .. i would suggest you first implement a protocol to communicate with a chess app like CuteChess (which i use and advice) or Arena, etc. Best is UCI, which is rather easily to grasp and program - i can give you the minimal command set to start .. then we can play and let play the engine conveniently and compare it to others ..

from my understanding you should first focus on these points :

when you get your head around my issues and pitfalls, by studying other code and designing a better (UCI) engine, you can get a new foundation, then implement lazy evaluation and transportation tables.


very nice to meet another enthousiast chess engine programmer ! This kind of program needs many skills and techniques, for the engine should run fast and efficient, and you'll learn a lot!

chess-vh

it's the road, the adventure, not the goal. all you'll ever create is "a first version".

tissatussa commented 3 weeks ago

btw. piece square tables are great besides 'normal' material values. You probably know PSTs exist for middle game positions (MG) and end game (EG) and their values are interpolated somehow.

Dimitri-Bit commented 3 weeks ago

i would suggest you first implement a protocol to communicate with a chess app like CuteChess

I think that this would be a smart next move, debugging is starting to be really difficult in with the CLI representation of the board.

  • create your own move generator and decide how it will act in your new setup. It must be fast, that's the challenge

I am using this library https://github.com/Disservin/chess-library for the chess board and generation, it does most of the heavy lifting honestly.

tissatussa commented 3 weeks ago

I am using this library https://github.com/Disservin/chess-library for the chess board and generation..

seems OK ! but it's really an experience to create such yourself - just saying ..

Dimitri-Bit commented 3 weeks ago

Yeah, I definitely plan on making my own later on! I'll let you know once some major improvements have been made so you can test out the engine again :)