Perl Monk, Perl Meditation | |
PerlMonks |
Re^5: implementing a scrabble-esque game on Termux IIIby tybalt89 (Monsignor) |
on Dec 03, 2019 at 16:42 UTC ( [id://11109606]=note: print w/replies, xml ) | Need Help?? |
Explanation of the masking in "matchrule"
Let's follow a call to matchrule('hello', '14222', 'world')
However, I want to change all non nulls ("\0") to "\xff" so that characters can pass through these positions unchanged.
Now we use this mask against the tile heights and look for any 5's, because the "\xff" in $newmask are at the positions where new tiles will be added.
and since there is no 5, the new word is not invalid (yet).
This leaves only the new tiles that must be played, ignoring the "\0"
because those positions use the old tile. So remove each new letter from
a string of the tile rack, and if any are not there, the move is invalid.
In Section
Seekers of Perl Wisdom
|
|