This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#51 2011-08-02 18:23:55

cygene
Scratcher
Registered: 2011-05-31
Posts: 100+

Re: 2-D Arrays

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  big_smile !


http://cygene.wikispaces.com/file/view/clip2.gif/242526033/clip2.gif

Offline

 

#52 2011-08-06 21:23:17

Greenatic
Scratcher
Registered: 2009-05-03
Posts: 1000+

Re: 2-D Arrays

OK, my Matrices topic got closed as a duplicate of this.  So it's moving here.

Offline

 

#53 2011-08-11 08:01:35

Greenatic
Scratcher
Registered: 2009-05-03
Posts: 1000+

Offline

 

#54 2011-08-11 08:19:38

joefarebrother
Scratcher
Registered: 2011-04-08
Posts: 1000+

Re: 2-D Arrays

I won't finish my AI tic-tac-toe until this is implemented!!!


My latest project is called http://tinyurl.com/d2m8hne! It has http://tinyurl.com/d395ygk views, http://tinyurl.com/cnasmt7 love-its, and http://tinyurl.com/bwjy8xs comments.
http://tinyurl.com/756anbk   http://tinyurl.com/iplaychess

Offline

 

#55 2011-08-11 09:48:51

Greenatic
Scratcher
Registered: 2009-05-03
Posts: 1000+

Re: 2-D Arrays

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!   yikes

Offline

 

#56 2011-08-13 20:55:57

Greenatic
Scratcher
Registered: 2009-05-03
Posts: 1000+

Offline

 

#57 2011-08-16 08:47:45

Greenatic
Scratcher
Registered: 2009-05-03
Posts: 1000+

Offline

 

#58 2011-08-22 10:40:46

Greenatic
Scratcher
Registered: 2009-05-03
Posts: 1000+

Re: 2-D Arrays

*brings back from third page*

Offline

 

#59 2011-08-29 17:12:06

scratchisthebest
Scratcher
Registered: 2009-02-08
Posts: 500+

Re: 2-D Arrays

Excellent idea! Matrices would be really cool. I don't need it now, but in other projects, it would be handy!


bye 1.4, we all loved you. but we all outgrew the site. 2.0 is a welcome change.
http://scratch.mit.edu/img/Pico3-med.pnghttp://scratch.mit.edu/img/Pico3-med.pnghttp://scratch.mit.edu/img/Pico3-med.pnghttp://scratch.mit.edu/img/Pico3-med.pnghttp://scratch.mit.edu/img/Pico3-med.png

Offline

 

#60 2011-08-29 21:36:30

Greenatic
Scratcher
Registered: 2009-05-03
Posts: 1000+

Re: 2-D Arrays

scratchisthebest wrote:

Excellent idea! Matrices would be really cool. I don't need it now, but in other projects, it would be handy!

big_smile   Thanks for supporting it!   big_smile

Ack!  60 second rule!   sad

Offline

 

#61 2011-11-08 20:10:11

SJRCS_011
Scratcher
Registered: 2011-02-07
Posts: 1000+

Re: 2-D Arrays

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.
http://farm7.static.flickr.com/6050/6326867033_68583a154e_m.jpg

Lists are a set of values, but only in one dimension, MEANING that you can only have |add thing to list|
http://farm7.static.flickr.com/6058/6326867031_6af4100c06_m.jpg

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.
http://farm7.static.flickr.com/6225/6326867025_3543e79ef6_m.jpg
Made using BYOB


Ways it will be useful: One grand array, with sub-lists inside.  Particularly useful for some OS's.


http://i.imgur.com/vQqtH.png
Learning to Program in a Nutshell:  "You're missing a closing parentheses" - LS97

Offline

 

#62 2011-11-09 14:51:23

Paddle2See
Scratch Team
Registered: 2007-10-27
Posts: 1000+

Re: 2-D Arrays

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.


http://i39.tinypic.com/2nav6o7.gif

Offline

 

#63 2011-12-02 05:15:12

jurk
Scratcher
Registered: 2010-05-06
Posts: 100+

Re: 2-D Arrays

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?


http://dl.dropbox.com/u/54228408/cool.png

Offline

 

#64 2012-08-30 16:14:21

