func createController() *env.Controller { var controller *env.Controller controller = new(env.Controller) var tileMap = env.LoadMap(arg.File()) controller.InitController(tileMap) return controller }
func pathfindEnvironment(discoverAll bool) (*env.Controller, *TileState) { var cont *env.Controller var tile *TileState var tileMap [env.MAX_SIZE][env.MAX_SIZE]bool tileMap[0][0] = true tileMap[0][1] = true tileMap[0][2] = true tileMap[1][2] = true tileMap[2][2] = true tileMap[2][1] = true tileMap[2][0] = true cont = new(env.Controller) cont.InitController(tileMap) tile = new(TileState) tile.AddDiscovery(cont.GetStartingTile()) // Mark all walls where there are no tiles for x := 0; x < env.MAX_SIZE; x++ { for y := 0; y < env.MAX_SIZE; y++ { if !tileMap[x][y] { tile.tiles[x][y].explored = true } } } if discoverAll { t := cont.GetStartingTile() t = t.GetNeighbour(env.UP) // 0 1 tile.AddDiscovery(t) t = t.GetNeighbour(env.UP) // 0 2 tile.AddDiscovery(t) t = t.GetNeighbour(env.RIGHT) // 1 2 tile.AddDiscovery(t) t = t.GetNeighbour(env.RIGHT) // 2 2 tile.AddDiscovery(t) t = t.GetNeighbour(env.DOWN) // 2 1 tile.AddDiscovery(t) t = t.GetNeighbour(env.DOWN) tile.AddDiscovery(t) // 2 0 } return cont, tile }
func createDummyEnvController() *env.Controller { var c *env.Controller = new(env.Controller) var tileMap [env.MAX_SIZE][env.MAX_SIZE]bool tileMap[0][0] = true tileMap[1][0] = true tileMap[2][0] = true tileMap[0][1] = true tileMap[1][1] = true tileMap[2][1] = true c.InitController(tileMap) return c }