Skip to content

Instantly share code, notes, and snippets.

@jmuzsik
Last active November 19, 2017 01:25
Show Gist options
  • Save jmuzsik/76d83464771ce677f0d38c9e04951e51 to your computer and use it in GitHub Desktop.
Save jmuzsik/76d83464771ce677f0d38c9e04951e51 to your computer and use it in GitHub Desktop.
Go introduction, instructional purposes
type TheMeaningOfLife {
sustenance //this is not matched with anything, it is simply for meaning
}
type LocationProps struct {
next []string
final string
}
type Location struct {
props LocationProps
}
type Maze struct {
Location
Directions [][]int
Height int
Width int
}
type Clone struct {
cloneNumber int
}
type CloneAction interface {
goDifLocation(location string)
findExit(m Maze)
}
func (*c Clone) goDifLocation(l string) {
//This is a pointer, so it mutates what it is called on
//This does? Make clone go to the next location, return nothing
}
func (c Clone) findExit(m Maze) TheMeaningOfLife {
var currentLocation string
if len(m.Location.props.next) == 3 {
currentLocation = &c.goDifLocation(
m.Location.props.next[rand.Intn(
len(m.Location.props.next))])
}
//... etc.
if currentLocation == m.location.props.final {
return TheMeaningOfLife
}
}
func createMaze(height int, width int) Maze {
//create the maze
}
func main() {
mazeData := createMaze(1000, 10000)
maze := Maze{mazeData}
clones := make([]Clone, 1000000)
for i := range clones {
clones[i] = Clone{id: i}
go clones[i].findExit(maze)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment