This file contains hidden or 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
| 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 | |
| } |
This file contains hidden or 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 { |
This file contains hidden or 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 LocationProps struct { | |
| next []string | |
| final string | |
| } |
This file contains hidden or 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 Location struct { | |
| props LocationProps | |
| } | |
| type Maze struct { | |
| Location | |
| Directions [][]int | |
| Height int | |
| Width int | |
| } |
This file contains hidden or 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 CloneAction interface { | |
| goDifLocation(location string) | |
| findExit(m Maze) | |
| } |
This file contains hidden or 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
| func (*c Clone) goDifLocation(l string) { | |
| /*c.goDifLocation can now occur in different functions*/ | |
| } |
This file contains hidden or 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
| func (c Clone) findExit(m Maze) TheMeaningOfLife {/*...*/} |
This file contains hidden or 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
| 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 |
This file contains hidden or 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
| 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) | |
| } | |
| } |
This file contains hidden or 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
| { | |
| Location: { | |
| next:["a1","a2","a3"],//or the like | |
| final:"z99" | |
| } | |
| Directions: [[/*giant*/][/*array*/]], | |
| Height: 1000, | |
| Width: 10000 | |
| } |
OlderNewer