Friendly greetings !
I'm writing a chess engine (my 1st engine ! yay !), using fortran.
I'm not sure which board representation would be a best fit for this language.
Techincally, fortran doesn't have uint64_t (only signed) but it should be a very major problem if the bitfield is only used for bit manipulation, and not math.
Another option could be a logical matrix (a 2d array of boolean) but it may kind of defeat the effectiveness of a bitboard.
Or it could be any other board representation, probably.
i don't know. Any idea ?
The source code is here https://github.com/ker2x/fortiche but it doesn't do anything at all, for now.
Any Fortran coder ?
Moderators: hgm, Rebel, chrisw
-
- Posts: 771
- Joined: Sat Sep 08, 2018 5:37 pm
- Location: Ukraine
- Full name: Maksim Korzh
Re: Any Fortran coder ?
Congratulations with your first attempt! Just curious - why Fortran?
Didactic chess engines:
https://www.chessprogramming.org/Maksim_Korzh
Chess programming YouTube channel:
https://www.youtube.com/channel/UCB9-pr ... KKqDgXhsMQ
https://www.chessprogramming.org/Maksim_Korzh
Chess programming YouTube channel:
https://www.youtube.com/channel/UCB9-pr ... KKqDgXhsMQ
-
- Posts: 12540
- Joined: Wed Mar 08, 2006 8:57 pm
- Location: Redmond, WA USA
Re: Any Fortran coder ?
I did Fortran in the 70's and 80's. All the sample programs and stuff you can find will be quite old and out of date as far as the latest techniques go.
There is a guy here who wrote "Six_Fortran_95_tools" and he is probably much more helpful for Fortran stuff.
Robert Hyatt, who wrote Crafty certainly knows a lot about Fortran.
Here is a Fortran chess program:
https://github.com/arbolis/fortranchess ... /chess.f90
There is a thread here about it:
https://groups.google.com/forum/#!topic ... IGLGF3CdMY
I added the sample fortran77 program from f77bench (kind of old) as an attachment.
The Fortran source for Cray Blitz is still around. I have several versions of it.
I had a Fortran95 chess program at one time, but I don't remember where I put it.
I am doing a disk grep for it now, and I will see if I can find it.
Since integers are signed in Fortran, bitwise operations would be a problem, but some Fortran compilers allow inline assembly.
You could also do an interface to C++ for that bit.
If you want it all in portable Fortran code, then one of the mailbox/array techniques is probably best.
I found a project that looks interesting called sigma chess which has some of the code in Fortran:
There is a guy here who wrote "Six_Fortran_95_tools" and he is probably much more helpful for Fortran stuff.
Robert Hyatt, who wrote Crafty certainly knows a lot about Fortran.
Here is a Fortran chess program:
https://github.com/arbolis/fortranchess ... /chess.f90
There is a thread here about it:
https://groups.google.com/forum/#!topic ... IGLGF3CdMY
I added the sample fortran77 program from f77bench (kind of old) as an attachment.
The Fortran source for Cray Blitz is still around. I have several versions of it.
I had a Fortran95 chess program at one time, but I don't remember where I put it.
I am doing a disk grep for it now, and I will see if I can find it.
Since integers are signed in Fortran, bitwise operations would be a problem, but some Fortran compilers allow inline assembly.
You could also do an interface to C++ for that bit.
If you want it all in portable Fortran code, then one of the mailbox/array techniques is probably best.
I found a project that looks interesting called sigma chess which has some of the code in Fortran:
Code: Select all
Directory of F:\project\dcorbit\sigma-chess-read-only\Application\Source\Chess Engine
2013-08-29 05:27 PM 4,677 Engine.f
1 File(s) 4,677 bytes
Directory of F:\project\dcorbit\sigma-chess-read-only\Application\Source\Chess Engine\Data Structures
2013-08-29 05:27 PM 2,092 Attack.f
2013-08-29 05:27 PM 2,216 Board.f
2013-08-29 05:27 PM 2,066 Move.f
3 File(s) 6,374 bytes
Directory of F:\project\dcorbit\sigma-chess-read-only\Application\Source\Chess Engine\Evaluation
2013-08-29 05:27 PM 1,999 Evaluate.f
2013-08-29 05:27 PM 1,923 Mobility.f
2013-08-29 05:27 PM 1,969 PieceVal.f
3 File(s) 5,891 bytes
Directory of F:\project\dcorbit\sigma-chess-read-only\Application\Source\Chess Engine\Misc
2013-08-29 05:27 PM 1,889 EndgameDB.f
2013-08-29 05:27 PM 2,070 HashCode.f
2013-08-29 05:27 PM 2,041 Time.f
3 File(s) 6,000 bytes
Directory of F:\project\dcorbit\sigma-chess-read-only\Application\Source\Chess Engine\Move Generation
2013-08-29 05:27 PM 2,335 MoveGen.f
2013-08-29 05:27 PM 1,958 PerformMove.f
2 File(s) 4,293 bytes
Directory of F:\project\dcorbit\sigma-chess-read-only\Application\Source\Chess Engine\Searching
2013-08-29 05:27 PM 1,896 MateSearch.f
2013-08-29 05:27 PM 2,200 Search.f
2013-08-29 05:27 PM 2,035 SearchMisc.f
2013-08-29 05:27 PM 1,924 Selection.f
2013-08-29 05:27 PM 1,886 Threats.f
2013-08-29 05:27 PM 2,022 TransTables.f
6 File(s) 11,963 bytes
Taking ideas is not a vice, it is a virtue. We have another word for this. It is called learning.
But sharing ideas is an even greater virtue. We have another word for this. It is called teaching.
But sharing ideas is an even greater virtue. We have another word for this. It is called teaching.
-
- Posts: 17
- Joined: Sun Nov 11, 2018 1:28 pm
- Full name: Laurent Laborde
Re: Any Fortran coder ?
@maksimKorzh : thank you. i do it in fortran because i can and fortran is awesome. No real practical reason.
@dann : Thank you for the code and info, i'll take a look.
Btw, any idea how i can do multi-threading working on both windows and linux ?
I also considered multiprocessing + MPI but i don't see how i can make it works on both plateform again.
i'm using gfortran (and the simply fortran IDE). My main development plateform is windows (at home) but i'm a linux sysadmin, so... i want both and windows is a pain to deal with.
@dann : Thank you for the code and info, i'll take a look.
Btw, any idea how i can do multi-threading working on both windows and linux ?
I also considered multiprocessing + MPI but i don't see how i can make it works on both plateform again.
i'm using gfortran (and the simply fortran IDE). My main development plateform is windows (at home) but i'm a linux sysadmin, so... i want both and windows is a pain to deal with.
-
- Posts: 27796
- Joined: Fri Mar 10, 2006 10:06 am
- Location: Amsterdam
- Full name: H G Muller
Re: Any Fortran coder ?
I think I never got beyond Fortran 60 (or something like that), before I switched to other programming languages. Fortran 77 already appeared 'after my time'... Problem used to be that you couldn't do recursion; I don't know if later Fortrans fixed that.
-
- Posts: 17
- Joined: Sun Nov 11, 2018 1:28 pm
- Full name: Laurent Laborde
Re: Any Fortran coder ?
Fortran changed, you can still do old fashined fixed form fortran and stuff but you can also do freeform fortran, or Object Oriented Fortran
Modern compiler even have auto vectorization and auto parallelization, so loop can run on mutiple core without having to write a single line of additional code, i'm pretty sure it's inherited from cray fortran compiler.
But i wish it had intrinsic for multithreading however
Modern compiler even have auto vectorization and auto parallelization, so loop can run on mutiple core without having to write a single line of additional code, i'm pretty sure it's inherited from cray fortran compiler.
But i wish it had intrinsic for multithreading however
-
- Posts: 12540
- Joined: Wed Mar 08, 2006 8:57 pm
- Location: Redmond, WA USA
Re: Any Fortran coder ?
Taking ideas is not a vice, it is a virtue. We have another word for this. It is called learning.
But sharing ideas is an even greater virtue. We have another word for this. It is called teaching.
But sharing ideas is an even greater virtue. We have another word for this. It is called teaching.
-
- Posts: 17
- Joined: Sun Nov 11, 2018 1:28 pm
- Full name: Laurent Laborde
Re: Any Fortran coder ?
Yes, i know this one. but i don't want to do SIMD (well, i'll also do it but it's a different problem) so openmp, coarray, cuda, isn't a solution for this case (i already planned to use openmp for the computation part).
From this list only MPI could do the job and i don't know if i can use openmpi on both windows and linux without having to write tons of #ifdef windows/linux to make it portable.
-
- Posts: 17
- Joined: Sun Nov 11, 2018 1:28 pm
- Full name: Laurent Laborde
Re: Any Fortran coder ?
and running open mpi app is a bit of a pain for the user
-
- Posts: 536
- Joined: Thu Mar 09, 2006 3:01 pm
Re: Any Fortran coder ?
Tinker's great grandfather started in Fortran. I did recursion just fine with an explicit stack. It was pretty straightforward, as I recall.