timhul / ClassicSim

An event-driven simulation tool written in C++ for World of Warcraft Classic.
Other
116 stars 70 forks source link

pybind11 for a more interactive approach #24

Open jokal2 opened 5 years ago

jokal2 commented 5 years ago

It would be very nice to able to do

war = Warrior()
war.talents = Warrior.Talents.templates.dualWieldFury
war.mainHand = Weapons.oneHandSwords.viskagTheBloodletter
war.buffs = 
...
engine = Engine()
engine.addDps(war)
results = { "withoutSongflower" : engine.runLoatheb() }
war.addBuff(Buffs.world.songflower)
results["withSongFlower"] = engine.runLoatheb()
...
numpy.doSomeFancyPlotWithAllThisDataToShowAnalytics()

etc and then be able to use that data with numpy, scipy, pandas etc to do typical data science analytics. Have you thought about this? You could even embed the state of the character in the results structure and cache it and only lazily reevaluate upon request.

It probably would be more usable even for non-programmers than any GUI could given that all they'd have to do would be install VSCode, open an example.py, install the MS python plugin and click play. Saving would be trivial since it would just be ctrl + s to save EVERYTHING that the user did.

Any thoughts?

timhul commented 5 years ago

Hi, sorry for the long response time on this issue, I've been unusually busy both last week and during this weekend. I've wanted to take the time to make sure to give a good response.

TL;DR: pybind11 looks real neat for some other projects I have in the works, but am unsure about it for this project.

A GUI is used in this project because its early development was partly due to a new work assignment that used the same techniques (C++/QML) and it served as a refresher from university. I have not considered the approach you laid out, but did consider the possibility of an "entirely file-based configuration", even though I ruled it out due to previous consideration of mainly focusing on supporting a GUI.

Also, I'm not actually too fond of the current retail ecosystem when it comes to the simulation of characters and did not want this project to facilitate a similar ecosystem in classic, which maybe sounds odd coming from a sim author. I'm still unsure about this part, because entirely file-based configurations certainly is a big leap towards enabling anyone to use this project as part of its backend to produce raidbots-like functionality to websites.

Further, even using the application locally I'm not sure that that many users would prefer file-based configurations but maybe this is just me. I always thought that was the worst part about SimCraft (otherwise it is a fantastic application), because e.g. syntax was seemingly obscured in documentation somewhere else, or not available at all.

So, trying to conclude these thoughts I think pybind11 looks neat and something I'd like to try for other projects, but it seems reading from the docs it would have a significant impact on the code and when contrasting to the gain I'm seeing I don't see it is quite worth it for this project.

You could even embed the state of the character in the results structure and cache it and only lazily reevaluate upon request.

I don't quite understand how this is possible, other than "do not re-sim if the character state is not at all mutated since last run", which seems like an edge-case. If a user wants to re-sim the same setup, then why not..? Or was this not what you meant? Mutating any other state will definitely cause a necessary reevaluation.