*Author

Offline XenocidiusTopic starter

  • Legendary Member
  • ******
  • Posts: 2696
  • Reputation Power: 49
  • Xenocidius is towering like an Amethyst Dragon over their peers.Xenocidius is towering like an Amethyst Dragon over their peers.Xenocidius is towering like an Amethyst Dragon over their peers.Xenocidius is towering like an Amethyst Dragon over their peers.Xenocidius is towering like an Amethyst Dragon over their peers.Xenocidius is towering like an Amethyst Dragon over their peers.Xenocidius is towering like an Amethyst Dragon over their peers.Xenocidius is towering like an Amethyst Dragon over their peers.Xenocidius is towering like an Amethyst Dragon over their peers.
  • Fear the Darkness ...
  • Awards: Slice of Elements 3rd Birthday CakeFavorite Community Member of 2011Weekly Tournament WinnerWinner of Design a Competition Competition
Game Coding Q&A https://elementscommunity.org/forum/index.php?topic=32442.msg409939#msg409939
« on: October 14, 2011, 11:14:36 pm »
This is a thread where you can ask questions about how the game is coded.

For example, the AI formula for casting Miracle, targeting for spells like Immolation, whether damage from bolts is dealt as one or in groups of 2/3 damage, and even Oracle fortunes are some of the questions you could ask.

Now that I've written my Sandbox, please direct all your AI questions here.

In particular, there are some things I learned that may render some of my AI information given here false. If you go to the Function Autotarget part and down to "Now make some final adjustments", it explains why, for example, Electrum Hourglass and Eternity have such high targeting priorities, among other things.

So what are you waiting for? Ask a question and I'll answer you as best I can. Let the questions commence.



QUESTIONS ASKED

What are the exact odds of getting a nymph from the oracle?  (any nymph)

