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:
Whenclicked
ForeverIfattack power-def powerenemy Attack power 1>Sayrepeat this like 4 times for each attackSayand find which one does the most damage
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:
Whenclicked
ForeverIfattack power-def powerenemy Attack power 1>Sayrepeat this like 4 times for each attackSayand find which one does the most damageEndIf
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:
Whenclicked
ForeverIfattack power-def powerenemy Attack power 1>Sayrepeat this like 4 times for each attackSayand find which one does the most damageEndIfI'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:
Whenclicked
ForeverIfattack power-def powerenemy Attack power 1>Sayrepeat this like 4 times for each attackSayand find which one does the most damageEndIfI'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
That would switch between each attack evenly I guess.whenclicked
sethighestto10setlowestto1setaverageto/highest+lowest2setswitchto0repeataverageifswitch=0broadcasthighest attack ▼elsebroadcastlowest attack ▼setswitchto1-switch
Offline
Magnie wrote:
Maybe
That would switch between each attack evenly I guess.whenclicked
sethighestto10setlowestto1setaverageto/highest+lowest2setswitchto0repeataverageifswitch=0broadcasthighest attack ▼elsebroadcastlowest attack ▼setswitchto1-switch
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
Hope this is helpful!whenclicked
sethealth ▼to100setdamage ▼to1setattackssofarto0setmostdamagingsofar ▼to0001or another arbitrarily low number, the 1 indicates the movesetleastdamagingsofar ▼to5002or another arbitrarily high number, the 2 indicates the moverepeat untilhealth=0AI losesifhealth=100if this is the first movesetmove ▼topick random1to10elseif game has begunsetmove ▼toletter4ofleast damaging so farthe best moveAI movesinflicts damage on person + depletes player's healthplayer movesthe person moves and inflicts damage on AI + depletes AI's healthifdamage<leastdamagingsofarsetleastdamagingsofar ▼tojoindamagemoveifdamage>mostdamagingsofarsetmostdamagingsofar ▼tojoindamagemovesettotal ▼tojointotaldamagechangeattackssofar ▼by1setaveragedamage ▼tototal/attackssofarthe average
Offline
The AI performs a move, and likewise for the player.
Offline
trinary wrote:
Hope this is helpful!whenclicked
sethealth ▼to100setdamage ▼to1setattackssofar ▼to0setmostdamagingsofar ▼to0001or another arbitrarily low number, the 1 indicates the movesetleastdamagingsofar ▼to5002or another arbitrarily high number, the 2 indicates the moverepeat untilhealth=0AI losesifhealth=100if this is the first movesetmove ▼topick random1to10elseif game has begunsetmove ▼toletter4ofleast damaging so farthe best moveAI movesinflicts damage on person + depletes player's healthplayer movesthe person moves and inflicts damage on AI + depletes AI's healthifdamage<leastdamagingsofarsetleastdamagingsofar ▼tojoindamagemoveifdamage>mostdamagingsofarsetmostdamagingsofar ▼tojoindamagemovesettotal ▼tojointotaldamagechangeattackssofar ▼by1setaveragedamage ▼tototal/attackssofarthe average![]()
Sorry, I forgot to mention:
whenclicked
sethealth ▼to100setdamage ▼to1setattackssofar ▼to0setmostdamagingsofar ▼to0001or another arbitrarily low number, the 1 indicates the movesetleastdamagingsofar ▼to5002or another arbitrarily high number, the 2 indicates the moverepeat untilhealth=0AI losesifpick random=1to51setmove ▼topick random1to10sometimes, the AI may try a different moveifmove=letter4ofmostdamagingsofarbut if it is too damagingsetmove ▼toletter4ofleastdamagingsofarelsenormally the AI sticks with the best moveifhealth=100if this is the first movesetmove ▼topick random1to10elsesetmove ▼toletter4ofleastdamagingsofarthe best moveAI moves with the above moveinflicts damage on person + depletes player's healthplayer movesthe person moves and inflicts damage on AI + depletes AI's healthifdamage<leastdamagingsofarsetleastdamagingsofar ▼tojoindamagemoveifdamage>mostdamagingsofarsetmostdamagingsofar ▼tojoindamagemovesettotal ▼tojointotaldamagechangeattackssofar ▼by1setaveragedamage ▼tototal/attackssofarthe average
Offline