Lucas has always right. He tried to save me from this misery before one year ago when he called me a troll and tried to chase me away. I should have listened to my best friend.vittyvirus wrote:Depends on what Lucas means by a 'well written engine'. He wrote a 2800 and now thinks himself god.Henk wrote:Ok that's a good reason for me to quit.lucasart wrote:I said well written engine. Obviously that excludes any work from: you, Folkert, Syed, etc.Henk wrote:I am currently using movelists but also iterator objects and move handlers one for captures, one for killers etc. All dynamically allocated. Lots of work to do.lucasart wrote:Exactly!syzygy wrote:Do not allocate any objects at all within your search.flok wrote:I wonder if any of you has suggestions for improving it any further.
A well written chess engine should not do any dynamic memory allocation, apart from the obvious hash table(s).
If you need to dynamically allocate/resize anything, you're doing it all wrong. Instead of wondering whether to choose std::vector vs. pointer+realloc, ask yourslef what you are doing wrong and redesign your code.
If I am going to reuse movelists of a pre-allocated pool it might be that clearing them will be expensive too. But of course instead of allocating power(N, BF) movelists I only need to allocate N such lists but they still have to be cleared power(N, ..) times.
std::vector<> considered harmful
Moderators: hgm, Rebel, chrisw
-
- Posts: 7220
- Joined: Mon May 27, 2013 10:31 am
Re: std::vector<> considered harmful
-
- Posts: 1334
- Joined: Sun Jul 17, 2011 11:14 am
Re: std::vector<> considered harmful
I had previously tried to keep my mouth shut when Lucas said something like this. I have, frankly, had enough.
It is my personal opinion that what Lucas has just said violates charter point #3.
I have already left this forum once over people making stupid insults like this.
Matthew:out
It is my personal opinion that what Lucas has just said violates charter point #3.
He is quite clearly, albeit indirectly, attacking Syed, Folkert and Henk. This is not acceptable.talkchess wrote: Once a member gains access to the message board, he may read all messages and post new or response messages with the proviso that these new or response messages:
...
3. Do not contain personal and/or libelous attacks on others
I have already left this forum once over people making stupid insults like this.
Matthew:out
Some believe in the almighty dollar.
I believe in the almighty printf statement.
I believe in the almighty printf statement.
-
- Posts: 3232
- Joined: Mon May 31, 2010 1:29 pm
- Full name: lucasart
Re: std::vector<> considered harmful
I'm saying that their engines are poorly designed. But, at least, they've written one.ZirconiumX wrote: He is quite clearly, albeit indirectly, attacking Syed, Folkert and Henk. This is not acceptable.
And yet, here you are...ZirconiumX wrote: I have already left this forum once over people making stupid insults like this.
Theory and practice sometimes clash. And when that happens, theory loses. Every single time.
-
- Posts: 7220
- Joined: Mon May 27, 2013 10:31 am
Re: std::vector<> considered harmful
I am not using my IChessPieceVisitorFactory interface class anymore.
-
- Posts: 1334
- Joined: Sun Jul 17, 2011 11:14 am
Re: std::vector<> considered harmful
That was cold.lucasart wrote:I'm saying that their engines are poorly designed. But, at least, they've written one.ZirconiumX wrote: He is quite clearly, albeit indirectly, attacking Syed, Folkert and Henk. This is not acceptable.
Considering you've given up DiscoCheck due to recognising your own code is poorly designed, I'm not sure you're in a position to tell people things like that.
If Marco, or Fabien said something like that, then yes, I would probably agree with them, due to the fact that they posess the unique ability to be polite.
Matthew:out
Some believe in the almighty dollar.
I believe in the almighty printf statement.
I believe in the almighty printf statement.
-
- Posts: 646
- Joined: Wed Jun 18, 2014 2:30 pm
- Full name: Fahad Syed
Re: std::vector<> considered harmful
+1ZirconiumX wrote:That was cold.lucasart wrote:I'm saying that their engines are poorly designed. But, at least, they've written one.ZirconiumX wrote: He is quite clearly, albeit indirectly, attacking Syed, Folkert and Henk. This is not acceptable.
Considering you've given up DiscoCheck due to recognising your own code is poorly designed, I'm not sure you're in a position to tell people things like that.
If Marco, or Fabien said something like that, then yes, I would probably agree with them, due to the fact that they posess the unique ability to be polite.
Matthew:out
-
- Posts: 855
- Joined: Sun May 23, 2010 1:32 pm
Re: std::vector<> considered harmful
I used to use std::vector<> for a lot of things inside my engine. I realized in early development that std::vector is not suitable for storing list of generated moves because it's too slow.
I used it to store past moves information ( undo moves information) but the i realized that when the size growth and it needs to be reallocated ALL THE REFERENCE to the data are invalidated.
at this point I switched back to fixed size array
I used it to store past moves information ( undo moves information) but the i realized that when the size growth and it needs to be reallocated ALL THE REFERENCE to the data are invalidated.
at this point I switched back to fixed size array
-
- Posts: 931
- Joined: Tue Mar 09, 2010 3:46 pm
- Location: New York
- Full name: Álvaro Begué (RuyDos)
Re: std::vector<> considered harmful
You can easily get around that by using indices instead of references or pointers.elcabesa wrote:[...]
I used it to store past moves information ( undo moves information) but the i realized that when the size growth and it needs to be reallocated ALL THE REFERENCE to the data are invalidated.
-
- Posts: 855
- Joined: Sun May 23, 2010 1:32 pm
Re: std::vector<> considered harmful
yes but saving a reference should be faster than every time you need an information access the data by indices.
-
- Posts: 931
- Joined: Tue Mar 09, 2010 3:46 pm
- Location: New York
- Full name: Álvaro Begué (RuyDos)
Re: std::vector<> considered harmful
Do you say that because you have measured it or because of some intuition? Don't trust your intuitions: The processor has addressing modes that make this kind of access really fast, at least if the element size is a small power of two.elcabesa wrote:yes but saving a reference should be faster than every time you need an information access the data by indices.