How much would it hinder the code or the speed of the AI if instead of the score / estimate system you introduced an array (or better yet a hash if that's possible in Flash) for every targeting effect?

How do bolt spells work? Multiple of 3 damage or just as a bulk?

Is there any possible way to damage your opponent after a SoG kicks in?

What is the process the game takes to calculate predicted HP loss? Does the AI react differently depending on how much damage it expects to take?

What's the AI's priority for discarding cards?

Are the order of the cards in the deck predetermined at the beginning of the match, or decided randomly based on which cards are left at the time it is drawn?

How does it send information when you play PvP? <- Still undergoing investigation

What is the "99" skill? <- Still undergoing investigation

What decides your oracle pet? Which ones are more likely to be your pet? What is the % that you get no pet?

What determines how much money you get from PVP?

How are cards picked for the bonus spin? Is it just like regular spins where it picks X amount of cards or is it from all the rares in-game except of cource nymphs/marks. Also from which pool are the cards picked  for the slot change (Where you can change a slot up to 3 times).

What is requiring Zanz to keep all monsters mono? (aka not allowing 2 :fire and 1 :aether) to play a monster? Last Zanz spoke about it, he said it was a technical limitation. It would be interesting to know what that limitation is.

Can a Skeleton be turned into a Fate Egg?

Are all creatures equally likely through Hatch? Are any excluded/rare/likely?

What is the order of the factors to make a mutation? (ex. Element, atk, hp, etc.)

how does the game RNG work? (i.e. : which is the algorhytm that lies behind the RNG)

Is the random pet selection mechanic the same as Fate Egg's?

Is SoSe using the Oracle card engine?

Does it make sense that Miracle never appears in SoSe/Oracle engines?

How is the value of each oracle card (in electrum) determined?

How are a card's stats, ability, and cost coded?

Can you have a variable casting cost in Elements?

Can it also have a variable ability cost?

How does the oracle decide which FG prediction you get?

Are the possibilities for Chaos Seed/Power, Fate Egg, Mutation, skeleton rewinding, Shard of Serendipity (and any random effects I may have forgotten) all equal?

What are the formulae for freezing on Ice/Permafrost Shield, for skeletonizing on Skull Buckler/Shield, and for freezing with Ice Bolt/Lance?

Is it possible to code AoE or Targeting spells that ignore Immaterial?

FGs use the same AI as everything else, right? I.E., custom AI6 is a valid method of testing FG counters?

How complicated is the card creation process? For example, if Zanz wanted to, could he easily flood the game with vanilla cards (ones with no effect) by simply filling in a few variables?

Is there a cap on bonewalls?

Can permanents have passives?

Does adrenaline have an exact formula, and if so what is it?



Spoiler for AI QUESTIONS:
How often does the AI decides "Hmmm....I'll burrow this creature?"

What's the targetting priority of fire/ice bolts and drain life? What about rage potions and reverse time?

AI questions: Miracle usage? Nightmare usage? Buff usage? Twin Universe usage?

What's the AI priority with permanents? (False - check sandbox)

Does the AI recognize if a weapon is frozen when considering using PC? Does the AI notice if its weapon is Frozen, Delayed or Protected when considering Flying weapon?

When does the AI play a dim shield?

If the AI has a weapon, and I have a weapon, and the AI has a crusader on the field ready to endow a weapon, whose does it endow? Which weapons have priority?

How does the AI use Catapults?

Why does the AI withhold playing something (referring to permanents here) even though playing it would save handroom (preventing discarding) and act as a contingency?

How Ai decides what creature to fractal?

When does the AI decide to hit you with a spell instead of your creature?

When I Nightmare a flying Dirk, why does the AI play every single Dirk it gets on the very next turn, replacing the previous Dirk each time (assuming it has no better weapon already there), but when I Nightmare a Ray of Light, the AI holds onto them for one turn before playing them all?

What are the mechanics behind the AI immolating things?

So the AI will always burrow if it has enough quanta? Or will make a call on whether to burrow or not if it has enough quanta?

Guess the AI did learn quite a bit eh? What about aether though? A lightning will kill off any burrow-critter in no time ...

Are there any other uses of the "suspicious" tag?

When will AI use SoPatience?

Does the AI know when to specifically 'burst play' creatures or does it just play them when it has the quanta for it?
Don't cry because it's over, smile because it happened.

Offline dragonsdemesne

  • Legendary Member
  • ******
  • Posts: 5283
  • Country: aq
  • Reputation Power: 63
  • dragonsdemesne shines with the light of the Morning Glory!dragonsdemesne shines with the light of the Morning Glory!dragonsdemesne shines with the light of the Morning Glory!dragonsdemesne shines with the light of the Morning Glory!dragonsdemesne shines with the light of the Morning Glory!dragonsdemesne shines with the light of the Morning Glory!dragonsdemesne shines with the light of the Morning Glory!dragonsdemesne shines with the light of the Morning Glory!dragonsdemesne shines with the light of the Morning Glory!dragonsdemesne shines with the light of the Morning Glory!dragonsdemesne shines with the light of the Morning Glory!dragonsdemesne shines with the light of the Morning Glory!
  • Leeeeeeeeeeroyyyyyyyyy....
  • Awards: Weekly Tournament WinnerWeekly Tournament WinnerWeekly Tournament WinnerWeekly Tournament WinnerWeekly Tournament WinnerWeekly Tournament WinnerWeekly Tournament WinnerBattle League 1/2014 2nd PlaceWeekly Tournament WinnerBattle League 3/2013 2nd PlaceWeekly Tournament WinnerWeekly Tournament WinnerWeekly Tournament WinnerBattle League 2/2013 WinnerBattle League 1/2013 2nd PlaceWeekly Tournament WinnerChampionship League 3/2012 2nd PlaceWeekly Tournament WinnerWeekly Tournament WinnerChampionship League 2/2012 3rd Place
Re: Game Coding Q&A https://elementscommunity.org/forum/index.php?topic=32442.msg409945#msg409945
« Reply #1 on: October 14, 2011, 11:19:18 pm »
What are the exact odds of getting a nymph from the oracle?  (any nymph)  Based on a thread I saw awhile back, but can no longer find, people were reporting a win rate just over 3%, or about 1:30 / 1 per month.

Can shards be spun at the oracle?  I've never spun one since I started playing, but I have seen most of the 'other' cards, actually I think all of the other ones, so I'm guessing not, but I'm just curious.


Offline furballdn

  • Legendary Member
  • ******
  • Posts: 7573
  • Reputation Power: 86
  • furballdn is a mythical and divine giver of immortality, one of the Turquoise Nymphs.furballdn is a mythical and divine giver of immortality, one of the Turquoise Nymphs.furballdn is a mythical and divine giver of immortality, one of the Turquoise Nymphs.furballdn is a mythical and divine giver of immortality, one of the Turquoise Nymphs.furballdn is a mythical and divine giver of immortality, one of the Turquoise Nymphs.furballdn is a mythical and divine giver of immortality, one of the Turquoise Nymphs.furballdn is a mythical and divine giver of immortality, one of the Turquoise Nymphs.furballdn is a mythical and divine giver of immortality, one of the Turquoise Nymphs.furballdn is a mythical and divine giver of immortality, one of the Turquoise Nymphs.furballdn is a mythical and divine giver of immortality, one of the Turquoise Nymphs.furballdn is a mythical and divine giver of immortality, one of the Turquoise Nymphs.furballdn is a mythical and divine giver of immortality, one of the Turquoise Nymphs.furballdn is a mythical and divine giver of immortality, one of the Turquoise Nymphs.furballdn is a mythical and divine giver of immortality, one of the Turquoise Nymphs.furballdn is a mythical and divine giver of immortality, one of the Turquoise Nymphs.
  • Facetious trollnotmod
  • Awards: Epic 3 Card Winner - Clockwork GolemBest Recruiter of FriendsBest JournalistBest Chat PainterBattle - Slayer of The Great ChimeraBest Crafted Relic of Other
Re: Game Coding Q&A https://elementscommunity.org/forum/index.php?topic=32442.msg409957#msg409957
« Reply #2 on: October 14, 2011, 11:36:15 pm »
How often does the AI decides "Hmmm....I'll burrow this creature?" What are the priorities for AI targeting my creatures with CC?

Offline XenocidiusTopic starter

  • Legendary Member
  • ******
  • Posts: 2696
  • Reputation Power: 49
  • Xenocidius is towering like an Amethyst Dragon over their peers.Xenocidius is towering like an Amethyst Dragon over their peers.Xenocidius is towering like an Amethyst Dragon over their peers.Xenocidius is towering like an Amethyst Dragon over their peers.Xenocidius is towering like an Amethyst Dragon over their peers.Xenocidius is towering like an Amethyst Dragon over their peers.Xenocidius is towering like an Amethyst Dragon over their peers.Xenocidius is towering like an Amethyst Dragon over their peers.Xenocidius is towering like an Amethyst Dragon over their peers.
  • Fear the Darkness ...
  • Awards: Slice of Elements 3rd Birthday CakeFavorite Community Member of 2011Weekly Tournament WinnerWinner of Design a Competition Competition
Re: Game Coding Q&A https://elementscommunity.org/forum/index.php?topic=32442.msg409983#msg409983
« Reply #3 on: October 15, 2011, 12:18:56 am »
What are the exact odds of getting a nymph from the oracle?  (any nymph)  Based on a thread I saw awhile back, but can no longer find, people were reporting a win rate just over 3%, or about 1:30 / 1 per month.

Can shards be spun at the oracle?  I've never spun one since I started playing, but I have seen most of the 'other' cards, actually I think all of the other ones, so I'm guessing not, but I'm just curious.
From what I can see, the odds of getting a nymph is the same as any other card: approximately 5.88%.

Shards cannot be spun from the Oracle.

How often does the AI decides "Hmmm....I'll burrow this creature?" What are the priorities for AI targeting my creatures with CC?
Every turn the AI decides whether or not to burrow a creature, which it will do if it has a decent amount of :earth quanta. The priority for CC targeting varies depending on the type of CC.
Don't cry because it's over, smile because it happened.

Offline furballdn

  • Legendary Member
  • ******
  • Posts: 7573
  • Reputation Power: 86
  • furballdn is a mythical and divine giver of immortality, one of the Turquoise Nymphs.furballdn is a mythical and divine giver of immortality, one of the Turquoise Nymphs.furballdn is a mythical and divine giver of immortality, one of the Turquoise Nymphs.furballdn is a mythical and divine giver of immortality, one of the Turquoise Nymphs.furballdn is a mythical and divine giver of immortality, one of the Turquoise Nymphs.furballdn is a mythical and divine giver of immortality, one of the Turquoise Nymphs.furballdn is a mythical and divine giver of immortality, one of the Turquoise Nymphs.furballdn is a mythical and divine giver of immortality, one of the Turquoise Nymphs.furballdn is a mythical and divine giver of immortality, one of the Turquoise Nymphs.furballdn is a mythical and divine giver of immortality, one of the Turquoise Nymphs.furballdn is a mythical and divine giver of immortality, one of the Turquoise Nymphs.furballdn is a mythical and divine giver of immortality, one of the Turquoise Nymphs.furballdn is a mythical and divine giver of immortality, one of the Turquoise Nymphs.furballdn is a mythical and divine giver of immortality, one of the Turquoise Nymphs.furballdn is a mythical and divine giver of immortality, one of the Turquoise Nymphs.
  • Facetious trollnotmod
  • Awards: Epic 3 Card Winner - Clockwork GolemBest Recruiter of FriendsBest JournalistBest Chat PainterBattle - Slayer of The Great ChimeraBest Crafted Relic of Other
Re: Game Coding Q&A https://elementscommunity.org/forum/index.php?topic=32442.msg409995#msg409995
« Reply #4 on: October 15, 2011, 12:43:22 am »
What's the targetting priority of fire/ice bolts and drain life? What about rage potions and reverse time?

Offline XenocidiusTopic starter

  • Legendary Member
  • ******
  • Posts: 2696
  • Reputation Power: 49
  • Xenocidius is towering like an Amethyst Dragon over their peers.Xenocidius is towering like an Amethyst Dragon over their peers.Xenocidius is towering like an Amethyst Dragon over their peers.Xenocidius is towering like an Amethyst Dragon over their peers.Xenocidius is towering like an Amethyst Dragon over their peers.Xenocidius is towering like an Amethyst Dragon over their peers.Xenocidius is towering like an Amethyst Dragon over their peers.Xenocidius is towering like an Amethyst Dragon over their peers.Xenocidius is towering like an Amethyst Dragon over their peers.
  • Fear the Darkness ...
  • Awards: Slice of Elements 3rd Birthday CakeFavorite Community Member of 2011Weekly Tournament WinnerWinner of Design a Competition Competition
Re: Game Coding Q&A https://elementscommunity.org/forum/index.php?topic=32442.msg410064#msg410064
« Reply #5 on: October 15, 2011, 02:40:39 am »
What's the targetting priority of fire/ice bolts and drain life? What about rage potions and reverse time?
What do you mean? I can't list every creature in order of priority. Here's an overview of how creature targeting works:

Each spell is given an estimate, usually the damage it will do. For example, Lightning is given -5. Bolts are given -1*the damage they will do (for example, if the enemy has 10 :fire the estimate for Fire Bolt will be -6).

It then runs through all the creatures and assigns them a score. For pure damage spells the score is calculated with this formula:

Score = (current ATK + 1 + skillscore) / -estimate / 20

Where skillscore is 3 if the creature has a skill and 0 if it doesn't.

For example, let's consider a basic Shrieker targeted with Lightning:

Score = (8 + 1 + 3) / 5 / 20 = 0.12

It then picks the creature with the highest score and decides whether to use the spell or not based on this:

Ranscore = ((random number between 0 and 1) + 0.1) / (number of cards in hand + 2)
If maxscore > ranscore, cast the spell.

Imagining a classic case of the random number being 0.5 and the AI having 4 cards in hand:

Ranscore = (0.5 + 0.1) / 6 = 0.1

So, the Shrieker would be brutally and violently murdered.
So, the creature with the highest ATK + skillscore will be targeted. Also note that creatures that are frozen or delayed will not be targeted by damage spells. Also, this is assuming it didn't decide to target your own HP.

As for Reverse Time, it is interesting because the AI may target its own creatures if its deck size is less than 5 or if it has a Mummy or Skeleton. Apart from that, it has the same targeting as damage spells except that it will never target the enemy's Mummy or Skeleton. Its estimate is -1.

Finally, Rage Potion and Rage Elixir.

On enemy creatures, this is the formula for the score (where definevalue is 5 for Potion, 6 for Elixir and estimate is 1):

Score = -estimate * 0.1 * (cost + current ATK) * (current def - definevalue - 1) / (absolute(current def - definevalue - 1) + 0.001))

