Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Playfield constructor performance #2

Open
ChristophWeigert opened this issue Oct 16, 2014 · 5 comments
Open

Playfield constructor performance #2

ChristophWeigert opened this issue Oct 16, 2014 · 5 comments

Comments

@ChristophWeigert
Copy link
Contributor

he biggest performance issue is the Playfield constructor.
dont know if i can change this with adding something like preallocating 5000 (or so) boards, and
just override the existing old/unused playfields in the posmoves-List.
(like:
int i = getNextFreeSpace(posmoves);
posmoves[i].deepCopy(p);
posmoves[i].doAction(a);

instead of

Playfield pf = new Playfield(p);
pf.doAction(a);
)

@ChristophWeigert
Copy link
Contributor Author

Changed all foreach loops to for loops.

Should be a little performance boost.
Can you try this commit?

https://github.com/Giswald/silverfish/commit/76b8c5fea4e6bf5266f43f0c1930b5e4be03e0be

@dfreelan
Copy link

I have used a profiler before on this code, and I can verify the constructor is a huge part of it.

To confirm your hypothesis further, if I disable to time it takes to do memory allocation from the profiler, the ctor is no longer the limiting factor. Rather the board evaluation.

So I think you are exactly correct, and the boards should be preallocated. However, modifying the AI structure written is probably easier said than done.

As soon as I feel comfortable where I am in school i'll have my own AI to work on where i'll likely do exactly that :)

( i probably won't touch the existing ai though)

@dfreelan
Copy link

oh and another note, iterator seemed only to be a performance block when memory allocation was not accounted for.

So I think you won't notice much of a difference until you get rid of the real bottle neck, playfield ctor

@dfreelan
Copy link

ALSO: sorry i keep writing things you probably keep getting emails.

when doing performance, make sure it's still correct by comparing a before and after of the board result. I wrote something as a benchmark in the other repo botmaker and I were using.... we should pull that over here

@noHero123
Copy link
Owner

@Giswald added you to https://github.com/noHero123/consoleversion

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants