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

#1 2012-01-28 11:54:26

treebark1313
Scratcher
Registered: 2011-05-23
Posts: 90

Advanced AI help

Hey. I was wondering if it would be possible to make an AI(Like in a pokemon game or something) that could learn the "Highest possible hit" and "lowest possible hit" then calculate the "average hit" and use that to select moves (Along with type and moveset)

Last edited by treebark1313 (2012-01-28 11:59:15)


When life gives you 100 reasons to frown,
show life you have 1000 reasons to smile. - Unknown

Offline

 

#2 2012-01-28 11:59:42

hello12345678910
Scratcher
Registered: 2009-07-11
Posts: 100+

Re: Advanced AI help

It's possible, but you have to use a lot of if blocks like:

When clicked
Forever
If
attack power
-
def power
enemy Attack power 1
>
Say
repeat this like 4 times for each attack
Say
and find which one does the most damage

Last edited by hello12345678910 (2012-01-28 12:03:26)


http://tinyurl.com/8yt32o9 http://tinyurl.com/6tgwp5r || Fish = F+I+S+H = 6+9+19+8 = 42<<The answer to Life, the Universe and Everything

Offline

 

#3 2012-01-28 12:03:18

treebark1313
Scratcher
Registered: 2011-05-23
Posts: 90

Re: Advanced AI help

hello12345678910 wrote:

It's possible, but you have to use a lot of if blocks like:

When clicked
Forever
If
attack power
-
def power
enemy Attack power 1
>
Say
repeat this like 4 times for each attack
Say
and find which one does the most damage
EndIf

I'm not sure you understand my question. I need it to find the AVERAGE, HIGHEST, and LOWEST attack, not just find out if the 'foe' is stronger than itself.


When life gives you 100 reasons to frown,
show life you have 1000 reasons to smile. - Unknown

Offline

 

#4 2012-01-28 12:11:24

hello12345678910
Scratcher
Registered: 2009-07-11
Posts: 100+

Re: Advanced AI help

treebark1313 wrote:

hello12345678910 wrote:

It's possible, but you have to use a lot of if blocks like:

When clicked
Forever
If
attack power
-
def power
enemy Attack power 1
>
Say
repeat this like 4 times for each attack
Say
and find which one does the most damage
EndIf

I'm not sure you understand my question. I need it to find the AVERAGE, HIGHEST, and LOWEST attack, not just find out if the 'foe' is stronger than itself.

Oh well if you need to do that then do something like this:

When gf clicked
Set (count) to (0)
Set (attackname) to ( )
//I'm assuming you have four attacks
If (attack1) > (count)
Set (count) to (attack1)
Set (attackname) to [attack1]
Endif
//repeat four times

This finds he highest attack. to find the lowest attack, set count to 1000000 and change the if operator to a <
I'm not sure how to find the middle attack. if you have three, you can just use the one that wasn't picked


http://tinyurl.com/8yt32o9 http://tinyurl.com/6tgwp5r || Fish = F+I+S+H = 6+9+19+8 = 42<<The answer to Life, the Universe and Everything

Offline

 

#5 2012-01-28 12:29:02

treebark1313
Scratcher
Registered: 2011-05-23
Posts: 90

Re: Advanced AI help

hello12345678910 wrote:

treebark1313 wrote:

hello12345678910 wrote:

It's possible, but you have to use a lot of if blocks like:

When clicked
Forever
If
attack power
-
def power
enemy Attack power 1
>
Say
repeat this like 4 times for each attack
Say
and find which one does the most damage
EndIf

I'm not sure you understand my question. I need it to find the AVERAGE, HIGHEST, and LOWEST attack, not just find out if the 'foe' is stronger than itself.

Oh well if you need to do that then do something like this:

When gf clicked
Set (count) to (0)
Set (attackname) to ( )
//I'm assuming you have four attacks
If (attack1) > (count)
Set (count) to (attack1)
Set (attackname) to [attack1]
Endif
//repeat four times

This finds he highest attack. to find the lowest attack, set count to 1000000 and change the if operator to a <
I'm not sure how to find the middle attack. if you have three, you can just use the one that wasn't picked

Nvm... i was talking about MATH, like actually calculating it.


When life gives you 100 reasons to frown,
show life you have 1000 reasons to smile. - Unknown

Offline

 

#6 2012-01-28 12:30:38

hello12345678910
Scratcher
Registered: 2009-07-11
Posts: 100+

Re: Advanced AI help

Check around AT or Questions about Scratch


http://tinyurl.com/8yt32o9 http://tinyurl.com/6tgwp5r || Fish = F+I+S+H = 6+9+19+8 = 42<<The answer to Life, the Universe and Everything

Offline

 

#7 2012-01-28 12:37:21

treebark1313
Scratcher
Registered: 2011-05-23
Posts: 90

Re: Advanced AI help

-__- Nvm.


When life gives you 100 reasons to frown,
show life you have 1000 reasons to smile. - Unknown

Offline

 

#8 2012-01-28 12:44:45

Magnie
Scratcher
Registered: 2007-12-12
Posts: 1000+

Re: Advanced AI help

Maybe

when clicked
set
highest
to
10
set
lowest
to
1
set
average
to
highest
+
lowest
/
2
set
switch
to
0
repeat
average
if
switch
=
0
broadcast
highest attack
else
broadcast
lowest attack
set
switch
to
1
-
switch

