I'm going with a bitboard representation but not sure if bitboards and other info about board should sit within a class, struct or simply an array. If I keep creating class instances I understand that might slow the program down. I could use a struct but there seems to be advice that says info in a struct should be immutable. If I go with static class then I can't copy state for searching in a search algorithm but it has performance benefit. Any advice on this would be appreciated.
daz12 wrote:I'm going with a bitboard representation but not sure if bitboards and other info about board should sit within a class, struct or simply an array. If I keep creating class instances I understand that might slow the program down. I could use a struct but there seems to be advice that says info in a struct should be immutable. If I go with static class then I can't copy state for searching in a search algorithm but it has performance benefit. Any advice on this would be appreciated.
Thanks
Daz
I think you need to start by Programming 101. At this point, it's obvious that writing a chess engine is way beyond your skills.
PS: struct and class are the same thing in C++. there is no difference in performance (and indeed compiled code) if you put an array in a struct/class.
"Talk is cheap. Show me the code." -- Linus Torvalds.
@ lucasart for your information I've made quite a lot of progress and managed to do things I didn't think I could, so I won't let your opinion limit my ambitions KMA!
daz12 wrote:I'm going with a bitboard representation but not sure if bitboards and other info about board should sit within a class, struct or simply an array. If I keep creating class instances I understand that might slow the program down. I could use a struct but there seems to be advice that says info in a struct should be immutable. If I go with static class then I can't copy state for searching in a search algorithm but it has performance benefit. Any advice on this would be appreciated.
Thanks
Daz
I think you need to start by Programming 101. At this point, it's obvious that writing a chess engine is way beyond your skills.
PS: struct and class are the same thing in C++. there is no difference in performance (and indeed compiled code) if you put an array in a struct/class.
Though there is no performance difference, there is an important nuance between struct and class in C++.
A struct has data members and methods that are public by default and a class has private access by default.
I am sure that Lucas knows this but the O.P. may not.