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
Tree plot #35
Tree plot #35
Conversation
Thank you very much - having this visualization directly into Ceres will be really cool! It's impressive also for your first C# code and also that you figured out some of the relatively undocumented Ceres internals. I don't think any substantive changes would be needed, just a number of smaller stylistic items. Comments below.
simpler:
simplest:
However in some cases, it can be inefficient. This is almost certainly the case because here because it ends up materializes the data structure (ToArray()). Instead, the spririt of Linq is to just keep enumerating over chains and then everything is "one at a time, just in time." It seems you could do this here, just chain this all together in the foreach appearing below:
then it there will be less objects created and speed will be much better. |
Just a thought - perhaps you could add not only the current save-tree-plot command but also a show-tree-plot command that does the same thing but auto-launches the png in the visualizer application, to make it really easy. We could also suggest to the author of Nibbler to add a menu choice to launch that. |
Thank you for the detailed comments! I will address those. I have only
EDIT: realized that the only reason why I had this problem was that during development I was calling TreePlot.Save directly from the search code. But now that it is called from UCI, it is all fine as UCI resides in Features layer.
Could you give an example of bad and correct way? Tried to compared how I and rest of the code base use if and while blocks and couldn't spot the difference. Rest seems clear for now. I also had show-tree-plot idea in my mind but ditched it as it seemed like I would have to use Windows Forms which sounded like it will never work on Linux. I will look into the suggested way of using Process.Start("plot.png"). |
…capitalize private ones.
Actually the use of braces is almost perfect, just I noticed not here (missing):
|
I hope I got it all.
|
Adds UCI command
save-tree-plot <filename>
to save visual presentation of current search tree as a png-file.Example UCI session
This saves following plot into file C:\temp\myplot.png.
Works well for larger trees, as long as memory does not run out. Drawing is fairly quick. On my machine with debug build plotting 1M node tree takes about 10 seconds, ~2 sec to calculate the x,y-coordinates and ~8 sec to draw it. Smaller trees are much faster to plot, e.g. 8000 nodes takes ~0.1 sec.
Some use cases:
Some potential future improvements:
This is my first time writing C# and implementation might be ugly at places. Happy to hear feedback how to improve.