That would switch between each attack evenly I guess.

Offline

 

#9 2012-01-28 12:56:43

treebark1313
Scratcher
Registered: 2011-05-23
Posts: 90

Re: Advanced AI help

Magnie wrote:

Maybe

when clicked
set
highest
to
10
set
lowest
to
1
set
average
to
highest
+
lowest
/
2
set
switch
to
0
repeat
average
if
switch
=
0
broadcast
highest attack
else
broadcast
lowest attack
set
switch
to
1
-
switch

That would switch between each attack evenly I guess.

I mean it could calculate the lowest and highest from the damage it took, like if it took 20 damage, it would set 20 as the highest damage until it was hit with something higher, and visa versa.


When life gives you 100 reasons to frown,
show life you have 1000 reasons to smile. - Unknown

Offline

 

#10 2012-01-30 14:13:11

trinary
Scratcher
Registered: 2012-01-29
Posts: 1000+

Re: Advanced AI help

when clicked
set
health
to
100
set
damage
to
1
set
attackssofar
to
0
set
mostdamagingsofar
to
0001
or another arbitrarily low number, the 1 indicates the move
set
leastdamagingsofar
to
5002
or another arbitrarily high number, the 2 indicates the move
repeat until
health
=
0
AI loses
if
health
=
100
if this is the first move
set
move
to
pick random
1
to
10
else
if game has begun
set
move
to
letter
4
of
least damaging so far
the best move
AI moves
inflicts damage on person + depletes player's health
player moves
the person moves and inflicts damage on AI + depletes AI's health
if
damage
<
leastdamagingsofar
set
leastdamagingsofar
to
join
damage
move
if
damage
>
mostdamagingsofar
set
mostdamagingsofar
to
join
damage
move
set
total
to
join
total
damage
change
attackssofar
by
1
set
averagedamage
to
total
/
attackssofar
the average

Hope this is helpful!  smile


http://trinary.tk/images/signature_.php

Offline

 

#11 2012-02-01 17:01:07

coolhogs
Scratcher
Registered: 2011-07-26
Posts: 1000+

Re: Advanced AI help

What do you mean by the "AI moves block and the "Player moves block?


Get ready for domination of:  tongue

Offline

 

#12 2012-02-01 17:03:39

Legolas_Greenleaf
Scratcher
Registered: 2011-06-16
Posts: 86

Re: Advanced AI help

The AI performs a move, and likewise for the player.


http://25.media.tumblr.com/tumblr_m8s5zeoqje1qky8rdo1_250.gif  OPPAN GANGNAM STYLE~

Offline

 

#13 2012-02-01 21:45:32

trinary
Scratcher
Registered: 2012-01-29
Posts: 1000+

Re: Advanced AI help

trinary wrote:

when clicked
set
health
to
100
set
damage
to
1
set
attackssofar
to
0
set
mostdamagingsofar
to
0001
or another arbitrarily low number, the 1 indicates the move
set
leastdamagingsofar
to
5002
or another arbitrarily high number, the 2 indicates the move
repeat until
health
=
0
AI loses
if
health
=
100
if this is the first move
set
move
to
pick random
1
to
10
else
if game has begun
set
move
to
letter
4
of
least damaging so far
the best move
AI moves
inflicts damage on person + depletes player's health
player moves
the person moves and inflicts damage on AI + depletes AI's health
if
damage
<
leastdamagingsofar
set
leastdamagingsofar
to
join
damage
move
if
damage
>
mostdamagingsofar
set
mostdamagingsofar
to
join
damage
move
set
total
to
join
total
damage
change
attackssofar
by
1
set
averagedamage
to
total
/
attackssofar
the average

Hope this is helpful!  smile

Sorry, I forgot to  mention:

when clicked
set
health
to
100
set
damage
to
1
set
attackssofar
to
0
set
mostdamagingsofar
to
0001
or another arbitrarily low number, the 1 indicates the move
set
leastdamagingsofar
to
5002
or another arbitrarily high number, the 2 indicates the move
repeat until
health
=
0
AI loses
if
pick random
1
to
5
=
1
set
move
to
pick random
1
to
10
sometimes, the AI may try a different move
if
move
=
letter
4
of
mostdamagingsofar
but if it is too damaging
set
move
to
letter
4
of
leastdamagingsofar
else
normally the AI sticks with the best move
if
health
=
100
if this is the first move
set
move
to
pick random
1
to
10
else
set
move
to
letter
4
of
leastdamagingsofar
the best move
AI moves with the above move
inflicts damage on person + depletes player's health
player moves
the person moves and inflicts damage on AI + depletes AI's health
if
damage
<
leastdamagingsofar
set
leastdamagingsofar
to
join
damage
move
if
damage
>
mostdamagingsofar
set
mostdamagingsofar
to
join
damage
move
set
total
to
join
total
damage
change
attackssofar
by
1
set
averagedamage
to
total
/
attackssofar
the average


http://trinary.tk/images/signature_.php

Offline

 

#14 2012-06-23 04:58:47

Wes64
Scratcher
Registered: 2011-08-19
Posts: 1000+

Re: Advanced AI help

Click my signature to go to my RPG, and download it. You might be able to learn something.


Experienced 2.0 Tester: Ask me questions!
Using Firefox 13.0, Flash plugin version 11.4.402.287, and Windows XP Professional.

Offline

 

Board footer