Jump to content
  • Advertisement
Sign in to follow this  
Concentrate

Design question, need opinion

This topic is 2547 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

The main problem is flexibly representing a maze data structure.

I have this Cell class

class Cell{
Shape cellShape;
bool visited;
//...
};


I have this maze class

class MazeGrid{
private:
//typedef boost::multi_array<Cell, 2> GridType;
typedef IGenerator::GridType GridType;

typedef boost::shared_ptr<IGenerator> GeneratorType;
GridType grid;
GeneratorType generator;
public:
MazeGrid();
MazeGrid(const size_t w, const size_t h, IGenerator generator);
//....
};


I have this Maze Generator class:

//Base Generator
struct IGenerator{
typedef boost::multi_array<Cell, 2> GridType;
virtual GridType generateMaze() = 0;
};


Now the question is how can I flexibly abstract GridType such that the MazeGrid is not coupled to the type returned by the IGenerator? What do you guys think?

Share this post


Link to post
Share on other sites
Advertisement
Why does your maze grid need to store a pointer to a generator? Once it's generated why would it care how it was generated?

Share this post


Link to post
Share on other sites

Why does your maze grid need to store a pointer to a generator? Once it's generated why would it care how it was generated?



I was thinking of enabling itself to regenerate if the user wishes to do so.

Share this post


Link to post
Share on other sites

[quote name='D.Chhetri' timestamp='1324705947' post='4897017']
What do you guys think?


That you're over-engineering things.
[/quote]


Ok, can you explain please and possibly give a possible design? Thanks.

Share this post


Link to post
Share on other sites

[quote name='Telastyn' timestamp='1324736164' post='4897067']
[quote name='D.Chhetri' timestamp='1324705947' post='4897017']
What do you guys think?


That you're over-engineering things.
[/quote]


Ok, can you explain please and possibly give a possible design? Thanks.
[/quote]

GridType? Just make the maps you need. Or simply:

[source]

class IMapGenerator<T>{
public:
virtual T GenerateMap() = 0;
};

[/source]

Where T is whatever collection of map nodes that your game wants. Though I still can't see the benefit of this since you need to know what you're getting out when you instantiate the things. The interface provides no benefit since you can't interchange them. Just make a function to generate the map and maybe a class to define what the map is.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!