gotak/gotak.go
changeset 12 37fd81bab065
parent 11 cd1296df76f1
child 15 eac7d78ff641
equal deleted inserted replaced
11:cd1296df76f1 12:37fd81bab065
    10 	"fmt"
    10 	"fmt"
    11 	"log"
    11 	"log"
    12 	"os"
    12 	"os"
    13 	"time"
    13 	"time"
    14 
    14 
    15 	flag "github.com/docker/docker/pkg/mflag"
    15 	"github.com/spf13/pflag"
    16 
    16 
    17 	"hg.lilotux.net/golang/mikael/takuzu"
    17 	"hg.lilotux.net/golang/mikael/takuzu"
    18 )
    18 )
    19 
    19 
    20 var verbosity int
    20 var verbosity int
    45 	tak := <-results
    45 	tak := <-results
    46 	return tak
    46 	return tak
    47 }
    47 }
    48 
    48 
    49 func main() {
    49 func main() {
    50 	vbl := flag.Uint([]string{"-vl"}, 0, "Verbosity Level")
    50 	vbl := pflag.Uint("vl", 0, "Verbosity Level")
    51 	simple := flag.Bool([]string{"-simple"}, false, "Only look for trivial solutions")
    51 	simple := pflag.Bool("simple", false, "Only look for trivial solutions")
    52 	out := flag.Bool([]string{"-out"}, false, "Send solution string to output")
    52 	out := pflag.Bool("out", false, "Send solution string to output")
    53 	board := flag.String([]string{"-board"}, "", "Load board string")
    53 	board := pflag.String("board", "", "Load board string")
    54 	schrodLvl := flag.Uint([]string{"-x-sl"}, 0, "[Advanced] Schrödinger level")
    54 	schrodLvl := pflag.Uint("x-sl", 0, "[Advanced] Schrödinger level")
    55 	resolveTimeout := flag.Duration([]string{"-x-timeout"}, 0, "[Advanced] Resolution timeout")
    55 	resolveTimeout := pflag.Duration("x-timeout", 0, "[Advanced] Resolution timeout")
    56 	buildBoardTimeout := flag.Duration([]string{"-x-build-timeout"}, 5*time.Minute, "[Advanced] Build timeout per resolution")
    56 	buildBoardTimeout := pflag.Duration("x-build-timeout", 5*time.Minute, "[Advanced] Build timeout per resolution")
    57 	reduceBoardTimeout := flag.Duration([]string{"-x-reduce-timeout"}, 20*time.Minute, "[Advanced] Reduction timeout")
    57 	reduceBoardTimeout := pflag.Duration("x-reduce-timeout", 20*time.Minute, "[Advanced] Reduction timeout")
    58 	buildMinRatio := flag.Uint([]string{"-x-new-min-ratio"}, 55, "[Advanced] Build empty cell ratio (40-60)")
    58 	buildMinRatio := pflag.Uint("x-new-min-ratio", 55, "[Advanced] Build empty cell ratio (40-60)")
    59 	buildMaxRatio := flag.Uint([]string{"-x-new-max-ratio"}, 62, "[Advanced] Build empty cell ratio (50-99)")
    59 	buildMaxRatio := pflag.Uint("x-new-max-ratio", 62, "[Advanced] Build empty cell ratio (50-99)")
    60 	all := flag.Bool([]string{"-all"}, false, "Look for all possible solutions")
    60 	all := pflag.Bool("all", false, "Look for all possible solutions")
    61 	reduce := flag.Bool([]string{"-reduce"}, false, "Try to reduce the number of digits")
    61 	reduce := pflag.Bool("reduce", false, "Try to reduce the number of digits")
    62 	buildNewSize := flag.Uint([]string{"-new"}, 0, "Build a new takuzu board (with given size)")
    62 	buildNewSize := pflag.Uint("new", 0, "Build a new takuzu board (with given size)")
    63 	pdfFileName := flag.String([]string{"-to-pdf"}, "", "PDF output file name")
    63 	pdfFileName := pflag.String("to-pdf", "", "PDF output file name")
    64 	workers := flag.Uint([]string{"-workers"}, 1, "Number of parallel workers (use with --new)")
    64 	workers := pflag.Uint("workers", 1, "Number of parallel workers (use with --new)")
    65 
    65 
    66 	flag.Parse()
    66 	pflag.Parse()
    67 
    67 
    68 	verbosity = int(*vbl)
    68 	verbosity = int(*vbl)
    69 	takuzu.SetVerbosityLevel(verbosity)
    69 	takuzu.SetVerbosityLevel(verbosity)
    70 	takuzu.SetSchrodingerLevel(*schrodLvl)
    70 	takuzu.SetSchrodingerLevel(*schrodLvl)
    71 
    71