Very informative! Thanks.
Why don't you check hand size before playing Shard of Serendipity?
Right now, AI wastes cards by playing it with hand full, and the algo line confirms this.
Adding random is good for variety, but creates "AI mistakes", like when AI doesn't use a free hostile skill it can use. Why don't you run another check at the end of the target finding to be sure that the skill has been used (or reduce the random factor influence)? I see flying Eternity with SoR not using their skill on my creatures quite frequently.
Hope I didn't miss something when I looked into this.