Spell Chess

Discussion of chess software programming and technical issues.

Moderator: Ras

User avatar
hgm
Posts: 28353
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Spell Chess

Post by hgm »

I think I have an even more elegant search algorithm, which would collaps the daughters were you did not cast a freeze with those where you did, searching both cases, and then report whether it is best to do a freeze (and if so, where) or not in combination with the move leading to it. This would still have to search each move twice, if there is no cutoff. (But know for the case where the opponent left you with or without a freeze.)

You could then first search all moves for the case where you are not hindered by any freeze. If this fails low, you are done, because it means the opponent's preceding move did already cause a cutoff without spending a freeze, which will be enough to satisfy him. If some of your moves raised alpha, the preceding move would not have failed high without a spell. The opponent then could try the same move in combination with a freeze. This would make all your moves in the current node better (as the opponent would be left with one less freeze in hand, which is always a disadvantage except perhaps in rare stalemate positions). But it could then be applied to prevent some of your best moves, so that their improved scores must be ignored, and the result will be the (now improved) score of one of your weaker (but not frozen out) moves. Which might still be below alpha.

So after search all moves normally, you would decrement the number of freezes held by the opponent, go through the move list again, searching the replies with this decremented number of freezes. (Of course only when the opponent actually had freezes to spend.) Score updating will be more complex, though: we keep track of the best move so far from each piece. This will start at the original alpha of the node, or, for pieces that had a move that raised alpha in the spellless round, by their score there. We sort these per-move scores high to low, and then determine how many of the highest scoring pieces we can freeze simultaneously.

We then start running through the move list, and every move of a piece that belongs to the set that can be frozen is not searched, but a copy is appended to the end of the move list so it can be searched later. If we do search a move, (for a piece that could not be frozen together with the best move so far) this might raise the score of the piece making it. If this brings its score in the realm of the scores of the frozen pieces, we have to recalculate where we can best apply the freeze spell. E.g. if the searched move would score better than any move so far, we would have to move the freeze spell to cover the corresponding piece, no matter how far away it was from the previous spell location, and no matter how many other pieces we must uncover by this. We will remember where the end of the move list was when we uncover any pieces this way. Whether subsequent moves will be searched or postponed will be judged by this new spell placement.

When we reach the remembered end of the move list (which might no longer be the current end of the move list, as in getting there we might have postponed more moves of frozen pieces), we can stop. Since all moves that have been postponed since the last time we uncovered any piece will still be banned by the spell. So in this second round each move will be searched at most once, but potentially postoponed many times.

Note that the spell location might not always be fully determined, which we implement by allowing the spell area to be smaller than 3x3. E.g. if in the first round only a single move raised alpha, we initially only need a 1x1 spell zone to freeze all the best pieces. When we encounter a piece next to such an 'under-developed' spell area, which can be covered by expanding the area, we will enlarge the area to cover that piece as well, and thus postpone the move. What shape and shift the enlarged area must have can be tabulated as function of the old shape and relative location of the new piece; once the area has grown to 3x3 and will no longer change, so pieces outside of it cannot be covered 'for free' (i.e. without uncovering something else), and their moves will have to be searched rather than postponed.

If the score such a search delivers upsets gets above that of the worst-scoring frozen piece, we have to recalculate the spell placement. We can do this using the same table. First insert the piece that improved in the proper place of the piece ranking. Then start with a 1x1 spell area on the best-scoring piece, and run through the ranking using the table to see if additional pieces are or can be covered as well, until you reach one that cannot. The score of the latter has the role of the (increased) alpha in a normal alpha-beta search; it will be returned as the score of the node, and when it gets above beta, we can return immediately. The spell location will have to be communicated to the parent, to inform it which spell it should combine with the move leading to the daughter to get the promised score (which could become arbitrarily lower when casting it elsewhere). But only the root node might be interested in that, although you would also need it for PV building.

I have the feeling that freeze spells are quite valuable, so that moves that spend one should be considered late moves, and reduced in LMR fashion. Perhaps except when they deliver check; in that case a lot of the replies won't resolve the check and thus score -INFINITY, so that the number of pieces you have to freeze to cause a dramatic score drop can be quite small.
rgrosz789
Posts: 121
Joined: Sat Dec 03, 2022 9:28 pm
Full name: Rick Groszkiewicz

Re: Spell Chess

Post by rgrosz789 »

My description was NOT quite correct. Chess.com has updated their own description recently:
  • Cast a spell before making a move.
  • Spells are limited, recharge after 3 full turns, and you cannot cast the same spell two moves in a row.
  • Use the Jump spell on another piece to hop over like it isn’t there.
  • Or use the Freeze spell to prevent pieces from moving or checking within a 3x3 area of effect. Be careful—any piece, including your own, will freeze if it enters the spell area.
  • Use spells to find a checkmate or king capture!
Retired actuary and software developer. I love chess, coffee, wine and food
User avatar
hgm
Posts: 28353
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Spell Chess

Post by hgm »

I think they don't understand their own variant, because this is nonsensical, incomplete and plain wrong in some places. Of course you cannot do two spells in a row when the 'recharge' only after 3 full turns; you would need two moves in between. It doesn't say how long the effect of a casted spell lasts, but since this is only for one turn, the remark on freezing your own pieces that move into the zone is not true: the spell would have worn off the next time that player has to move, and that they cannot move during the opponent's turn is already true without any spell.