LEGOengineer261
Scratcher
Registered: 2011-11-16
Posts: 100+

Re: 2-D Arrays

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!


http://i1156.photobucket.com/albums/p562/LEGOengineer261/IronmanSERIOUSBOSS.jpg

Offline

 

#65 2012-08-30 16:36:07

taddl
Scratcher
Registered: 2009-03-08
Posts: 100+

Re: 2-D Arrays

I posted once, that they should add tables.
I support!!!


http://blocks.scratchr.org/API.php?action=projects&amp;type=newest&amp;return=image&amp;user=taddl
http://blocks.scratchr.org/API.php?user=taddl&amp;action=projects&amp;type=newest&amp;return=text&amp;num=1

Offline

 

#66 2012-08-30 16:38:44

Molybdenum
Scratcher
Registered: 2012-06-17
Posts: 1000+

Re: 2-D Arrays

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).


"The Enrichment Center is required to remind you that you will be baked, and then there will be cake."
(|Balls and Platforms: Stay on!|) (|NaOS-H: An operating system... Or is it?|)

Offline

 

#67 2012-08-30 16:48:08

thebriculator
Scratcher
Registered: 2011-07-11
Posts: 500+

Re: 2-D Arrays

to make a 2D array, you just need a list with strings; the letter position in the strings is the third direction.


.     http://tiny.cc/2cwgpw    http://tiny.cc/viwgpw    http://tiny.cc/iwwgpw

Offline

 

#68 2012-09-01 18:45:34

xJira
Scratcher
Registered: 2012-03-24
Posts: 91

Re: 2-D Arrays

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

 

#69 2012-09-01 19:14:36

legobob23o
Scratcher
Registered: 2012-06-22
Posts: 500+

Re: 2-D Arrays

Maybe. Sounds good.

Offline

 

#70 2012-09-01 20:16:25

dvd4
Scratcher
Registered: 2010-06-30
Posts: 1000+

Re: 2-D Arrays

this sounds like a very good idea


I made a mod  big_smile  It's called blook!
http://i49.tinypic.com/16ia63p.png

Offline

 

#71 2012-09-02 00:10:45

OverPowered
Scratcher
Registered: 2012-07-27
Posts: 100+

Re: 2-D Arrays

This would be a great step towards making strategy games more common among Scratch projects.  smile  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:

Code:

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...  smile


Newest project: Tunnel TEST ~http://blocks.scratchr.org/API.php?user=OverPowered&amp;action=onlineStatus~ On my mind: Unicameralism

Offline

 

#72 2012-09-02 07:18:36

zammer990
Scratcher
Registered: 2012-01-22
Posts: 500+

Re: 2-D Arrays

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.


http://i45.tinypic.com/2ynq7nn.jpg Play now!

Offline

 

#73 2012-09-02 08:41:59

BirdByte
Scratcher
Registered: 2012-07-07
Posts: 1000+

Re: 2-D Arrays

Hey, use this.

Code:

1. 1. 1.
orange. 1. 1.
1. 1. 1. asparagus. 1.

becomes

Code:

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:

Code:

3.
6.
11.

and then

(item ((item (y) of [lenghts v]) - ((item (y) of [lenghts v]) - (x))) of [array v])
can be used.  hmm

Last edited by BirdByte (2012-09-16 08:46:58)


http://i50.tinypic.com/312u714.jpg

Offline

 

#74 2012-09-02 09:17:12

OverPowered
Scratcher
Registered: 2012-07-27
Posts: 100+

Re: 2-D Arrays

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.  smile


Newest project: Tunnel TEST ~http://blocks.scratchr.org/API.php?user=OverPowered&amp;action=onlineStatus~ On my mind: Unicameralism

Offline

 

#75 2012-09-02 09:45:53

Molybdenum
Scratcher
Registered: 2012-06-17
Posts: 1000+

Re: 2-D Arrays

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.  smile

You could just use a list, like me and birdbyte do. One place for each element. This generalizes to higher dimensions too!


"The Enrichment Center is required to remind you that you will be baked, and then there will be cake."
(|Balls and Platforms: Stay on!|) (|NaOS-H: An operating system... Or is it?|)

Offline

 

Board footer