![]() Self.vertices = for x in xrange(self.numRows*2+2)]ĮdgeLocations = self.getEdgeLocations(hexagon) Self.edges = for x in xrange(self.numRows*2+2)] Self.hexagons = for x in xrange(self.numRows)] # Layout is just a double list of Tiles, some will be None It was a fun problem, but the board took a lot of time, so in case anyone is still looking for a simple implementation here is our Python code: class Board: We implemented a Settlers of Catan AI for a class project, and modified code from this answer (which was buggy) to create a Board with constant time random access to vertices and edges. Hopefully, that might give you some ideas about one way to approach it though. ![]() You could use pointers rather than arrays, you could use objects rather than records, and you could store your hexes in a two-dimensional array as other answerers have suggested. There are many things that you could do a different way of course. Each edge keeps track of its two adjoining hexes, and each vertex keeps track of its three adjoining hexes (hexes on the edges of the map will be a special case). Vertices: array of Integer // Index of vertex.Įach hex has six edges and six vertices. Hexes: array of Integer // Index of adjoining hexes.Įdges: array of Integer // Index of edge. I would suggest something like the following (I'll use Delphi-style declarations): type
0 Comments
Leave a Reply. |