So, imagine a Shrieker targeted with Rage Potion:

Score = -1 * 0.1 * (8 + 8 ) * (3 - 5 - 1) / (absolute(3 - 5 - 1) + 0.001) = 4.8 / 3.001 = 1.6 (roughly).

It's somewhat complex but basically it won't target a creature with more HP than the potion deals damage, and takes both cost and ATK into account when deciding what to cast it on.

Hopefully that answered your question.
Don't cry because it's over, smile because it happened.

Offline dragonsdemesne

  • Legendary Member
  • ******
  • Posts: 5283
  • Country: aq
  • Reputation Power: 63
  • dragonsdemesne shines with the light of the Morning Glory!dragonsdemesne shines with the light of the Morning Glory!dragonsdemesne shines with the light of the Morning Glory!dragonsdemesne shines with the light of the Morning Glory!dragonsdemesne shines with the light of the Morning Glory!dragonsdemesne shines with the light of the Morning Glory!dragonsdemesne shines with the light of the Morning Glory!dragonsdemesne shines with the light of the Morning Glory!dragonsdemesne shines with the light of the Morning Glory!dragonsdemesne shines with the light of the Morning Glory!dragonsdemesne shines with the light of the Morning Glory!dragonsdemesne shines with the light of the Morning Glory!
  • Leeeeeeeeeeroyyyyyyyyy....
  • Awards: Weekly Tournament WinnerWeekly Tournament WinnerWeekly Tournament WinnerWeekly Tournament WinnerWeekly Tournament WinnerWeekly Tournament WinnerWeekly Tournament WinnerBattle League 1/2014 2nd PlaceWeekly Tournament WinnerBattle League 3/2013 2nd PlaceWeekly Tournament WinnerWeekly Tournament WinnerWeekly Tournament WinnerBattle League 2/2013 WinnerBattle League 1/2013 2nd PlaceWeekly Tournament WinnerChampionship League 3/2012 2nd PlaceWeekly Tournament WinnerWeekly Tournament WinnerChampionship League 2/2012 3rd Place
