This is a standard for programming languages! I don't understand why Scratch can't have it. It is possible to replace a 2-D array with several lists, or one list that is very long, but that is time consuming.
Count my vote for this in !
Offline
OK, my Matrices topic got closed as a duplicate of this. So it's moving here.
Offline
bump
Offline
I won't finish my AI tic-tac-toe until this is implemented!!!
Offline
joefarebrother wrote:
I won't finish my AI tic-tac-toe until this is implemented!!!
I actually was working on a Connect Four game w/ AI, but imagine how difficult it would be without matrices!
Offline
bump
Offline
bump
Offline
*brings back from third page*
Offline
Excellent idea! Matrices would be really cool. I don't need it now, but in other projects, it would be handy!
Offline
scratchisthebest wrote:
Excellent idea! Matrices would be really cool. I don't need it now, but in other projects, it would be handy!
Thanks for supporting it!
Ack! 60 second rule!
Offline
I suggest that arrays can be made in Scratch 2.0 like in BYOB.
For those of you who don't know the difference between an array and list, look here.
If you don't want to, then here's an explanation:
Variables are one value.
Lists are a set of values, but only in one dimension, MEANING that you can only have |add thing to list|
Arrays are multidimensional lists, meaning that you can have |add <item 1 of <item 1 of list>>to list| if you have a three dimensional array.
Made using BYOB
Ways it will be useful: One grand array, with sub-lists inside. Particularly useful for some OS's.
Offline
The above post was a separate topic that I merged on to here. Since it asks for multi-dimensional arrays beyond 2-D, it extends the scope of the original suggestion.
Offline
Paddle2See wrote:
I would like higher order arrays...but we must remember that Scratch's first goal is to be approachable to beginners. You can always construct an indexing formula so that a 2D array can be stored in a 1D array.
Example:
If you want to store a 2D array with rows that are 9 elements long in a 1D list then the formula might be
Item_Number = (Row_Number-1) * 9 + Column_Number
you said "Scratch's first goal is to be approachable to beginners" but what is you did not put it in scratch and put it on the scratch web site, so we can put it in our scratch image?
Offline
I agree!! Its very very hard to make grid based games and storing date in lists.... I accidentally destroyed my programming in a whole project trying to figure it out... We really need this!
Offline
LEGOengineer261 wrote:
I agree!! Its very very hard to make grid based games and storing date in lists.... I accidentally destroyed my programming in a whole project trying to figure it out... We really need this!
Epic necropost. Anyway, arrays are not needed that bad, as they have a very simple workaround (see this).
Offline
to make a 2D array, you just need a list with strings; the letter position in the strings is the third direction.
Offline
It may be a bit late but ...
TOTALLY SUPPORT!
This is what so many miss about Scratch and I don't think it would make things that difficult. Beginners will just use the 1. Dimension only^^ And what do we have a wiki for?
2D-Arrays would be so useful for many, many Scratchers and their projects, please make it possible!!
Offline
This would be a great step towards making strategy games more common among Scratch projects. Here are a few block I think might be nice:
when gf clicked delete [all v] of table [Terrain v] repeat until <(join ((# of rows v) of table (Terrain v)) ((# of columns v) of table (Terrain v))) = (99)>//Scratch does not like nonexistent blocks. :P add (0) to table [Terrain v] in [row v](1)//Adds an item to the end or a row/column. add (0) to table [Terrain v] in [column v](1) end insert (1) to table [Terrain v] in row(5) col(5)//Replaces this item with another. replace [row v](9) of table [Terrain v] with (1)//Replaces entire row with one item. replace [column v](9) of table [Terrain v] with (1) replace [all v] [empty blocks v] of table [Terrain v] with (0)//Replaces all items of a type (empty/full) with one item.This would produce this table:
11:1 21:1 31:1 41:1 51:1 61:1 71:1 81:1 91:1 12:1 22:0 32:0 42:0 52:0 62:0 72:0 82:0 92:1 13:1 23:0 33:0 43:0 53:0 63:0 73:0 83:0 93:1 14:1 24:0 34:0 44:0 54:0 64:0 74:0 84:0 94:1 15:1 25:0 35:0 45:0 55:1 65:0 75:0 85:0 95:1 16:1 26:0 36:0 47:0 56:0 66:0 76:0 86:0 96:1 17:1 27:0 37:0 47:0 57:0 67:0 77:0 87:0 97:1 18:1 28:0 38:0 48:0 58:0 68:0 78:0 88:0 89:1 19:1 29:1 39:1 49:1 59:1 69:1 79:1 89:1 99:1
I really hope this gets implemented...
Offline
It's already possible, my game Path uses a 16x16 array with the (letter () of []) block. And to edit one you just load the item you need into a separate list as single items, edit it and replace the old item. For items larger than 1 letter, you just iteratively add it to a temp until it reaches a break character (a space) then adds that to the edit list.
I just don't think enough people would use it for there to be a need, especially since there is a workaround.
Offline
Hey, use this.
1. 1. 1. orange. 1. 1. 1. 1. 1. asparagus. 1.
becomes
1. 1. 1. orange. 1. 1. 1. 1. 1. asparagus. 1.
and is named "array" and another list is created, with the lengths, added with the previous one:
3. 6. 11.
and then
(item ((item (y) of [lenghts v]) - ((item (y) of [lenghts v]) - (x))) of [array v])can be used.
Last edited by BirdByte (2012-09-16 08:46:58)
Offline
zammer990 wrote:
It's already possible, my game Path uses a 16x16 array with the (letter () of []) block. And to edit one you just load the item you need into a separate list as single items, edit it and replace the old item. For items larger than 1 letter, you just iteratively add it to a temp until it reaches a break character (a space) then adds that to the edit list.
I just don't think enough people would use it for there to be a need, especially since there is a workaround.
People would only use this for every tile-based game, like Minecraft-style games on Scratch, strategy gams like Civilization, and most board games... One reason these are less prevalent, I believe, is that it's harder to program these than simpler action games or animations. This makes those games easier.
The "workaround" you speak of needs a text parser that completely rewrites an item both for input and output for changes to the list. This might be feasible for a 16x16 board, but if it is much larger, such as 40x30, then rewriting an entire line for only one change means also inefficiently rewriting 39 unneeded blocks within that item. This is just a horribly slow process and really could be simplified with a table.
Offline
OverPowered wrote:
zammer990 wrote:
It's already possible, my game Path uses a 16x16 array with the (letter () of []) block. And to edit one you just load the item you need into a separate list as single items, edit it and replace the old item. For items larger than 1 letter, you just iteratively add it to a temp until it reaches a break character (a space) then adds that to the edit list.
I just don't think enough people would use it for there to be a need, especially since there is a workaround.People would only use this for every tile-based game, like Minecraft-style games on Scratch, strategy gams like Civilization, and most board games... One reason these are less prevalent, I believe, is that it's harder to program these than simpler action games or animations. This makes those games easier.
The "workaround" you speak of needs a text parser that completely rewrites an item both for input and output for changes to the list. This might be feasible for a 16x16 board, but if it is much larger, such as 40x30, then rewriting an entire line for only one change means also inefficiently rewriting 39 unneeded blocks within that item. This is just a horribly slow process and really could be simplified with a table.
You could just use a list, like me and birdbyte do. One place for each element. This generalizes to higher dimensions too!
Offline