Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » Trying to make a Game with Ai
- carlosxc
-
Scratcher
19 posts
Trying to make a Game with Ai
Just making a Copy of a GBA game And the game has AI I'm wondering if anyone has any advice on how to make an AI with different playstyles one is more aggressive and another wants to sit somewhere and shoot you without getting close. I wanted to know if this is even possible on Scratch. don't want code just want to know if it's possible. (I'm new to coding)
- n-clue
-
Scratcher
100+ posts
Trying to make a Game with Ai
technically anything thats possible in other games youve seen is possible in scratch because of turing completeness but practically some things are too slow to run properly on scratch, based on what youve said here it should be possible but it depends
- XCardx
-
Scratcher
30 posts
Trying to make a Game with Ai
It’s entirely possible, and there’s also a variety of methods that can be used to achieve that
- Tu2tl3Gamz
-
Scratcher
100+ posts
Trying to make a Game with Ai
Hello!
This if very much POSSIBLE!
Scratch uses block coding to teach the basics of coding, but it can still be used to make complex things! So new to coding or not, its possible to make AI in scratch!
To make clones of a sprite that act in diffrent ways (Example, hard AI and easy AI) youll need to give the AI diffrent values.
Ill give you an example of AI that you can make in scratch!
This if very much POSSIBLE!
Scratch uses block coding to teach the basics of coding, but it can still be used to make complex things! So new to coding or not, its possible to make AI in scratch!
To make clones of a sprite that act in diffrent ways (Example, hard AI and easy AI) youll need to give the AI diffrent values.
Ill give you an example of AI that you can make in scratch!
AI Shooter Example
In this example, ill have two AIs trying to shoot the player. one AI is smart (1) and the other is dumb (2)when green flag clicked
set [ AI] to [1]
create clone of [ myself]
set [AI] to [2]
create clone of [myself]
when I start as a clone
forever
if <(AI) = [1]> then
point towards [player]
if <(distance to [ player]) > [10]> then
move (pick random (5) to (10)) steps
else
if <(distance to [ player]) < [10]> then
move (pick random (-10) to (-5)) steps
end
end
broadcast [ shoot]
wait (pick random (2) to (4)) secs
else
if <(AI) = [2]> then
point towards [ player]
move (4) steps
broadcast [ shoot]
wait (pick random (2) to (4)) secs
end
end
end
- n-clue
-
Scratcher
100+ posts
Trying to make a Game with Ai
Hello!you missed that it was turn based so youd have to do it differently, id also like to point out the variable needs to be for this sprite only for it to have a different value between clones
This if very much POSSIBLE!
Scratch uses block coding to teach the basics of coding, but it can still be used to make complex things! So new to coding or not, its possible to make AI in scratch!
To make clones of a sprite that act in diffrent ways (Example, hard AI and easy AI) youll need to give the AI diffrent values.
Ill give you an example of AI that you can make in scratch!AI Shooter Example
In this example, ill have two AIs trying to shoot the player. one AI is smart (1) and the other is dumb (2)when green flag clicked
set [ AI] to [1]
create clone of [ myself]
set [AI] to [2]
create clone of [myself]
when I start as a clone
forever
if <(AI) = [1]> then
point towards [player]
if <(distance to [ player]) > [10]> then
move (pick random (5) to (10)) steps
else
if <(distance to [ player]) < [10]> then
move (pick random (-10) to (-5)) steps
end
end
broadcast [ shoot]
wait (pick random (2) to (4)) secs
else
if <(AI) = [2]> then
point towards [ player]
move (4) steps
broadcast [ shoot]
wait (pick random (2) to (4)) secs
end
end
end
- Tu2tl3Gamz
-
Scratcher
100+ posts
Trying to make a Game with Ai
Hello!you missed that it was turn based so youd have to do it differently, id also like to point out the variable needs to be for this sprite only for it to have a different value between clones
This if very much POSSIBLE!
Scratch uses block coding to teach the basics of coding, but it can still be used to make complex things! So new to coding or not, its possible to make AI in scratch!
To make clones of a sprite that act in diffrent ways (Example, hard AI and easy AI) youll need to give the AI diffrent values.
Ill give you an example of AI that you can make in scratch!AI Shooter Example
In this example, ill have two AIs trying to shoot the player. one AI is smart (1) and the other is dumb (2)when green flag clicked
set [ AI] to [1]
create clone of [ myself]
set [AI] to [2]
create clone of [myself]
when I start as a clone
forever
if <(AI) = [1]> then
point towards [player]
if <(distance to [ player]) > [10]> then
move (pick random (5) to (10)) steps
else
if <(distance to [ player]) < [10]> then
move (pick random (-10) to (-5)) steps
end
end
broadcast [ shoot]
wait (pick random (2) to (4)) secs
else
if <(AI) = [2]> then
point towards [ player]
move (4) steps
broadcast [ shoot]
wait (pick random (2) to (4)) secs
end
end
end
I know!
This is an example of AI. Its a starting point to make an AI for the turn-based game.
- Discussion Forums
- » Help with Scripts
-
» Trying to make a Game with Ai