Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » Big Question: Artificial Intelligences?!?!?!
- Acerman
- Scratcher
3 posts
Big Question: Artificial Intelligences?!?!?!
It is * Hard. A project of mine being made needs AIs, apart from my little RPG. ‘Tis a fairly superfluously ridiculously complex one I’m looking to invest in… for Scratch. I wouldn't say I've gotten particularly far. Any help?
- RUBIXS
- New to Scratch
60 posts
Big Question: Artificial Intelligences?!?!?!
What kind of Al are you talking about? Do you mean like a conversation al or one that is like a pet thing that follows you around?
- mwiedmann
- Scratcher
100+ posts
Big Question: Artificial Intelligences?!?!?!
An easy one to to is to just have your AI sprites wander randomly and then move towards the good guy if he gets within a certain range. Something like this:
1st create a “for this sprite only” variable “moveTimer”
When created as a clone
Set moveTimer = timer
Point in direction (random 0 to 360)
Repeat until I_am_dead – You need some test here to see if the sprite is dead
move 5 – whatever speed you want your sprite to move
If moveTimer + 4 < timer – the 4 here means it will change direction every 4 seconds. Set to what you want
Point in direction (random 0 to 360) – Change directions. You could also “turn random -30 to 30” for smaller direction changes.
Set moveTimer = timer – resets the timer
End If
If distance to “main guy” < 100 – If close to the guy just follow him
point towards “main guy”
End If
End Repeat
Delete this clone
1st create a “for this sprite only” variable “moveTimer”
When created as a clone
Set moveTimer = timer
Point in direction (random 0 to 360)
Repeat until I_am_dead – You need some test here to see if the sprite is dead
move 5 – whatever speed you want your sprite to move
If moveTimer + 4 < timer – the 4 here means it will change direction every 4 seconds. Set to what you want
Point in direction (random 0 to 360) – Change directions. You could also “turn random -30 to 30” for smaller direction changes.
Set moveTimer = timer – resets the timer
End If
If distance to “main guy” < 100 – If close to the guy just follow him
point towards “main guy”
End If
End Repeat
Delete this clone
- MingleYT
- Scratcher
14 posts
Big Question: Artificial Intelligences?!?!?!
don't necropost bro lol
sorry!!! didnt mean to necropost, made a mistake and don't know how to delete
Last edited by MingleYT (Aug. 5, 2023 03:31:55)
An evil kumquat ate my signature, sadly.
- Discussion Forums
- » Help with Scripts
- » Big Question: Artificial Intelligences?!?!?!