Last active
November 19, 2017 01:25
-
-
Save jmuzsik/76d83464771ce677f0d38c9e04951e51 to your computer and use it in GitHub Desktop.
Go introduction, instructional purposes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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