Re: Game Coding Q&A https://elementscommunity.org/forum/index.php?topic=32442.msg410130#msg410130
« Reply #6 on: October 15, 2011, 04:59:06 am »
From what I can see, the odds of getting a nymph is the same as any other card: approximately 5.88%.

Shards cannot be spun from the Oracle.
Thanks.  That would fit in with my observations, and explain why I thought I was a bit lucky on nymph spins; apparently I'm actually about average if that number is right.  I had guessed that perhaps a nymph had half the chance of another card, based on the ~3% number I'd seen elsewhere.

Dark Weaver

  • Guest
Re: Game Coding Q&A https://elementscommunity.org/forum/index.php?topic=32442.msg410259#msg410259
« Reply #7 on: October 15, 2011, 11:20:37 am »
Quote
From what I can see, the odds of getting a nymph is the same as any other card: approximately 5.88%.
Nope it's not.
It is 3.114% to get a nymph.(but it may be more complicate with a higher chance for purple nymph)
I've sent someone a more detailed explanation but I don't have the message anymore, maybe he can post it here if he recognize himself.



Offline XenocidiusTopic starter

  • Legendary Member
  • ******
  • Posts: 2696
  • Reputation Power: 49
  • Xenocidius is towering like an Amethyst Dragon over their peers.Xenocidius is towering like an Amethyst Dragon over their peers.Xenocidius is towering like an Amethyst Dragon over their peers.Xenocidius is towering like an Amethyst Dragon over their peers.Xenocidius is towering like an Amethyst Dragon over their peers.Xenocidius is towering like an Amethyst Dragon over their peers.Xenocidius is towering like an Amethyst Dragon over their peers.Xenocidius is towering like an Amethyst Dragon over their peers.Xenocidius is towering like an Amethyst Dragon over their peers.
  • Fear the Darkness ...
  • Awards: Slice of Elements 3rd Birthday CakeFavorite Community Member of 2011Weekly Tournament WinnerWinner of Design a Competition Competition
