Oktober 2014 blog archive

This page contains all the blog posts from oktober 2014. To read the most recent blog posts, click here.

26/10 - unpredictable

V 3.01.001 was released last thursday, containing a number of bugfixes, but also some new content that didn't exist in HDx. Unpredictable is a new game mode, where both players are given a new hand of 6 cards each turn. All cards in hand, scrap and deck are removed at the end of a player's turn. The cards one gets each turn can be controlled by setting the races in the battle setup screen (similar to how one sets races for generated decks). If two different races are chosen, each of the 6 cards has 60% chance to belong to the first race and 40% to belong to the second race. These 6 cards are not completely random : the game makes sure that there's always one ship, one energy structure and one action in this set. Since randomness has a higher effect on the outcome of a duel compared to the average game, the game is slowed down by setting a limit to the number of structures players can play each turn. By limiting this to 1, there's more time to build up defenses.
The increased randomness in this game mode comes from the fact that the entire card set(s) of the chosen race(s) are available to draw cards from, compared to a players self-made deck, which is between 40 and 60 cards and generally contains 4 copies of a number of cards. This also means that the set of cards players draw each turn can contain cards of which they already have 4 copies in play.

The core idea of unpredictable is available for testing in the latest alpha patch, but seeing as this game mode is very different from the default single duel versus the AI, it's to be expected that unpredictable will need fine-tuning.
Up until now, in the history of HD, cards have always been balanced from the point of view of one player versus one AI. Some cards will be vastly more powerful in the unpredictable setting, others might have no use at all. Cards like that could be removed from this game mode, so that players can't draw them, or they could be made more rare, so that there's less chance to draw them.
The rules of unpredictable themselves can also be adjusted. To make sure that the first couple turns are balanced, and players are given enough time to set up, the game guarantees that there's always one ship, one energy structure and one action in the cards that are drawn. Technically, this is no longer needed after round 5, as you can expect players will have 5 energy structures in play by then. The fact that this gamemode gives players 6 new cards each turn can drastically increase the number of cards players can actually play, especially later in the game, compared to regular duels. It might be an idea to gradually lower the number of cards that are drawn each turn, down to for instance 3 cards after a number of rounds.

This update also added a new deck mod called 'Basic ships', which removes all abilities from ship cards in the deck. This deck mod has been set up so that it doesn't affect the abilities that other deck mods might add to ship cards.
A deck mod that already existed in HDx, called 'Cerberus fleet', which halves the attack of all ships in a deck, but gives them the 'Cerberus' passive, has also been added.

Several environments were added as well :
'Datastream', which allows players to draw 1 to 2 additional cards during their draw phases.
'Relentless', which gives players 1 to 2 additional combat phases during their turns.
'Energy vortex', which drains 4 to 8 random energy from opponents every turn.
All these existed in HDx, but Datastream and Relentless used to be deck mods. A few other HDx deck mods will be turned into environments, and a couple will likely be removed completely but will be incorporated in new game modes. The affected deck mods are all those that are simply too powerful, and that, when added to a single deck, will almost guarantee that deck to win the duel. So this option has been removed and by turning these deck mods into environments, they basically get applied to both decks. It will still be possible for the AI in the future (and in specific game modes) to select these deck mods to give the player an extra challenge.

19/10 - AI score thresholds and modifiers

When the AI runs a simulation to predict the effect of an ability on a card it's considering playing or activating, it generally runs 3 sims. One immediate sim where the ability is activated, or the card that it's on is played. A second sim (on top of the first) where the AI will attack the current opponent, and a final sim on top of this one, where the opponent goes through an upkeep, draw and combat phase.

