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

#1 2012-04-04 16:53:42

skippito
Scratcher
Registered: 2012-03-17
Posts: 100+

Artificial Intelligence and Saving

I have created a two-player game, but wish to add an intelligent opponent that is not a friend. Does anyone know how to do this? I also wish to make it so that you can save a game, then return to it. Is there a way to do this? If you need to see the program to do this, this is the link: http://scratch.mit.edu/projects/skippito/2404160

Offline

 

#2 2012-04-04 17:30:10

ftf841
Scratcher
Registered: 2012-02-19
Posts: 1000+

Re: Artificial Intelligence and Saving

create a public varible called player x position then add this to the person

when gf clicked
forever
set [player x position v] to (x position)
then for the basketball
forever
if <(x position) = (player x position)>
change y by [-something]
end
here is some thing that might help with saving a game.
http://wiki.scratch.mit.edu/wiki/Saving_Data

Last edited by ftf841 (2012-04-04 17:36:02)


http://mag.racked.eu/cimage/i9002/Achievement++get%21/Hi+there./mca.png
http://mag.racked.eu/mcimage/i354/Achievement++get%21/CAKE%21%21%21%21%21/mca.png

Offline

 

#3 2012-04-05 16:10:08

skippito
Scratcher
Registered: 2012-03-17
Posts: 100+

Re: Artificial Intelligence and Saving

Thanks. I had to change your script a bit because Adobe Flash was not fast enough to run it, but this was only developing a range. Other than that, your script is very useful.

Offline

 

#4 2012-04-06 20:12:25

silvershine
Scratcher
Registered: 2010-11-21
Posts: 500+

Re: Artificial Intelligence and Saving

Hello!

If you want the project to save your progress, there is a relatively simple way to do this. (this will only work offline unfortunately.)

I'm on my iPod at the moment so I can't see your project, but I'll give you a pretty general explanation:

Let's say for example that you want the game to save what level you're on. Create a level variable (I'm assuming you already have something like this). Normally, when the player clicks the green flag, all the variables will be reset.

when flag clicked
Set [level v] to [1]
If you wanted the level you are at to save, simply don't add this script. When the player plays the game and advances to new levels, the variable will change. As long as the player saves the project, if the level variable is never reset, the level will be the same the next time the user opens the project.

This same process can be applied to all variables and lists, so be creative! You could save the life that each player has, or even save things like the players preferences and items etc. that they collected in the game.

Hope that was helpful! Good luck in your game!

Offline

 

#5 2012-04-06 20:33:54

AtomicBawm3
Scratcher
Registered: 2009-06-27
Posts: 1000+

Re: Artificial Intelligence and Saving

ftf841 wrote:

create a public varible called player x position then add this to the person

when gf clicked
forever
set [player x position v] to (x position)
then for the basketball
forever
if <(x position) = (player x position)>
change y by [-something]
end
here is some thing that might help with saving a game.
http://wiki.scratch.mit.edu/wiki/Saving_Data

or he could just use the

 ([x position v] of [player v]) 
block.


http://i50.tinypic.com/j0yw0p.jpg

Offline

 

#6 2012-04-08 08:04:53

skippito
Scratcher
Registered: 2012-03-17
Posts: 100+

Re: Artificial Intelligence and Saving

AtomicBawm3 wrote:

ftf841 wrote:

create a public varible called player x position then add this to the person

when gf clicked
forever
set [player x position v] to (x position)
then for the basketball
forever
if <(x position) = (player x position)>
change y by [-something]
end
here is some thing that might help with saving a game.
http://wiki.scratch.mit.edu/wiki/Saving_Data

or he could just use the

 ([x position v] of [player v]) 
block.

That is what I did. It makes it so the game responds more quickly. The real problem was how fast Adobe Flash can refresh.

Offline

 

#7 2012-04-08 11:46:32

slayerrobe7
Scratcher
Registered: 2011-06-24
Posts: 500+

Re: Artificial Intelligence and Saving

if you want to save and you have panther you could use files and then have it read the file to know you progress (only works offline)


!!!When it comes to Scratch2.0 I am totally like freaking out!!!

Offline

 

Board footer