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)
Offline
It's possible, but you have to use a lot of if blocks like:
When gf 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] end End
Last edited by hello12345678910 (2012-01-28 12:03:26)
Offline
hello12345678910 wrote:
It's possible, but you have to use a lot of if blocks like:
When gf 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 End
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.
Offline
treebark1313 wrote:
hello12345678910 wrote:
It's possible, but you have to use a lot of if blocks like:
When gf 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 EndI'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
Offline
hello12345678910 wrote:
treebark1313 wrote:
hello12345678910 wrote:
It's possible, but you have to use a lot of if blocks like:
When gf 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 EndI'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.
Offline
Check around AT or Questions about Scratch
Offline
-__- Nvm.
Offline
Maybe
when gf 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 v] else broadcast [lowest attack v] end set [switch] to <(1) - (switch)> endThat would switch between each attack evenly I guess.
Offline
Magnie wrote:
Maybe
when gf 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 v] else broadcast [lowest attack v] end set [switch] to <(1) - (switch)> endThat 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.
Offline
when gf clicked set [health v] to (100) set [damage v] to (1) set [attackssofar] to(0) set [mostdamagingsofar v] to (0001) //or another arbitrarily low number, the 1 indicates the move set [leastdamagingsofar v] 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 v] to (pick random (1) to (10)) else //if game has begun set [move v] to <letter (4) of (least damaging so far)> //the best move end 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 v] to (join (damage)(move)) end if <(damage) > (mostdamagingsofar)> set [mostdamagingsofar v] to (join (damage)(move)) end set [total v]to <join (total)(damage)> change [attackssofar v] by (1) set [averagedamage v] to <(total)/(attackssofar)> //the average endHope this is helpful!
Offline
The AI performs a move, and likewise for the player.
Offline
trinary wrote:
when gf clicked set [health v] to (100) set [damage v] to (1) set [attackssofar v] to(0) set [mostdamagingsofar v] to (0001) //or another arbitrarily low number, the 1 indicates the move set [leastdamagingsofar v] 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 v] to (pick random (1) to (10)) else //if game has begun set [move v] to <letter (4) of (least damaging so far)> //the best move end 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 v] to (join (damage)(move)) end if <(damage) > (mostdamagingsofar)> set [mostdamagingsofar v] to (join (damage)(move)) end set [total v]to <join (total)(damage)> change [attackssofar v] by (1) set [averagedamage v] to <(total)/(attackssofar)> //the average endHope this is helpful!
Sorry, I forgot to mention:
when gf clicked set [health v] to (100) set [damage v] to (1) set [attackssofar v] to(0) set [mostdamagingsofar v] to (0001) //or another arbitrarily low number, the 1 indicates the move set [leastdamagingsofar v] 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 v] 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 v] to (letter (4) of (leastdamagingsofar)) end else //normally the AI sticks with the best move if<(health) = (100)> //if this is the first move set [move v] to (pick random (1) to (10)) else set [move v] to <letter (4) of (leastdamagingsofar)> //the best move end end 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 v] to (join (damage)(move)) end if <(damage) > (mostdamagingsofar)> set [mostdamagingsofar v] to (join (damage)(move)) end set [total v]to <join (total)(damage)> change [attackssofar v] by (1) set [averagedamage v] to <(total)/(attackssofar)> //the average end
Offline