As mentioned in previous blogposts about the AI updates, the further into the future the AI tries to predict, the less reliable things become. If the AI has an ability that can destroy a single ship, that ability will get a score based on the overall strength of that ship. If this happens in the first of the 3 sims, it means that the effect is instant, and the ability will get the full score. If the ship survives the first step but is destroyed after the combat phase, the score will be half of the original, and if the ship only dies at the end of the opponent's combatphase (ie after the 3rd sim), the score will only be 1/4th of the original.
If the AI has two abilities that are identical, except for the fact that one ability has an immediate effect on the board, and the other ability its effect is only visible a bit further into the future, the AI will thus play the one with the immediate effect first. Some abilities however only have an effect that's visible into the future. Example : an ability that allows to disable a ship. When played on an opposing ship, this will cause that ship to skip its attack phase, but that attack phase is more than an entire turn into the future.
It's relatively difficult for the AI to score such abilities, as they will always have a score that's on average very low, unless that ability has a very large effect on the board (fi when it can keep a ship from attacking that would otherwise destroy the AI's base).

Another reason why abilities might have low scores is simply because their efffect is very small. There are abilities whose effect scales off other elements in the game. If the AI has an action that repairs its base for 1 HP for each card in scrap, that ability will have a score of (for instance) 1 when there's 1 card in scrap, and a score of 10 if there are 10 cards in scrap. In both cases, the ability has a score, and as long as cards have positive scores, the AI will play them. In case of this example, it's clear that the AI should considering waiting until there are more cards in scrap, unless this ability is vital in keeping the AI alive.

Both problems exist currently in the AI, but are gradually being tackled by changing the score modifiers for individual abilities, and applying thresholds where needed.

Abilities can have secondary effects, some might even be negative to the AI, but if the positive effect outweighs the negative, the AI will still consider playing that ability. Example : the AI might sacrifice one of its ships to gain energy, but at the same time this might leave an attacker unblocked, which can then proceed to damage the base. Sometimes, negative effects have nothing to do with the original ability, but only manifest themselves in the future. Example : a ship can generate energy instead of attacking. As a result, this ship's blocker won't be damaged in the next combat phase, possibly allowing it to survive until that ship itself, can attack. If that ship is then unblockable, it will damage the base. Thus as a result of using this ability, the AI might end up receiving additional base damage.
Score modifiers tell the AI how important different kind of effects are. There are 3 effects for each player : loss of ships, changing ship stats, and changing base HP amounts. A defensive ability that can repair the AI's base will generally have a higher modifier for the base HP stats. If the same ability has a negative effect (f.i. it deals damage to an allied ship), the modifier for loss of own ships will be slightly higher as well, allowing the AI to avoid using this ability if it were to destroy one of its own ships. If the loss own ships would be completely ignores, the AI might end up playing abilities that are more harmful than beneficial to itself.

Score thresholds are straightforward : for abilities that have them, it basically means that if this ability has such a small impact on the board that its score is below this threshold, the AI will simply not consider playing it. Currently only a few abilities have such a threshold. While modifiers are easier to set up, as they depend primarily on what an ability does mechanically, whether or not an ability needs a threshold depends on how often the AI ends up playing that ability too soon. So figuring this out is a matter of seeing the AI in progress over the course of many games.

12/10 - alpha 3.01

The first major alpha update is out. It took about a month to get this one ready, which is about the amount of time i had expected it would take, even though things ended up going very differently.

The CA card set is the biggest addition in 3.01, but also the only thing content-wise, next to some bug fixes. The general plan is that each major version comes with an entire card set, but also a few other content related elements, such as game modes, deckmods and environments. Since the CA card set took so much time, i released 3.01 with only those cards. The other content will be added to the game, alongside a few more bug fixes, over the course of the next few minor updates.

Next to the CA card set, there's another big change in 3.01, which mostly happens out of sight : the overhaul of a large section of the AI. On one hand, this is what caused 3.01 to take so long to complete, but at the same time, it made the addition of half of the CA card set take about 1/4th the time of the addition of the first half. In the long run, these changes to the AI will save me a lot of time.

Before i start working on the next minor patch, i'll probably take a break from coding for a few days, which will also give me the time to set up a list of things that i would like to see added in 3.01 before i start work on 3.02.

05/10 - AI optimizations II

Last week i talked about a new system which would make the AI more accurate and which would also reduce the amount of new code i'd have to write when adding in new abilties.
The main reason why i have to write less code is that the new setup can handle different ability classes : actis, actions and play abilities. Actis and actions worked right away, but for play abilties the setup needed to extra stuff, mainly because play abilities are scored after a new cardplay, which exists in 3 forms : a new ship, a new structure, or a recycled structure.

While working on support for play abilities i discovered a problem with the original AI (and which would still persist, and even get worse under the new system). This problem is of no concern for actions and actis since cards can only have one of each of those abilities, but cards can have multiple play abilities.
When the AI is considering what card to play next, it simulates each of the cards it can play entering the board, which involves the play abilities getting triggered. The core of this system is that all the abilities on the card get a score based on their impact on the board (for new cardplays, play abilities are the most important). The card with the highest score is then the one the AI will end up playing first. This scoring is done on a per-ability base, meaning that for each ability, the AI can choose to run a sim or score the ability in a simpler way.
Thus, for a card with two play abilities, the AI will run two seperate simulations where this card enters play, and then see how those abilities impacted the board. Under the old system this really wasn't a problem, since a play ability that generates energy combined with one that deals damage results in two effects that almost never overlap. For the energy ability the AI will check how much of which race's energy is generated and compares that with how much of that type of energy the AI really needs, the AI doesn't need to check the opposing base or ships for this. When the AI tries to gauge the impact of the damage ability, it's not going to check its own energy stocks.
But technically, the AI should check everything. I might add a trigger aura that lets a ship deal damage to the opposing base when the opponent gains energy. There could be trigger that drains energy when a ship gets damaged. If such cards are on the board, an ability that generates energy will require the AI to check the opposing base to see how much damage it received, or, if this ability is owned by the opponent, the AI would have to check its own base.
The problem comes from the fact that the AI runs two sims, one for each play ability. Yet, this sim (of a card entering play) will trigger both play abilities on this card (fi a structure that generates energy and deals damage to the opponent). The AI then checks the entire board and notices that it gained energy and that the opposing base received damage, but this happens twice, since the AI runs such a sim for each ability. Even though energy and damage abilities generally don't overlap, it might be possible in the future.
The solution was to change the way how the AI scores a new card entering play : instead of looking at all the play abilities and running a simulation for each of them, there will now only be a single simulation. The AI then looks at the board first to see how all the abilities combined (and any triggers that might have gone off) have affected the board. The new setup is made to focus on abilities that affect ships or bases, but it will also keep an eye on energy stocks. After this sim, the AI will still go through all the play abilities on the card to see if there are any that the setup can't score (such as a play ability that lets a player draw a card).

An interesting side-effect of this new way how play abilities are handled, is that it drastically reduces the number of simulations a new cardplay requires. In the original setup, there was always the initial sim, which checked if the card survived the entry onto the board. This first step also checked how newly played ships performed in the first combat phase (do they survive at all?). Once this sim is done, the AI loops through all play abilties, often doing additional sims for each of them. So a card with 2 play abilities might need 3 sims so that the AI can calculate the score of the card. Now, for most cards, only one sim is needed.