gbonsai

[DORMANT] a port of cbonsai to go
git clone git://git.figbert.com/gbonsai.git
Log | Files | Refs | README | LICENSE

model.go (991B)


      1 package main
      2 
      3 import "os"
      4 
      5 type model struct {
      6 	width  int
      7 	height int
      8 	conf   config
      9 }
     10 
     11 type config struct {
     12 	live        bool
     13 	infinite    bool
     14 	screensaver bool
     15 	printTree   bool
     16 	verbose     bool
     17 
     18 	life              int
     19 	multiplier        int
     20 	base              int
     21 	seed              int
     22 	targetBranchCount int
     23 
     24 	timeStep float64
     25 	timeWait float64
     26 
     27 	message  string
     28 	saveFile string
     29 	loadFile string
     30 
     31 	leaves [64]string
     32 }
     33 
     34 func initialModel() model {
     35 	var userCache string
     36 	if cache, err := os.UserCacheDir(); err == nil {
     37 		userCache = cache + "/gbonsai"
     38 	} else if home, err := os.UserHomeDir(); err == nil {
     39 		userCache = home + "/.cache/gbonsai"
     40 	} else if current, err := os.Getwd(); err == nil {
     41 		userCache = current + "/.gbonsai"
     42 	}
     43 
     44 	c := config{
     45 		life:              32,
     46 		multiplier:        5,
     47 		base:              1,
     48 		seed:              0,
     49 		targetBranchCount: 0,
     50 
     51 		timeStep: 0.03,
     52 		timeWait: 4,
     53 
     54 		saveFile: userCache,
     55 		loadFile: userCache,
     56 	}
     57 	return model{conf: c}
     58 }