rspeer / dominiate

A simulator for Dominion card game strategies
http://rspeer.github.com/dominiate
MIT License
121 stars 43 forks source link

Turn slow mode into fast mode #68

Closed bilts closed 12 years ago

bilts commented 12 years ago
This fixes several major UI inefficiencies:

 * playWeb.coffee triggered output updates that were being suppressed by play.html
   I removed these.  The output updates less frequently and is completely
   controlled by play.html.  Eventually, all of the CoffeeScript in play.html should
   be merged with playWeb.coffee, but that's a different issue.
 * We were calling zeroTimeout very frequently.  zeroTimeout is fast, but not
   free.  We now call it approximately 4 times a second, enough to keep the browser
   from timing out, but not enough to cause noticeable performance overhead.
 * We had released control back to the browser based on the number of games played.
   We also updated the graphs based on the number of games played.  Doing this
   way, we needed to be pessimistic about AI and browser performance.  We now
   release control when a game is over and we've had control for more than .25s.
 * We were updating the DOM whenever we added a page to the log, even when we
   updated "quietly" because we updated the paginator.  We now detect if the
   pagination has changed before updating it.

Combined, these changes allow the "slow mode" simulations to run nearly as fast
as the fast mode.  In Firefox, the UI updates in slow mode cause about 10%
runtime overhead.  Because of this, I removed the fast mode checkbox.

Fixes #23
rspeer commented 12 years ago

Thanks for all the fixes! I'm a bit low on time so I haven't checked all the code, but it sounds like you know what you're doing, so I've merged them all. Of course keep me updated if this makes something go wrong.