Skip to content

Instantly share code, notes, and snippets.

View jmuzsik's full-sized avatar
⏲️

Jerry jmuzsik

⏲️
View GitHub Profile
findExit(clone, maze) {
//go to a random location that is not where the clone is
if( maze.location.next.length === 3 ) {
let currentLocation = clone.direction( maze.location.next[
Math.floor(Math.random()*3)]
) )
} //...more if's, etc.
if( currentLocation === maze.location.final ) {
return theMeaningOfLife
}
@jmuzsik
jmuzsik / golang-example-3.go
Last active November 19, 2017 01:25
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 {
type LocationProps struct {
next []string
final string
}
type Location struct {
props LocationProps
}
type Maze struct {
Location
Directions [][]int
Height int
Width int
}
type CloneAction interface {
goDifLocation(location string)
findExit(m Maze)
}
func (*c Clone) goDifLocation(l string) {
/*c.goDifLocation can now occur in different functions*/
}
func (c Clone) findExit(m Maze) TheMeaningOfLife {/*...*/}
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 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)
}
}
{
Location: {
next:["a1","a2","a3"],//or the like
final:"z99"
}
Directions: [[/*giant*/][/*array*/]],
Height: 1000,
Width: 10000
}