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

#1 2012-03-09 12:26:41

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

Making the chances of an event happening increase over time

Wow it's so embarrassing that I need help with something as simple as this ._.

I wanna have it so that to start with, obstacles don't appear very frequently, but after a while they increase in frequency. I know how to do it with loads of "if" blocks, but I want it just one block. For example, to make the chance decrease, it's;

wait (round ((timer)/[5])) secs
How would I go about making the opposite of this without using multiple "if" blocks?

(I'm gonna kick myself when I find out just how simple it really is).

EDIT: I think I have it. I'll just test it and if it's right I'll ask for this to be closed.

EDIT2: Okay the good thing: my method worked. The bad thing: how the heck did I not think of this?! xD Thanks Paddle ^^
Well that was embarrassing.

Last edited by RedRocker227 (2012-03-09 18:25:35)


Why

Offline

 

#2 2012-03-09 12:32:27

schusteralex2
Scratcher
Registered: 2011-09-17
Posts: 1000+

Re: Making the chances of an event happening increase over time

The loads of if blocks might be the only way  hmm


http://i44.tinypic.com/2uj37ds.gif

Offline

 

#3 2012-03-09 12:38:07

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

Re: Making the chances of an event happening increase over time

schusteralex2 wrote:

The loads of if blocks might be the only way  hmm

Oh ;-;


Why

Offline

 

#4 2012-03-09 13:55:00

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

Re: Making the chances of an event happening increase over time

when gf clicked
set [chance v] to (100) //insert any value
repeat until <(chance) = (10)>
 change [chance v] by (-1)
 wait (pick a random (0.75) to (2)) secs
end

when gf clicked
forever if <(pick a random (1) to (chance)) = (1)>
  do stuff

why doesn't the pick a random block work of the forums?????

Last edited by joefarebrother (2012-03-09 13:57:55)


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

 

#5 2012-03-09 16:26:06

PullJosh
Scratcher
Registered: 2011-08-01
Posts: 500+

Re: Making the chances of an event happening increase over time

What about this?

when gf clicked
set [a v] to (5) // This changes the amount of time it starts with for the waiting.
forever
wait ((round(a)) - ((round(timer)) / (5))) secs
do stuff...
change [a v] by (0.4) // This changes how much the amount of time changes.
end
It works! I tested it. At some point, it will stop getting to be a smaller amount of time, although by that time you'll probably have a game over.

Last edited by PullJosh (2012-03-09 16:46:47)


http://www.blocks.scratchr.org/API.php?action=text&amp;string=I'm_on_vacation!&amp;xpos=155&amp;ypos=90&amp;font_size=30&amp;bgimage=http://imageshack.us/a/img339/7215/sspeechsigapiforwords.png

Offline

 

#6 2012-03-09 18:08:52

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

Re: Making the chances of an event happening increase over time

You could just make the wait time proportional to the reciprocal of the timer....

wait ((50) / (timer)) secs


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

Offline

 

#7 2012-03-09 18:14:37

PullJosh
Scratcher
Registered: 2011-08-01
Posts: 500+

Re: Making the chances of an event happening increase over time

Paddle2See wrote:

You could just make the wait time proportional to the reciprocal of the timer....

wait ((50) / (timer)) secs

But that's no fun. It won't make you look smart.  tongue


http://www.blocks.scratchr.org/API.php?action=text&amp;string=I'm_on_vacation!&amp;xpos=155&amp;ypos=90&amp;font_size=30&amp;bgimage=http://imageshack.us/a/img339/7215/sspeechsigapiforwords.png

Offline

 

#8 2012-03-09 18:23:30

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

Re: Making the chances of an event happening increase over time

Paddle2See wrote:

You could just make the wait time proportional to the reciprocal of the timer....

wait ((50) / (timer)) secs

Wow. I knew it was gonna be really simple, but I didn't realise it was THAT simple xD I feel like an idiot now  tongue

Close this pwease ^.^


Why

Offline

 

#9 2012-03-09 19:56:38

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

Re: Making the chances of an event happening increase over time

Closed by request of the topic owner.


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

Offline

 

Board footer