data structure used for snood?

Started by
4 comments, last by mickeyren 11 years, 10 months ago
Is it a graph? Im wondering what the data structure used to hold the data that represents the balls. Perhaps a 2d array would do?
Advertisement
A 2D array would probably be fine :-)

Wielder of the Sacred Wands
[Work - ArenaNet] [Epoch Language] [Scribblings]

Perhaps a 2d array would do?


Yes; the trick lies in determing the neighbors of a cell. A cell in rigid 2D grid has only 4 neighbors, whereas a cell in a "jagged" 2D grid has 6.
guys thanks for the hints - but i may need some more elaboration.

the thing i couldn't figure out is since Snood has its balls lined up diagonally in an alternate manner, can you guys explain some more how a simple 2d array would do?

fastcall22:

can you also elaborate some more on the "jagged", like how do i figure out the connecting balls?
can you guys explain some more how a simple 2d array would do?[/quote]

This is your array:
A B C
D E F
G H I


This is your array on drugs:
A B C
D E F
G H I


like how do i figure out the connecting balls?[/quote]

E, for example, is connected to: A, B, D, F, G, H.


Neighbours of a cell in regular 2D array have relative coordinates, (-1, 0), (1, 0), (0, -1), (0, 1)
In jagged array, they would be: (-1, 1), (0, 1), (-1, 0), (1, 0), (-1, -1), (0, -1).


It may help to draw things out on paper.

In jagged representation, there might also be an unused cell at beginning or end of each row.
thank you so much i think these information concludes my inquiring thoughts.

This topic is closed to new replies.

Advertisement