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

#1 2012-03-18 11:40:58

youtube_com
New Scratcher
Registered: 2012-03-17
Posts: 4

nim game

i am making a nim game and have got it to work to some point by then i want to make the who gets to go first to select the stones random, that is either the player goes first or the computer goes first. Can anyone help me with a script which can do that

Offline

 

#2 2012-03-18 12:02:49

MrScoop
Scratcher
Registered: 2010-12-17
Posts: 100+

Re: nim game

I think I know what you mean, but I'm not too sure I can describe it with the scratch scripts, so I'll do it in text.

Create a variable, name it whatever you want.

When green flag clicked
Set [variable name] to (pick random (1) to (2))
If
[variable name] = (1)
broadcast (computer goes first)
else
broadcast (player goes first)

Does that help?

Offline

 

#3 2012-03-18 20:21:35

turkey3
Scratcher
Registered: 2011-12-04
Posts: 500+

Re: nim game

MrScoop wrote:

I think I know what you mean, but I'm not too sure I can describe it with the scratch scripts, so I'll do it in text.

Create a variable, name it whatever you want.

When green flag clicked
Set [variable name] to (pick random (1) to (2))
If <[variable name] = (1)>
broadcast (computer goes first)
else
broadcast (player goes first)
Does that help?

Fixed it.

Last edited by turkey3 (2012-03-18 20:22:44)

Offline

 

Board footer