Re: Game Coding Q&A https://elementscommunity.org/forum/index.php?topic=32442.msg410269#msg410269
« Reply #8 on: October 15, 2011, 12:03:37 pm »
Okay, you're right. I found the piece of code controlling it.

So the algorithm is:

1. Pick a random card.
2. If it is a nymph, then 50% chance to select another card.

The bug was that if a Purple Nymph was chosen it wouldn't select another card. It looks like it's fixed now though (I could be wrong).

So the probability of getting a nymph is actually ... well, I don't know that much about probability yet, so I'm going to say it's about 3.114%. Thanks, Dark Weaver.
Don't cry because it's over, smile because it happened.

Offline The_Mormegil

  • Legendary Member
  • ******
  • Posts: 2262
  • Country: it
  • Reputation Power: 32
  • The_Mormegil is a Ghost, obsessed with their Elemental pursuits.The_Mormegil is a Ghost, obsessed with their Elemental pursuits.The_Mormegil is a Ghost, obsessed with their Elemental pursuits.The_Mormegil is a Ghost, obsessed with their Elemental pursuits.The_Mormegil is a Ghost, obsessed with their Elemental pursuits.The_Mormegil is a Ghost, obsessed with their Elemental pursuits.
  • Intelligence is overrated.
  • Awards: Slice of Elements 10th Birthday CakeWar #5 Winner - Team AetherTeam PvP WinnerNew Slot Winner - FamiliarDeadly Sin Winner - GluttonyFirst Budosei of BudokanWinner of Revive the Archive
