一张扑克牌的面值及花色用一字节表示,高四位表示花色,低四位表示面值。如高四位1、2、3、4、5分别表示黑桃、红桃、方块、梅花、王牌。低四位从0x00到0x0C,分别表示123456789,10JQK。大王0x5E,小王0x5D。
这样一副牌就可以表示为:
0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1A,0x1B,0x1C(黑桃)
0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29,0x2A,0x2B,0x2C(红桃)
0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x3A,0x3B,0x3C(方块)
0x40,0x41,0x42,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4A,0x4B,0x4C(梅花)
0x5D,0x5E(王牌)
这样表示后,游戏AI的编制非常方便。