Closed SamanthaDawsonBanks closed 6 years ago
And yet again I show how I need to check my posts in the morning...
This shouldn't be inheritance it should be composition.
A scored vertex will be composed if a base vertex and some new data and behaviour. All through the use of a constructor. Sorry for leading you in the wrong direction Harry
I'm still not happy with this as polymorphism would be more useful, let me chew on it for a bit then i will bung up a PR for it (it might need to get wrapped into the AStar rework you are thinking of)
I think a subclass is fine, but we should be passing the Vertex through a heuristic method which returns a new scored vertex (the result of the scoring). The algorithm then handles a collection of scored vertex objects which it can throw away once the pathfinding is complete. Storing the score in the current vertex will dramatically increase the size of the Herd object and therefore the traffic passed between Herd members.
From the PR I can see you went with inheritance, over composition. I mean i would assume either would work. When the PR is merged I will refactor the AStar.
done
As one (the Vertex) is the base object (a place in graph theory, nodal space) and the second (the ScoredVertex) is a specialised (mostly for pathfinding) version that extends it and has the addition of the scoring stuff?