本文整理汇总了Golang中github.com/dnesting/alife/goalife/grid2d.Grid.Get方法的典型用法代码示例。如果您正苦于以下问题:Golang Grid.Get方法的具体用法?Golang Grid.Get怎么用?Golang Grid.Get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/dnesting/alife/goalife/grid2d.Grid
的用法示例。
在下文中一共展示了Grid.Get方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: printLoop
func printLoop(ch <-chan []grid2d.Update, g grid2d.Grid, cns *census.DirCensus, cond *sync.Cond, numUpdates *int64, clearScreen bool) {
// Try to keep rendering smooth.
runtime.LockOSThread()
for _ = range ch {
if clearScreen {
// TODO(dnesting): use termcap/terminfo to do this more portably.
fmt.Print("[H")
}
term.PrintWorld(os.Stdout, g)
fmt.Println()
if clearScreen {
fmt.Print("[J")
}
// Write some summary stats after the rendering.
fmt.Printf("%d updates\n", atomic.LoadInt64(numUpdates))
fmt.Printf("%d/%d orgs (%d/%d species, %d recorded)\n", cns.Count(), cns.CountAllTime(), cns.Distinct(), cns.DistinctAllTime(), cns.NumRecorded())
if loc := g.Get(0, 0); loc != nil {
fmt.Printf("random: %v\n", loc.Value())
}
// If we're running with --sync, signal to any goroutines waiting on a rendering that
// it's OK for them to continue again.
if cond != nil {
cond.Broadcast()
}
}
}