gabo-tor / gocellular Goto Github PK
View Code? Open in Web Editor NEW3d cellular automata with a GUI in GO!
License: MIT License
3d cellular automata with a GUI in GO!
License: MIT License
Line 211 in fba6a09
for i, c := range board {
if i > 0 && i < SIZE-1 {
//becomes
for i := 1; i<SIZE-1;i++ {
c := board[i]
// same suggestion for inner loops
Line 117 in fba6a09
if Neighbour == 1 {
// extract contents of `if` to a function countNeighborsMoore?
Encapsulate board logic in a type
type game struct {
board tensor3 // tensor3 type with contiguous allocation, stride mem access if you want to needlessly optimize, if not already existing [][][]uint8 is good enough
rules int // Moore==1, neumann==0
}
//suggestion for tensor3
type tensor3 struct {
data []uint8
r, c, d int //row, column, depth
// dynamic stride completely useless if no resizing going on
//stride1 int
//stride2 int
}
// set assigns v to element at position (i,j,k) of 3D tensor
func (t tensor3) set(i, j, k int, v uint8) {
// row major, depth minor. not sure if this is correct though
t.data[k + j*t.d + i*t.d*t.c] = v // 🤷
}
and add logic as methods to game
Use go modules so users can run the program and track go.mod
file for reproducible builds.
Steps:
go mod init gocellular
in the base directory. This generates an empty go.mod
file with the name of the module "gocellular".go mod tidy
. The go tool will then fetch dependencies for the project and update the go.mod
file. The tool will also generate the go.sum
file, which provides the project with exact versions for all required modules ensuring reproducible builds with these two files. This file is not "required" but helps ensure consistent builds.The result is that now anyone who clones the application with the go.mod
file can run the application from scratch. Take that virtual environments.
Line 303 in 2eba8f7
Becomes
ticker := time.NewTicker((1000 / FRECUENCY) * time.Millisecond)
go func() {
for range ticker.C {
// use close(ticker.C) to terminate this loop
update(board)
}
}()
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.