Discuss Scratch

Haycat2009
Scratcher
500+ posts

2D list engine reccomendations

Can anyone recommend any 2d list engines that allow an arbitrary constantly-changing number of rows and columns, as well as having custom blocks that allow for any individual cell to be read or edited given a coordinate?

Last edited by Haycat2009 (Yesterday 03:00:38)

awesome-llama
Scratcher
1000+ posts

2D list engine reccomendations

What's your use case? There are lots of ways a 2D list or array can be implemented, and it's important to consider their strengths and weaknesses.
Haycat2009
Scratcher
500+ posts

2D list engine reccomendations

awesome-llama wrote:

What's your use case? There are lots of ways a 2D list or array can be implemented, and it's important to consider their strengths and weaknesses.
Its for a tile grid. It needs to be able to have individual x and y positions precisely edited or read.
awesome-llama
Scratcher
1000+ posts

2D list engine reccomendations

Haycat2009 wrote:

awesome-llama wrote:

What's your use case? There are lots of ways a 2D list or array can be implemented, and it's important to consider their strengths and weaknesses.
Its for a tile grid. It needs to be able to have individual x and y positions precisely edited or read.
What are the expected dimensions or how many items do you expect to need? Do you need to read/write fast? What values do the cells contain?

If you are making a game where you need fast reads to draw things onto the screen, I would suggest something based on a 2D array.

Resizing will likely add a lot of complexity, but this is only a guess because I don't know what you are making. For a 2D array, one way would be to allocate space for the largest allowed dimensions of your use case. Smaller dimensions can use a subset of it, which saves the need to reorder the items. (You mention needing to constantly change the dimensions which can be costly to performance.)

Alternatively, a popular method found in tile-based games is to split the world up into “chunks”. The chunks form a larger grid. Each chunk is an array. This comes with benefits like not needing to reorder individual tiles as chunks can be allocated as needed.
dem_bot
Scratcher
1000+ posts

2D list engine reccomendations

I made this little thingy, which may be interesting
https://scratch.mit.edu/projects/1381884561/
it's an engine that can be used for doing stuff with n dimensional lists

Powered by DjangoBB