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

#1 2012-05-13 11:13:34

EzekielE
Scratcher
Registered: 2010-09-26
Posts: 100+

Lists Question And Optimizing Speed

So I have a scratch project here

When it rewrites a block after it generates the terrain (clicking), it scans the X list for matching locations, then checks if that same Y item is correct, if it is not it goes to the next item.

Any way to optimize this?


http://mag.racked.eu/cimage/i2260/Achievement++get%21/Find+a+Disk/mca.pnghttp://ezekielelin.com/1x1Gif/image.php

Offline

 

#2 2012-05-13 11:16:45

stevetheipad
Scratcher
Registered: 2011-08-06
Posts: 1000+

Re: Lists Question And Optimizing Speed

Hmmm...I'm not exactly sure how to make the script run faster. However, you could put a sprite up at the beginning telling people to put their flash player in turbo mode, and then they could turn it off when not needed.


http://i.imgur.com/0x8ia.jpg
gone

Offline

 

#3 2012-05-13 12:52:13

EzekielE
Scratcher
Registered: 2010-09-26
Posts: 100+

Re: Lists Question And Optimizing Speed

stevetheipad wrote:

Hmmm...I'm not exactly sure how to make the script run faster. However, you could put a sprite up at the beginning telling people to put their flash player in turbo mode, and then they could turn it off when not needed.

Thats what I am doing now, and it works well, but a way to figure out where to change the data without searching is what I need.


http://mag.racked.eu/cimage/i2260/Achievement++get%21/Find+a+Disk/mca.pnghttp://ezekielelin.com/1x1Gif/image.php

Offline

 

#4 2012-05-13 12:54:17

RedRocker227
Scratcher
Registered: 2011-10-26
Posts: 1000+

Re: Lists Question And Optimizing Speed

stevetheipad wrote:

Hmmm...I'm not exactly sure how to make the script run faster. However, you could put a sprite up at the beginning telling people to put their flash player in turbo mode, and then they could turn it off when not needed.

Putting it in Turbo generally makes it run too fast.


Why

Offline

 

#5 2012-05-13 13:05:06

stevetheipad
Scratcher
Registered: 2011-08-06
Posts: 1000+

Re: Lists Question And Optimizing Speed

RedRocker227 wrote:

stevetheipad wrote:

Hmmm...I'm not exactly sure how to make the script run faster. However, you could put a sprite up at the beginning telling people to put their flash player in turbo mode, and then they could turn it off when not needed.

Putting it in Turbo generally makes it run too fast.

Then make the project run slower, so it's not "too fast" when in turbo mode.  wink


http://i.imgur.com/0x8ia.jpg
gone

Offline

 

#6 2012-05-13 13:16:36

RedRocker227
Scratcher
Registered: 2011-10-26
Posts: 1000+

Re: Lists Question And Optimizing Speed

stevetheipad wrote:

RedRocker227 wrote:

stevetheipad wrote:

Hmmm...I'm not exactly sure how to make the script run faster. However, you could put a sprite up at the beginning telling people to put their flash player in turbo mode, and then they could turn it off when not needed.

Putting it in Turbo generally makes it run too fast.

Then make the project run slower, so it's not "too fast" when in turbo mode.  wink

The only way to do that would be to have loads of "wait" blocks, and that makes it run too slow.


Why

Offline

 

#7 2012-05-13 13:40:02

stevetheipad
Scratcher
Registered: 2011-08-06
Posts: 1000+

Re: Lists Question And Optimizing Speed

RedRocker227 wrote:

stevetheipad wrote:

RedRocker227 wrote:


Putting it in Turbo generally makes it run too fast.

Then make the project run slower, so it's not "too fast" when in turbo mode.  wink

The only way to do that would be to have loads of "wait" blocks, and that makes it run too slow.

No, that's not correct. It's not about making it wait longer, it's about making it do a lot of work to the point where the speed has to slow down to complete all the tasks.


http://i.imgur.com/0x8ia.jpg
gone

Offline

 

#8 2012-05-13 13:56:58

RedRocker227
Scratcher
Registered: 2011-10-26
Posts: 1000+

Re: Lists Question And Optimizing Speed

stevetheipad wrote:

RedRocker227 wrote:

stevetheipad wrote:


Then make the project run slower, so it's not "too fast" when in turbo mode.  wink

The only way to do that would be to have loads of "wait" blocks, and that makes it run too slow.

No, that's not correct. It's not about making it wait longer, it's about making it do a lot of work to the point where the speed has to slow down to complete all the tasks.

To make it slow down to the correct speed using that method, the script would exceed the maximum script length.


Why

Offline

 

#9 2012-05-13 14:45:41

EzekielE
Scratcher
Registered: 2010-09-26
Posts: 100+

Re: Lists Question And Optimizing Speed

Ok Guys, Turbo works well, but say we have this

LISTS

XPOS

10
15
20

YPOS

-5
-10
-15

NAME

WOOD
GRASS
DIRT

And I want to find the index where X=10 and Y=-10, so I can find the NAME for that location right? One thing to note about the project is the indexes never move, therefor the upperleft hand block is always #1 on all three lists, the only value that changes is the NAME


http://mag.racked.eu/cimage/i2260/Achievement++get%21/Find+a+Disk/mca.pnghttp://ezekielelin.com/1x1Gif/image.php

Offline

 

#10 2012-05-13 15:14:25

ManaUser
Scratcher
Registered: 2009-03-11
Posts: 100+

Re: Lists Question And Optimizing Speed

In general, I'd think your best bet is use a fixed location in the list for each terrain block position. For example if your world were 10x10, you would always have a list of 100 blocks, even if some are empty. Then if you wanted say the block at 7,3 it would be item 73 on the list. That way you don't in a separate list for positions. It's going to take a little more work to convert from Scratch's XY coordinates, but that's the basic idea.


http://i.imgur.com/SPYSM.gif http://i.imgur.com/t9k1Z.gif http://i.imgur.com/OwYVa.gif http://i.imgur.com/0qlZq.gif

Offline

 

#11 2012-05-13 15:56:58

EzekielE
Scratcher
Registered: 2010-09-26
Posts: 100+

Re: Lists Question And Optimizing Speed

ManaUser wrote:

In general, I'd think your best bet is use a fixed location in the list for each terrain block position. For example if your world were 10x10, you would always have a list of 100 blocks, even if some are empty. Then if you wanted say the block at 7,3 it would be item 73 on the list. That way you don't in a separate list for positions. It's going to take a little more work to convert from Scratch's XY coordinates, but that's the basic idea.

Thats what I was thinking......

does anyone have any easy ways to do this or do I have to take the time to do this? Its about 700 positions


http://mag.racked.eu/cimage/i2260/Achievement++get%21/Find+a+Disk/mca.pnghttp://ezekielelin.com/1x1Gif/image.php

Offline

 

#12 2012-05-13 16:30:08

stevetheipad
Scratcher
Registered: 2011-08-06
Posts: 1000+

Re: Lists Question And Optimizing Speed

RedRocker227 wrote:

stevetheipad wrote:

RedRocker227 wrote:

The only way to do that would be to have loads of "wait" blocks, and that makes it run too slow.

No, that's not correct. It's not about making it wait longer, it's about making it do a lot of work to the point where the speed has to slow down to complete all the tasks.

To make it slow down to the correct speed using that method, the script would exceed the maximum script length.

No, actually, there are ways to slow down the process without going over-board.  wink


http://i.imgur.com/0x8ia.jpg
gone

Offline

 

Board footer