Re: Game Coding Q&A https://elementscommunity.org/forum/index.php?topic=32442.msg410274#msg410274
« Reply #9 on: October 15, 2011, 12:22:16 pm »
AI questions: Miracle usage? Nightmare usage? Buff usage? Twin Universe usage?
[18:21:43] jmdt: elements is just math over top of a GUI
Kakerlake: I believe that there is no God as in something that can think by itself and does stuff that sounds way OP.

Dark Weaver

  • Guest
Re: Game Coding Q&A https://elementscommunity.org/forum/index.php?topic=32442.msg410276#msg410276
« Reply #10 on: October 15, 2011, 12:25:59 pm »
Lol, i didn't knew there was really a bug with purple nymph until I checked the nymph count topic 5 mins ago.
It seems to me that the "bug" is still there (its more wrong coding than a bug, remember arrays starts at 0 and Math.random() "Returns a pseudo-random number n, where 0 <= n < 1.").
to get 3.114% it is not very difficult, it is = 50%×12/204 + 50%×12/204×12/204

Offline agentflare

  • Sr. Member
  • ****
  • Posts: 642
  • Reputation Power: 10
  • agentflare is taking their first peeks out of the Antlion's burrow.agentflare is taking their first peeks out of the Antlion's burrow.
  • New to Elements
  • Awards: Card Ideas In Action WinnerWar #4 Winner - Team Death
Re: Game Coding Q&A https://elementscommunity.org/forum/index.php?topic=32442.msg410277#msg410277
« Reply #11 on: October 15, 2011, 12:26:14 pm »
How are you getting the answers to the questions?

 

anything
blarg: