2012-08-06 19:38:35 -06:00
|
|
|
// cmpout
|
|
|
|
|
2016-04-10 15:32:26 -06:00
|
|
|
// Copyright 2010 The Go Authors. All rights reserved.
|
2010-04-09 14:31:26 -06:00
|
|
|
// Use of this source code is governed by a BSD-style
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
2015-12-04 20:51:03 -07:00
|
|
|
// +build test_run
|
2012-03-06 21:27:30 -07:00
|
|
|
|
2010-04-09 14:31:26 -06:00
|
|
|
// Run the game of life in C using Go for parallelization.
|
|
|
|
|
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2012-03-06 21:27:30 -07:00
|
|
|
"."
|
2010-04-09 14:31:26 -06:00
|
|
|
"flag"
|
|
|
|
"fmt"
|
|
|
|
)
|
|
|
|
|
|
|
|
const MAXDIM = 100
|
|
|
|
|
|
|
|
var dim = flag.Int("dim", 16, "board dimensions")
|
|
|
|
var gen = flag.Int("gen", 10, "generations")
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
flag.Parse()
|
|
|
|
|
2012-09-24 12:58:45 -06:00
|
|
|
var a [MAXDIM * MAXDIM]int32
|
2010-04-09 14:31:26 -06:00
|
|
|
for i := 2; i < *dim; i += 8 {
|
|
|
|
for j := 2; j < *dim-3; j += 8 {
|
|
|
|
for y := 0; y < 3; y++ {
|
|
|
|
a[i**dim+j+y] = 1
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-10-07 02:52:13 -06:00
|
|
|
life.Run(*gen, *dim, *dim, a[:])
|
2010-04-09 14:31:26 -06:00
|
|
|
|
|
|
|
for i := 0; i < *dim; i++ {
|
|
|
|
for j := 0; j < *dim; j++ {
|
|
|
|
if a[i**dim+j] == 0 {
|
|
|
|
fmt.Print(" ")
|
|
|
|
} else {
|
|
|
|
fmt.Print("X")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fmt.Print("\n")
|
|
|
|
}
|
|
|
|
}
|