pasky / pachi

A fairly strong Go/Baduk/Weiqi playing program
http://pachi.or.cz/
GNU General Public License v2.0
510 stars 116 forks source link

Spring cleanup: time options and help #65

Closed lemonsqueeze closed 6 years ago

lemonsqueeze commented 7 years ago

Hi,

Some time ago i thought it might be good to cleanup the parts of Pachi i was involved with. It started with a few lines here and there, and next thing i knew it was spring cleanup in my tree.

Here's what i got so far: there are a few extra functionality / fixes, but other than that none of the cleanup changes are absolutely necessary. For the most part I'm happy with them though, they do make hacking Pachi more enjoyable =)

Many of the changes i've had in my tree for a long time and didn't notice anything bad so i'm confident with them, but the latest ones haven't been tested extensively yet. So not ready to merge at this point, but comments welcome.

I'll try to split them into different PRs to make it more manageable.

lemonsqueeze commented 7 years ago

This PR adds support for long options and adds two new time options which are nice on kgs:

Tried to make --help more helpful. How about something like this:

./pachi: unrecognized option '--help'
Pachi version 11.99 (Genjo-devel)
Usage: ./pachi [OPTIONS] [ENGINE_ARGS]

Options: 
  -c, --chatfile FILE               set kgs chatfile 
  -d, --debug-level LEVEL           set debug level 
  -D                                don't log board diagrams 
  -e, --engine ENGINE               select engine: (default uct) 
                                    random|replay|montecarlo|uct|distributed|dcnn|patternplay 
  -f, --fbook FBOOKFILE             use opening book 
  -g, --gtp-port [HOST:]GTP_PORT    read gtp commands from network instead of stdin. 
                                    listen on given port if HOST not given, otherwise 
                                    connect to remote host. 
  -l, --log-port [HOST:]LOG_PORT    log to remote host instead of stderr 
  -r, --rules RULESET               rules to use: (default chinese) 
                                    japanese|chinese|aga|new_zealand|simplified_ing 
  -s, --seed RANDOM_SEED            set random seed 
  -t, --time TIME_SETTINGS          force basic time settings (override kgs/gtp time settings) 
      --fuseki-time TIME_SETTINGS   specific time settings to use during fuseki 
  -u, --unit-test FILE              run unit tests 

TIME_SETTINGS: 
  =SIMS           fixed number of Monte-Carlo simulations per move 
                  Pachi will play fast on a fast computer, slow on a slow computer, 
                  but strength will remain the same. 
  =SIMS:MAX_SIMS  same but allow playing up-to MAX_SIMS simulations if best move is unclear. 
                  useful to avoid blunders when playing with very low number of simulations. 
  SECS            fixed number of seconds per move 
                  Pachi will spend a little less to allow for network latency and other 
                  unexpected slowdowns. This is the same as one-period japanese byoyomi. 
  _SECS           absolute time: use fixed number of seconds for the whole game

  Examples:       pachi -t =5000            5000 simulations per move 
                  pachi -t =5000:15000      max 15000 simulations per move 
                  pachi -t 20               20s per move 
                  pachi -t _600             10min game, sudden death 

I'm impressed that time settings make such a big difference, -t =5000:15000 is almost half a stone stronger than -t =5000 on kgs while still playing pretty fast on low-end machines. I guess it avoids many blunders.