Changed type of maze in SolvedMaze to pointer, to

not copy the entire maze by value
This commit is contained in:
Karma Riuk 2023-08-10 10:30:37 +02:00
parent bd8165e47f
commit d1d3ed1c73
2 changed files with 13 additions and 13 deletions

View File

@ -13,7 +13,6 @@ func trivial() *maze.SolvedMaze {
#123# #123#
###4# ###4#
*/ */
ret := &maze.SolvedMaze{}
nodes := make([]*maze.Node, 5) nodes := make([]*maze.Node, 5)
nodes[0] = maze.NewNode(maze.Coordinates{X: 2, Y: 0}) nodes[0] = maze.NewNode(maze.Coordinates{X: 2, Y: 0})
@ -37,16 +36,17 @@ func trivial() *maze.SolvedMaze {
nodes[4].Up = nodes[3] nodes[4].Up = nodes[3]
solution := []*maze.Node{ ret := &maze.SolvedMaze{
nodes[0], nodes[2], nodes[3], nodes[4], Maze: &maze.Maze{
Width: 5,
Height: 3,
Nodes: nodes,
},
Solution: []*maze.Node{
nodes[0], nodes[2], nodes[3], nodes[4],
},
} }
ret.Nodes = nodes
ret.Width = 5
ret.Height = 3
ret.Solution = solution
return ret return ret
} }
@ -89,7 +89,7 @@ func bigger() *maze.SolvedMaze {
nodes[4].Up = nodes[3] nodes[4].Up = nodes[3]
ret := &maze.SolvedMaze{ ret := &maze.SolvedMaze{
Maze: maze.Maze{ Maze: &maze.Maze{
Width: 7, Width: 7,
Height: 5, Height: 5,
Nodes: nodes, Nodes: nodes,
@ -146,7 +146,7 @@ func bigger_staggered() *maze.SolvedMaze {
nodes[5].Up = nodes[4] nodes[5].Up = nodes[4]
ret := &maze.SolvedMaze{ ret := &maze.SolvedMaze{
Maze: maze.Maze{ Maze: &maze.Maze{
Width: 7, Width: 7,
Height: 5, Height: 5,
Nodes: nodes, Nodes: nodes,
@ -266,7 +266,7 @@ func normal() *maze.SolvedMaze {
} }
ret := &maze.SolvedMaze{ ret := &maze.SolvedMaze{
Maze: maze.Maze{ Maze: &maze.Maze{
Width: 11, Width: 11,
Height: 11, Height: 11,
Nodes: nodes, Nodes: nodes,

View File

@ -48,6 +48,6 @@ type Maze struct {
} }
type SolvedMaze struct { type SolvedMaze struct {
Maze *Maze
Solution []*Node Solution []*Node
} }