even prev -> rank within 4; otherwise different suit

if not mainline:
    return True
prev = mainline[-1]
if prev.rank % 2 == 0:
    return abs(card.rank - prev.rank) <= 4
return card.suit != prev.suit


face prev -> rank within 4; otherwise rank within 1

if not mainline:
    return True
prev = mainline[-1]
if prev.is_face:
    return abs(card.rank - prev.rank) <= 4
return abs(card.rank - prev.rank) <= 1


red -> same color; otherwise rank within 5

if not mainline:
    return True
prev = mainline[-1]
if prev.color == "red":
    return card.color == prev.color
return abs(card.rank - prev.rank) <= 5


high prev -> same color; otherwise rank within 3

if not mainline:
    return True
prev = mainline[-1]
if prev.rank >= 9:
    return card.color == prev.color
return abs(card.rank - prev.rank) <= 3


high prev -> same suit; otherwise decreasing

if not mainline:
    return True
prev = mainline[-1]
if prev.rank >= 9:
    return card.suit == prev.suit
return card.rank < prev.rank


red -> same color; otherwise rank within 6

if not mainline:
    return True
prev = mainline[-1]
if prev.color == "red":
    return card.color == prev.color
return abs(card.rank - prev.rank) <= 6


face prev -> same parity; otherwise rank within 3

if not mainline:
    return True
prev = mainline[-1]
if prev.is_face:
    return card.rank % 2 == prev.rank % 2
return abs(card.rank - prev.rank) <= 3


face prev -> rank within 5; otherwise rank within 1

if not mainline:
    return True
prev = mainline[-1]
if prev.is_face:
    return abs(card.rank - prev.rank) <= 5
return abs(card.rank - prev.rank) <= 1


red -> rank within 1; otherwise same parity

if not mainline:
    return True
prev = mainline[-1]
if prev.color == "red":
    return abs(card.rank - prev.rank) <= 1
return card.rank % 2 == prev.rank % 2


face prev -> different color; otherwise rank within 3

if not mainline:
    return True
prev = mainline[-1]
if prev.is_face:
    return card.color != prev.color
return abs(card.rank - prev.rank) <= 3


high prev -> rank within 2; otherwise rank within 3

if not mainline:
    return True
prev = mainline[-1]
if prev.rank >= 9:
    return abs(card.rank - prev.rank) <= 2
return abs(card.rank - prev.rank) <= 3


red -> different color; otherwise nondecreasing

if not mainline:
    return True
prev = mainline[-1]
if prev.color == "red":
    return card.color != prev.color
return card.rank >= prev.rank


even prev -> same color; otherwise rank within 1

if not mainline:
    return True
prev = mainline[-1]
if prev.rank % 2 == 0:
    return card.color == prev.color
return abs(card.rank - prev.rank) <= 1


high prev -> different suit; otherwise rank within 2

if not mainline:
    return True
prev = mainline[-1]
if prev.rank >= 9:
    return card.suit != prev.suit
return abs(card.rank - prev.rank) <= 2


high prev -> same color; otherwise decreasing

if not mainline:
    return True
prev = mainline[-1]
if prev.rank >= 9:
    return card.color == prev.color
return card.rank < prev.rank


high prev -> same parity; otherwise rank within 1

if not mainline:
    return True
prev = mainline[-1]
if prev.rank >= 9:
    return card.rank % 2 == prev.rank % 2
return abs(card.rank - prev.rank) <= 1


face prev -> rank within 1; otherwise rank within 2

if not mainline:
    return True
prev = mainline[-1]
if prev.is_face:
    return abs(card.rank - prev.rank) <= 1
return abs(card.rank - prev.rank) <= 2


red -> nondecreasing; otherwise same suit

if not mainline:
    return True
prev = mainline[-1]
if prev.color == "red":
    return card.rank >= prev.rank
return card.suit == prev.suit


face prev -> same parity; otherwise rank within 6

if not mainline:
    return True
prev = mainline[-1]
if prev.is_face:
    return card.rank % 2 == prev.rank % 2
return abs(card.rank - prev.rank) <= 6


even prev -> nondecreasing; otherwise higher rank

if not mainline:
    return True
prev = mainline[-1]
if prev.rank % 2 == 0:
    return card.rank >= prev.rank
return card.rank > prev.rank


face prev -> nondecreasing; otherwise rank within 6

if not mainline:
    return True
prev = mainline[-1]
if prev.is_face:
    return card.rank >= prev.rank
return abs(card.rank - prev.rank) <= 6


high prev -> opposite parity; otherwise same parity

if not mainline:
    return True
prev = mainline[-1]
if prev.rank >= 9:
    return card.rank % 2 != prev.rank % 2
return card.rank % 2 == prev.rank % 2


red -> same color; otherwise opposite parity

if not mainline:
    return True
prev = mainline[-1]
if prev.color == "red":
    return card.color == prev.color
return card.rank % 2 != prev.rank % 2


high prev -> different suit; otherwise decreasing

if not mainline:
    return True
prev = mainline[-1]
if prev.rank >= 9:
    return card.suit != prev.suit
return card.rank < prev.rank


even prev -> different suit; otherwise rank within 1

if not mainline:
    return True
prev = mainline[-1]
if prev.rank % 2 == 0:
    return card.suit != prev.suit
return abs(card.rank - prev.rank) <= 1


face prev -> nondecreasing; otherwise same suit

if not mainline:
    return True
prev = mainline[-1]
if prev.is_face:
    return card.rank >= prev.rank
return card.suit == prev.suit


even prev -> same parity; otherwise different suit

if not mainline:
    return True
prev = mainline[-1]
if prev.rank % 2 == 0:
    return card.rank % 2 == prev.rank % 2
return card.suit != prev.suit


high prev -> higher rank; otherwise rank within 6

if not mainline:
    return True
prev = mainline[-1]
if prev.rank >= 9:
    return card.rank > prev.rank
return abs(card.rank - prev.rank) <= 6


high prev -> rank within 6; otherwise opposite parity

if not mainline:
    return True
prev = mainline[-1]
if prev.rank >= 9:
    return abs(card.rank - prev.rank) <= 6
return card.rank % 2 != prev.rank % 2


high prev -> same parity; otherwise higher rank

if not mainline:
    return True
prev = mainline[-1]
if prev.rank >= 9:
    return card.rank % 2 == prev.rank % 2
return card.rank > prev.rank


red -> rank within 4; otherwise higher rank

if not mainline:
    return True
prev = mainline[-1]
if prev.color == "red":
    return abs(card.rank - prev.rank) <= 4
return card.rank > prev.rank


face prev -> different suit; otherwise rank within 6

if not mainline:
    return True
prev = mainline[-1]
if prev.is_face:
    return card.suit != prev.suit
return abs(card.rank - prev.rank) <= 6


high prev -> different suit; otherwise rank within 5

if not mainline:
    return True
prev = mainline[-1]
if prev.rank >= 9:
    return card.suit != prev.suit
return abs(card.rank - prev.rank) <= 5


high prev -> rank within 4; otherwise same suit

if not mainline:
    return True
prev = mainline[-1]
if prev.rank >= 9:
    return abs(card.rank - prev.rank) <= 4
return card.suit == prev.suit


face prev -> same parity; otherwise opposite parity

if not mainline:
    return True
prev = mainline[-1]
if prev.is_face:
    return card.rank % 2 == prev.rank % 2
return card.rank % 2 != prev.rank % 2


high prev -> rank within 4; otherwise rank within 3

if not mainline:
    return True
prev = mainline[-1]
if prev.rank >= 9:
    return abs(card.rank - prev.rank) <= 4
return abs(card.rank - prev.rank) <= 3


face prev -> same color; otherwise rank within 4

if not mainline:
    return True
prev = mainline[-1]
if prev.is_face:
    return card.color == prev.color
return abs(card.rank - prev.rank) <= 4


face prev -> rank within 1; otherwise nondecreasing

if not mainline:
    return True
prev = mainline[-1]
if prev.is_face:
    return abs(card.rank - prev.rank) <= 1
return card.rank >= prev.rank


high prev -> nondecreasing; otherwise rank within 2

if not mainline:
    return True
prev = mainline[-1]
if prev.rank >= 9:
    return card.rank >= prev.rank
return abs(card.rank - prev.rank) <= 2


high prev -> rank within 1; otherwise opposite parity

if not mainline:
    return True
prev = mainline[-1]
if prev.rank >= 9:
    return abs(card.rank - prev.rank) <= 1
return card.rank % 2 != prev.rank % 2


high prev -> same suit; otherwise rank within 1

if not mainline:
    return True
prev = mainline[-1]
if prev.rank >= 9:
    return card.suit == prev.suit
return abs(card.rank - prev.rank) <= 1


high prev -> decreasing; otherwise rank within 6

if not mainline:
    return True
prev = mainline[-1]
if prev.rank >= 9:
    return card.rank < prev.rank
return abs(card.rank - prev.rank) <= 6


high prev -> rank within 4; otherwise rank within 1

if not mainline:
    return True
prev = mainline[-1]
if prev.rank >= 9:
    return abs(card.rank - prev.rank) <= 4
return abs(card.rank - prev.rank) <= 1


high prev -> rank within 6; otherwise higher rank

if not mainline:
    return True
prev = mainline[-1]
if prev.rank >= 9:
    return abs(card.rank - prev.rank) <= 6
return card.rank > prev.rank


red -> same parity; otherwise decreasing

if not mainline:
    return True
prev = mainline[-1]
if prev.color == "red":
    return card.rank % 2 == prev.rank % 2
return card.rank < prev.rank


face prev -> rank within 2; otherwise higher rank

if not mainline:
    return True
prev = mainline[-1]
if prev.is_face:
    return abs(card.rank - prev.rank) <= 2
return card.rank > prev.rank


face prev -> rank within 3; otherwise nondecreasing

if not mainline:
    return True
prev = mainline[-1]
if prev.is_face:
    return abs(card.rank - prev.rank) <= 3
return card.rank >= prev.rank


high prev -> rank within 2; otherwise same color

if not mainline:
    return True
prev = mainline[-1]
if prev.rank >= 9:
    return abs(card.rank - prev.rank) <= 2
return card.color == prev.color


face prev -> rank within 6; otherwise rank within 3

if not mainline:
    return True
prev = mainline[-1]
if prev.is_face:
    return abs(card.rank - prev.rank) <= 6
return abs(card.rank - prev.rank) <= 3


high prev -> rank within 2; otherwise higher rank

if not mainline:
    return True
prev = mainline[-1]
if prev.rank >= 9:
    return abs(card.rank - prev.rank) <= 2
return card.rank > prev.rank


even prev -> higher rank; otherwise rank within 5

if not mainline:
    return True
prev = mainline[-1]
if prev.rank % 2 == 0:
    return card.rank > prev.rank
return abs(card.rank - prev.rank) <= 5


red -> opposite parity; otherwise rank within 5

if not mainline:
    return True
prev = mainline[-1]
if prev.color == "red":
    return card.rank % 2 != prev.rank % 2
return abs(card.rank - prev.rank) <= 5


face prev -> rank within 2; otherwise rank within 5

if not mainline:
    return True
prev = mainline[-1]
if prev.is_face:
    return abs(card.rank - prev.rank) <= 2
return abs(card.rank - prev.rank) <= 5


even prev -> higher rank; otherwise same suit

if not mainline:
    return True
prev = mainline[-1]
if prev.rank % 2 == 0:
    return card.rank > prev.rank
return card.suit == prev.suit


even prev -> rank within 3; otherwise higher rank

if not mainline:
    return True
prev = mainline[-1]
if prev.rank % 2 == 0:
    return abs(card.rank - prev.rank) <= 3
return card.rank > prev.rank


face prev -> rank within 4; otherwise rank within 5

if not mainline:
    return True
prev = mainline[-1]
if prev.is_face:
    return abs(card.rank - prev.rank) <= 4
return abs(card.rank - prev.rank) <= 5


high prev -> rank within 5; otherwise rank within 1

if not mainline:
    return True
prev = mainline[-1]
if prev.rank >= 9:
    return abs(card.rank - prev.rank) <= 5
return abs(card.rank - prev.rank) <= 1


even prev -> rank within 2; otherwise different suit

if not mainline:
    return True
prev = mainline[-1]
if prev.rank % 2 == 0:
    return abs(card.rank - prev.rank) <= 2
return card.suit != prev.suit


face prev -> same color; otherwise rank within 6

if not mainline:
    return True
prev = mainline[-1]
if prev.is_face:
    return card.color == prev.color
return abs(card.rank - prev.rank) <= 6


red -> nondecreasing; otherwise rank within 1

if not mainline:
    return True
prev = mainline[-1]
if prev.color == "red":
    return card.rank >= prev.rank
return abs(card.rank - prev.rank) <= 1


high prev -> same color; otherwise opposite parity

if not mainline:
    return True
prev = mainline[-1]
if prev.rank >= 9:
    return card.color == prev.color
return card.rank % 2 != prev.rank % 2


even prev -> rank within 5; otherwise same parity

if not mainline:
    return True
prev = mainline[-1]
if prev.rank % 2 == 0:
    return abs(card.rank - prev.rank) <= 5
return card.rank % 2 == prev.rank % 2


red -> decreasing; otherwise opposite parity

if not mainline:
    return True
prev = mainline[-1]
if prev.color == "red":
    return card.rank < prev.rank
return card.rank % 2 != prev.rank % 2


high prev -> different suit; otherwise same suit

if not mainline:
    return True
prev = mainline[-1]
if prev.rank >= 9:
    return card.suit != prev.suit
return card.suit == prev.suit


face prev -> rank within 6; otherwise nondecreasing

if not mainline:
    return True
prev = mainline[-1]
if prev.is_face:
    return abs(card.rank - prev.rank) <= 6
return card.rank >= prev.rank


even prev -> same suit; otherwise rank within 2

if not mainline:
    return True
prev = mainline[-1]
if prev.rank % 2 == 0:
    return card.suit == prev.suit
return abs(card.rank - prev.rank) <= 2


even prev -> same suit; otherwise rank within 6

if not mainline:
    return True
prev = mainline[-1]
if prev.rank % 2 == 0:
    return card.suit == prev.suit
return abs(card.rank - prev.rank) <= 6


even prev -> different color; otherwise same color

if not mainline:
    return True
prev = mainline[-1]
if prev.rank % 2 == 0:
    return card.color != prev.color
return card.color == prev.color


even prev -> rank within 2; otherwise rank within 5

if not mainline:
    return True
prev = mainline[-1]
if prev.rank % 2 == 0:
    return abs(card.rank - prev.rank) <= 2
return abs(card.rank - prev.rank) <= 5


red -> rank within 1; otherwise different color

if not mainline:
    return True
prev = mainline[-1]
if prev.color == "red":
    return abs(card.rank - prev.rank) <= 1
return card.color != prev.color


high prev -> different color; otherwise same color

if not mainline:
    return True
prev = mainline[-1]
if prev.rank >= 9:
    return card.color != prev.color
return card.color == prev.color


face prev -> same suit; otherwise rank within 3

if not mainline:
    return True
prev = mainline[-1]
if prev.is_face:
    return card.suit == prev.suit
return abs(card.rank - prev.rank) <= 3


high prev -> higher rank; otherwise same suit

if not mainline:
    return True
prev = mainline[-1]
if prev.rank >= 9:
    return card.rank > prev.rank
return card.suit == prev.suit


red -> different color; otherwise opposite parity

if not mainline:
    return True
prev = mainline[-1]
if prev.color == "red":
    return card.color != prev.color
return card.rank % 2 != prev.rank % 2


high prev -> same parity; otherwise decreasing

if not mainline:
    return True
prev = mainline[-1]
if prev.rank >= 9:
    return card.rank % 2 == prev.rank % 2
return card.rank < prev.rank


even prev -> same suit; otherwise rank within 1

if not mainline:
    return True
prev = mainline[-1]
if prev.rank % 2 == 0:
    return card.suit == prev.suit
return abs(card.rank - prev.rank) <= 1


high prev -> different color; otherwise rank within 4

if not mainline:
    return True
prev = mainline[-1]
if prev.rank >= 9:
    return card.color != prev.color
return abs(card.rank - prev.rank) <= 4


high prev -> nondecreasing; otherwise rank within 3

if not mainline:
    return True
prev = mainline[-1]
if prev.rank >= 9:
    return card.rank >= prev.rank
return abs(card.rank - prev.rank) <= 3


red -> rank within 3; otherwise rank within 2

if not mainline:
    return True
prev = mainline[-1]
if prev.color == "red":
    return abs(card.rank - prev.rank) <= 3
return abs(card.rank - prev.rank) <= 2


high prev -> higher rank; otherwise same parity

if not mainline:
    return True
prev = mainline[-1]
if prev.rank >= 9:
    return card.rank > prev.rank
return card.rank % 2 == prev.rank % 2


red -> rank within 2; otherwise rank within 6

if not mainline:
    return True
prev = mainline[-1]
if prev.color == "red":
    return abs(card.rank - prev.rank) <= 2
return abs(card.rank - prev.rank) <= 6


high prev -> same suit; otherwise different color

if not mainline:
    return True
prev = mainline[-1]
if prev.rank >= 9:
    return card.suit == prev.suit
return card.color != prev.color


face prev -> rank within 4; otherwise different suit

if not mainline:
    return True
prev = mainline[-1]
if prev.is_face:
    return abs(card.rank - prev.rank) <= 4
return card.suit != prev.suit


face prev -> rank within 6; otherwise same suit

if not mainline:
    return True
prev = mainline[-1]
if prev.is_face:
    return abs(card.rank - prev.rank) <= 6
return card.suit == prev.suit


high prev -> rank within 3; otherwise opposite parity

if not mainline:
    return True
prev = mainline[-1]
if prev.rank >= 9:
    return abs(card.rank - prev.rank) <= 3
return card.rank % 2 != prev.rank % 2


even prev -> rank within 5; otherwise nondecreasing

if not mainline:
    return True
prev = mainline[-1]
if prev.rank % 2 == 0:
    return abs(card.rank - prev.rank) <= 5
return card.rank >= prev.rank


red -> decreasing; otherwise rank within 6

if not mainline:
    return True
prev = mainline[-1]
if prev.color == "red":
    return card.rank < prev.rank
return abs(card.rank - prev.rank) <= 6


high prev -> rank within 2; otherwise same suit

if not mainline:
    return True
prev = mainline[-1]
if prev.rank >= 9:
    return abs(card.rank - prev.rank) <= 2
return card.suit == prev.suit


high prev -> rank within 6; otherwise rank within 5

if not mainline:
    return True
prev = mainline[-1]
if prev.rank >= 9:
    return abs(card.rank - prev.rank) <= 6
return abs(card.rank - prev.rank) <= 5


face prev -> higher rank; otherwise rank within 5

if not mainline:
    return True
prev = mainline[-1]
if prev.is_face:
    return card.rank > prev.rank
return abs(card.rank - prev.rank) <= 5


face prev -> higher rank; otherwise decreasing

if not mainline:
    return True
prev = mainline[-1]
if prev.is_face:
    return card.rank > prev.rank
return card.rank < prev.rank


even prev -> rank within 1; otherwise rank within 2

if not mainline:
    return True
prev = mainline[-1]
if prev.rank % 2 == 0:
    return abs(card.rank - prev.rank) <= 1
return abs(card.rank - prev.rank) <= 2


even prev -> rank within 4; otherwise rank within 5

if not mainline:
    return True
prev = mainline[-1]
if prev.rank % 2 == 0:
    return abs(card.rank - prev.rank) <= 4
return abs(card.rank - prev.rank) <= 5


even prev -> nondecreasing; otherwise same parity

if not mainline:
    return True
prev = mainline[-1]
if prev.rank % 2 == 0:
    return card.rank >= prev.rank
return card.rank % 2 == prev.rank % 2


face prev -> opposite parity; otherwise decreasing

if not mainline:
    return True
prev = mainline[-1]
if prev.is_face:
    return card.rank % 2 != prev.rank % 2
return card.rank < prev.rank


red -> different color; otherwise same color

if not mainline:
    return True
prev = mainline[-1]
if prev.color == "red":
    return card.color != prev.color
return card.color == prev.color


face prev -> decreasing; otherwise different suit

if not mainline:
    return True
prev = mainline[-1]
if prev.is_face:
    return card.rank < prev.rank
return card.suit != prev.suit


red -> rank within 2; otherwise decreasing

if not mainline:
    return True
prev = mainline[-1]
if prev.color == "red":
    return abs(card.rank - prev.rank) <= 2
return card.rank < prev.rank


even prev -> different suit; otherwise rank within 6

if not mainline:
    return True
prev = mainline[-1]
if prev.rank % 2 == 0:
    return card.suit != prev.suit
return abs(card.rank - prev.rank) <= 6


red -> nondecreasing; otherwise rank within 3

if not mainline:
    return True
prev = mainline[-1]
if prev.color == "red":
    return card.rank >= prev.rank
return abs(card.rank - prev.rank) <= 3


high prev -> nondecreasing; otherwise rank within 1

if not mainline:
    return True
prev = mainline[-1]
if prev.rank >= 9:
    return card.rank >= prev.rank
return abs(card.rank - prev.rank) <= 1


face prev -> different suit; otherwise same parity

if not mainline:
    return True
prev = mainline[-1]
if prev.is_face:
    return card.suit != prev.suit
return card.rank % 2 == prev.rank % 2


red -> same color; otherwise nondecreasing

if not mainline:
    return True
prev = mainline[-1]
if prev.color == "red":
    return card.color == prev.color
return card.rank >= prev.rank


red -> same suit; otherwise nondecreasing

if not mainline:
    return True
prev = mainline[-1]
if prev.color == "red":
    return card.suit == prev.suit
return card.rank >= prev.rank


face prev -> rank within 5; otherwise decreasing

if not mainline:
    return True
prev = mainline[-1]
if prev.is_face:
    return abs(card.rank - prev.rank) <= 5
return card.rank < prev.rank


high prev -> decreasing; otherwise same color

if not mainline:
    return True
prev = mainline[-1]
if prev.rank >= 9:
    return card.rank < prev.rank
return card.color == prev.color


even prev -> rank within 4; otherwise different color

if not mainline:
    return True
prev = mainline[-1]
if prev.rank % 2 == 0:
    return abs(card.rank - prev.rank) <= 4
return card.color != prev.color


high prev -> rank within 2; otherwise rank within 5

if not mainline:
    return True
prev = mainline[-1]
if prev.rank >= 9:
    return abs(card.rank - prev.rank) <= 2
return abs(card.rank - prev.rank) <= 5


face prev -> rank within 5; otherwise same suit

if not mainline:
    return True
prev = mainline[-1]
if prev.is_face:
    return abs(card.rank - prev.rank) <= 5
return card.suit == prev.suit


high prev -> same color; otherwise different color

if not mainline:
    return True
prev = mainline[-1]
if prev.rank >= 9:
    return card.color == prev.color
return card.color != prev.color


face prev -> nondecreasing; otherwise rank within 2

if not mainline:
    return True
prev = mainline[-1]
if prev.is_face:
    return card.rank >= prev.rank
return abs(card.rank - prev.rank) <= 2


even prev -> rank within 4; otherwise rank within 1

if not mainline:
    return True
prev = mainline[-1]
if prev.rank % 2 == 0:
    return abs(card.rank - prev.rank) <= 4
return abs(card.rank - prev.rank) <= 1


even prev -> rank within 2; otherwise same parity

if not mainline:
    return True
prev = mainline[-1]
if prev.rank % 2 == 0:
    return abs(card.rank - prev.rank) <= 2
return card.rank % 2 == prev.rank % 2


even prev -> higher rank; otherwise rank within 6

if not mainline:
    return True
prev = mainline[-1]
if prev.rank % 2 == 0:
    return card.rank > prev.rank
return abs(card.rank - prev.rank) <= 6


red -> higher rank; otherwise different suit

if not mainline:
    return True
prev = mainline[-1]
if prev.color == "red":
    return card.rank > prev.rank
return card.suit != prev.suit


high prev -> rank within 4; otherwise decreasing

if not mainline:
    return True
prev = mainline[-1]
if prev.rank >= 9:
    return abs(card.rank - prev.rank) <= 4
return card.rank < prev.rank


even prev -> different color; otherwise rank within 5

if not mainline:
    return True
prev = mainline[-1]
if prev.rank % 2 == 0:
    return card.color != prev.color
return abs(card.rank - prev.rank) <= 5


face prev -> opposite parity; otherwise rank within 4

if not mainline:
    return True
prev = mainline[-1]
if prev.is_face:
    return card.rank % 2 != prev.rank % 2
return abs(card.rank - prev.rank) <= 4


face prev -> different suit; otherwise opposite parity

if not mainline:
    return True
prev = mainline[-1]
if prev.is_face:
    return card.suit != prev.suit
return card.rank % 2 != prev.rank % 2


if not mainline:
    return True
prev = mainline[-1]
return card.color == prev.color or abs(card.rank - prev.rank) <= 8


different color and rank distance at most 8

if not mainline:
    return True
prev = mainline[-1]
return card.color != prev.color and abs(card.rank - prev.rank) <= 8


if not mainline:
    return True
prev = mainline[-1]
return abs(card.rank - prev.rank) <= 6 or card.rank % 2 == prev.rank % 2


if not mainline:
    return True
prev = mainline[-1]
return card.color == prev.color or abs(card.rank - prev.rank) <= 3


different color and rank distance at most 7

if not mainline:
    return True
prev = mainline[-1]
return card.color != prev.color and abs(card.rank - prev.rank) <= 7


different color and rank distance at most 10

if not mainline:
    return True
prev = mainline[-1]
return card.color != prev.color and abs(card.rank - prev.rank) <= 10


different color and rank distance at most 9

if not mainline:
    return True
prev = mainline[-1]
return card.color != prev.color and abs(card.rank - prev.rank) <= 9


different color and rank distance at most 12

if not mainline:
    return True
prev = mainline[-1]
return card.color != prev.color and abs(card.rank - prev.rank) <= 12


if not mainline:
    return True
prev = mainline[-1]
return card.color == prev.color or abs(card.rank - prev.rank) <= 5


if not mainline:
    return True
prev = mainline[-1]
return card.color == prev.color or abs(card.rank - prev.rank) <= 7


different color and rank distance at most 11

if not mainline:
    return True
prev = mainline[-1]
return card.color != prev.color and abs(card.rank - prev.rank) <= 11


if not mainline:
    return True
prev = mainline[-1]
return card.color == prev.color or abs(card.rank - prev.rank) <= 4


different color and rank distance at most 6

if not mainline:
    return True
prev = mainline[-1]
return card.color != prev.color and abs(card.rank - prev.rank) <= 6


red when accepted count is 0 modulo 6, black otherwise

if not mainline:
    return True
return (card.color == "red") == (len(mainline) % 6 == 0)


candidate color unseen on the whole mainline

if not mainline:
    return True
return all(card.color != item.color for item in mainline)


red when accepted count is 0 modulo 4, black otherwise

if not mainline:
    return True
return (card.color == "red") == (len(mainline) % 4 == 0)


red when accepted count is 2 modulo 6, black otherwise

if not mainline:
    return True
return (card.color == "red") == (len(mainline) % 6 == 2)


red when accepted count is 4 modulo 6, black otherwise

if not mainline:
    return True
return (card.color == "red") == (len(mainline) % 6 == 4)


red when accepted count is 4 modulo 5, black otherwise

if not mainline:
    return True
return (card.color == "red") == (len(mainline) % 5 == 4)


red when accepted count is 5 modulo 6, black otherwise

if not mainline:
    return True
return (card.color == "red") == (len(mainline) % 6 == 5)


red when accepted count is 0 modulo 3, black otherwise

if not mainline:
    return True
return (card.color == "red") == (len(mainline) % 3 == 0)


red when accepted count is 2 modulo 5, black otherwise

if not mainline:
    return True
return (card.color == "red") == (len(mainline) % 5 == 2)


red when accepted count is 3 modulo 5, black otherwise

if not mainline:
    return True
return (card.color == "red") == (len(mainline) % 5 == 3)


red when accepted count is 1 modulo 5, black otherwise

if not mainline:
    return True
return (card.color == "red") == (len(mainline) % 5 == 1)


red when accepted count is 2 modulo 3, black otherwise

if not mainline:
    return True
return (card.color == "red") == (len(mainline) % 3 == 2)


red when accepted count is 0 modulo 5, black otherwise

if not mainline:
    return True
return (card.color == "red") == (len(mainline) % 5 == 0)


accepted-position color pattern RRBRRBR (period 7)

if not mainline:
    return True
pattern = ['red', 'red', 'black', 'red', 'red', 'black', 'red']
return card.color == pattern[len(mainline) % 7]


accepted-position color pattern RBBBBRBRBB (period 10)

if not mainline:
    return True
pattern = ['red', 'black', 'black', 'black', 'black', 'red', 'black', 'red', 'black', 'black']
return card.color == pattern[len(mainline) % 10]


accepted-position color pattern BRBRBRRBRB (period 10)

if not mainline:
    return True
pattern = ['black', 'red', 'black', 'red', 'black', 'red', 'red', 'black', 'red', 'black']
return card.color == pattern[len(mainline) % 10]


accepted-position color pattern BRBBBB (period 6)

if not mainline:
    return True
pattern = ['black', 'red', 'black', 'black', 'black', 'black']
return card.color == pattern[len(mainline) % 6]


accepted-position color pattern RBRRBB (period 6)

if not mainline:
    return True
pattern = ['red', 'black', 'red', 'red', 'black', 'black']
return card.color == pattern[len(mainline) % 6]


accepted-position color pattern RRRBRBB (period 7)

if not mainline:
    return True
pattern = ['red', 'red', 'red', 'black', 'red', 'black', 'black']
return card.color == pattern[len(mainline) % 7]


accepted-position color pattern RRRRBBB (period 7)

if not mainline:
    return True
pattern = ['red', 'red', 'red', 'red', 'black', 'black', 'black']
return card.color == pattern[len(mainline) % 7]


accepted-position color pattern RBBRRRRRB (period 9)

if not mainline:
    return True
pattern = ['red', 'black', 'black', 'red', 'red', 'red', 'red', 'red', 'black']
return card.color == pattern[len(mainline) % 9]


accepted-position color pattern RBRRRBRRBR (period 10)

if not mainline:
    return True
pattern = ['red', 'black', 'red', 'red', 'red', 'black', 'red', 'red', 'black', 'red']
return card.color == pattern[len(mainline) % 10]


accepted-position color pattern RRBBBBRBR (period 9)

if not mainline:
    return True
pattern = ['red', 'red', 'black', 'black', 'black', 'black', 'red', 'black', 'red']
return card.color == pattern[len(mainline) % 9]


accepted-position color pattern RBRRBRRRR (period 9)

if not mainline:
    return True
pattern = ['red', 'black', 'red', 'red', 'black', 'red', 'red', 'red', 'red']
return card.color == pattern[len(mainline) % 9]


accepted-position color pattern RRRRB (period 5)

if not mainline:
    return True
pattern = ['red', 'red', 'red', 'red', 'black']
return card.color == pattern[len(mainline) % 5]


accepted-position color pattern BRBBRBRRR (period 9)

if not mainline:
    return True
pattern = ['black', 'red', 'black', 'black', 'red', 'black', 'red', 'red', 'red']
return card.color == pattern[len(mainline) % 9]


accepted-position color pattern BBRRR (period 5)

if not mainline:
    return True
pattern = ['black', 'black', 'red', 'red', 'red']
return card.color == pattern[len(mainline) % 5]


accepted-position color pattern BRBRRBBB (period 8)

if not mainline:
    return True
pattern = ['black', 'red', 'black', 'red', 'red', 'black', 'black', 'black']
return card.color == pattern[len(mainline) % 8]


accepted-position color pattern BBBRBB (period 6)

if not mainline:
    return True
pattern = ['black', 'black', 'black', 'red', 'black', 'black']
return card.color == pattern[len(mainline) % 6]


accepted-position color pattern BBRRRBBBR (period 9)

if not mainline:
    return True
pattern = ['black', 'black', 'red', 'red', 'red', 'black', 'black', 'black', 'red']
return card.color == pattern[len(mainline) % 9]


accepted-position color pattern RRBRRBB (period 7)

if not mainline:
    return True
pattern = ['red', 'red', 'black', 'red', 'red', 'black', 'black']
return card.color == pattern[len(mainline) % 7]


accepted-position color pattern BBBRBRBRRR (period 10)

if not mainline:
    return True
pattern = ['black', 'black', 'black', 'red', 'black', 'red', 'black', 'red', 'red', 'red']
return card.color == pattern[len(mainline) % 10]


accepted-position color pattern BBBRBBRB (period 8)

if not mainline:
    return True
pattern = ['black', 'black', 'black', 'red', 'black', 'black', 'red', 'black']
return card.color == pattern[len(mainline) % 8]


accepted-position color pattern RRRRRBBBR (period 9)

if not mainline:
    return True
pattern = ['red', 'red', 'red', 'red', 'red', 'black', 'black', 'black', 'red']
return card.color == pattern[len(mainline) % 9]


accepted-position color pattern RBBRRRRB (period 8)

if not mainline:
    return True
pattern = ['red', 'black', 'black', 'red', 'red', 'red', 'red', 'black']
return card.color == pattern[len(mainline) % 8]


accepted-position color pattern BBRRB (period 5)

if not mainline:
    return True
pattern = ['black', 'black', 'red', 'red', 'black']
return card.color == pattern[len(mainline) % 5]


accepted-position color pattern RRRRBB (period 6)

if not mainline:
    return True
pattern = ['red', 'red', 'red', 'red', 'black', 'black']
return card.color == pattern[len(mainline) % 6]


accepted-position color pattern RBBRRBB (period 7)

if not mainline:
    return True
pattern = ['red', 'black', 'black', 'red', 'red', 'black', 'black']
return card.color == pattern[len(mainline) % 7]


accepted-position color pattern BBBBBBBBRB (period 10)

if not mainline:
    return True
pattern = ['black', 'black', 'black', 'black', 'black', 'black', 'black', 'black', 'red', 'black']
return card.color == pattern[len(mainline) % 10]


accepted-position color pattern RRRRBRBBBB (period 10)

if not mainline:
    return True
pattern = ['red', 'red', 'red', 'red', 'black', 'red', 'black', 'black', 'black', 'black']
return card.color == pattern[len(mainline) % 10]


accepted-position color pattern RBBRRBRR (period 8)

if not mainline:
    return True
pattern = ['red', 'black', 'black', 'red', 'red', 'black', 'red', 'red']
return card.color == pattern[len(mainline) % 8]


accepted-position color pattern RBRBBB (period 6)

if not mainline:
    return True
pattern = ['red', 'black', 'red', 'black', 'black', 'black']
return card.color == pattern[len(mainline) % 6]


return card.is_face or 10 <= card.rank <= 12


face cards and rank at most 12; number cards above 12

return card.is_face if card.rank <= 12 else card.rank > 12 and not card.is_face


return card.is_face or 9 <= card.rank <= 11


face cards and rank at most 11; number cards above 11

return card.is_face if card.rank <= 11 else card.rank > 11 and not card.is_face


face cards and rank at most 9; number cards above 9

return card.is_face if card.rank <= 9 else card.rank > 9 and not card.is_face


return card.is_face or 8 <= card.rank <= 10


return 2 <= card.rank <= 5 or 10 <= card.rank <= 13


return 2 <= card.rank <= 5 or 8 <= card.rank <= 11


return card.suit == "spades" and card.rank >= 5


return card.rank in [2, 3, 5, 6, 7, 8, 9]


return card.suit == "hearts" and card.rank >= 9


return card.rank % 2 == 0 and 4 <= card.rank <= 8


return 1 <= card.rank <= 4 or 10 <= card.rank <= 13


return 1 <= card.rank <= 5 or 8 <= card.rank <= 11


return card.rank in [1, 2, 4, 5, 6, 7, 8]


return card.rank in [2, 3, 4, 6, 7, 8, 9]


return 2 <= card.rank <= 5 or 8 <= card.rank <= 13


return 1 <= card.rank <= 5 or 8 <= card.rank <= 13


return card.rank in [1, 2, 3, 5, 6, 7, 8]


return card.rank in [6, 7, 8, 9, 11, 12]


return card.rank % 2 == 1 and 2 <= card.rank <= 6


return card.suit == "spades" and card.rank >= 9


return 2 <= card.rank <= 5 or 9 <= card.rank <= 13


return card.suit == "diamonds" and card.rank >= 7


return card.rank in [2, 3, 4, 5, 7, 8, 9]


return card.suit == "clubs" and card.rank >= 7


return card.rank % 2 == 1 and 8 <= card.rank <= 12


return card.rank in [1, 2, 3, 4, 5, 7, 8]


return card.suit == "hearts" and card.rank >= 7


return card.suit == "clubs" and card.rank >= 5


return card.suit == "diamonds" and card.rank >= 5


return card.rank % 2 == 0 and 3 <= card.rank <= 7


return card.rank in [6, 7, 8, 9, 10, 12]


return 1 <= card.rank <= 4 or 8 <= card.rank <= 13


return 1 <= card.rank <= 5 or 10 <= card.rank <= 13


return 2 <= card.rank <= 6 or 9 <= card.rank <= 13


return card.rank in [5, 6, 7, 8, 10, 11]


return card.rank % 2 == 0 and 7 <= card.rank <= 11


return card.rank % 2 == 1 and 6 <= card.rank <= 10


return card.rank in [1, 3, 4, 5, 6, 7, 8]


return card.rank % 2 == 0 and 5 <= card.rank <= 9


return card.rank % 2 == 1 and 5 <= card.rank <= 9


return card.suit == "clubs" and card.rank >= 9


return card.rank % 2 == 0 and 6 <= card.rank <= 10


return card.suit == "spades" and card.rank >= 7


return 2 <= card.rank <= 6 or 10 <= card.rank <= 13


return card.rank % 2 == 1 and 3 <= card.rank <= 7


return card.rank in [5, 6, 8, 9, 10, 11]


return card.rank in [5, 6, 7, 9, 10, 11]


return card.rank in [1, 2, 3, 4, 6, 7, 8]


return card.suit == "diamonds" and card.rank >= 9


return card.rank in [2, 3, 4, 5, 6, 7, 9]


return 1 <= card.rank <= 5 or 9 <= card.rank <= 13


return card.rank % 2 == 1 and 7 <= card.rank <= 11


return card.rank % 2 == 0 and 2 <= card.rank <= 6


return 1 <= card.rank <= 4 or 8 <= card.rank <= 11


return card.rank % 2 == 0 and 8 <= card.rank <= 12


return card.rank in [1, 2, 3, 4, 5, 6, 8]


return card.rank in [2, 4, 5, 6, 7, 8, 9]


return card.rank in [5, 7, 8, 9, 10, 11]


return card.rank % 2 == 1 and 4 <= card.rank <= 8


return 1 <= card.rank <= 4 or 9 <= card.rank <= 13


return card.suit == "hearts" and card.rank >= 5


return card.color == "black" and card.rank >= 10


return card.color == "black" and card.rank <= 7


return card.color == "red" and card.rank >= 11


if card.color == "red":
    return card.rank % 2 == 1
return card.rank % 2 == 0


colors appear in pairs and each pair changes color

if not mainline:
    return True
if len(mainline) % 2 == 0:
    return card.color != mainline[-1].color
return card.color == mainline[-1].color


rank parity appears in pairs and each pair changes parity

if not mainline:
    return True
if len(mainline) % 2 == 0:
    return (card.rank % 2) != (mainline[-1].rank % 2)
return (card.rank % 2) == (mainline[-1].rank % 2)


if not mainline:
    return True
if len(mainline) % 2 == 0:
    return card.rank == mainline[-1].rank
return card.rank != mainline[-1].rank


if not mainline:
    return True
if len(mainline) % 2 == 0:
    return card.suit == mainline[-1].suit
return card.suit != mainline[-1].suit


return card.color == "black" and card.rank % 2 == 0


return card.rank % 2 == 0 or card.rank == 13


return card.color == "red" and card.rank % 2 == 0


primes = {2, 3, 5, 7, 11, 13}
return card.rank not in primes


alternate low and high vs previous (threshold ten)

if not mainline:
    return True
return (card.rank >= 10) != (mainline[-1].rank >= 10)


different low/high rank group than previous card

if not mainline:
    return True
return (card.rank >= 8) != (mainline[-1].rank >= 8)


alternate low and mid-high vs previous (threshold five)

if not mainline:
    return True
return (card.rank >= 5) != (mainline[-1].rank >= 5)


alternate between hearts+clubs and diamonds+spades

if not mainline:
    return True
group_a = {"hearts", "clubs"}
return (card.suit in group_a) != (mainline[-1].suit in group_a)


if not mainline:
    return True
return card.rank <= mainline[-1].rank


if not mainline:
    return True
return abs(card.rank - mainline[-1].rank) >= 3


if not mainline:
    return True
return abs(card.rank - mainline[-1].rank) <= 2


if not mainline:
    return True
return abs(card.rank - mainline[-1].rank) == 1


red previous goes down, black previous goes up

if not mainline:
    return 5 <= card.rank <= 9
prev = mainline[-1]
if prev.color == "red":
    return card.rank <= prev.rank
return card.rank >= prev.rank


if not mainline:
    return True
return card.color == mainline[-1].color


same face/number status as previous card

if not mainline:
    return True
return (card.rank >= 11) == (mainline[-1].rank >= 11)


same low/high rank group as previous card

if not mainline:
    return True
return (card.rank >= 8) == (mainline[-1].rank >= 8)


if not mainline:
    return True
return (card.rank % 2) == (mainline[-1].rank % 2)


if not mainline:
    return True
return card.rank == mainline[-1].rank


if not mainline:
    return True
return card.suit == mainline[-1].suit


same suit or same rank parity as previous card

if not mainline:
    return True
prev = mainline[-1]
return card.suit == prev.suit or (card.rank % 2) == (prev.rank % 2)


if not mainline:
    return True
return card.rank > mainline[-1].rank


suits cycle diamonds, clubs, hearts, spades

if not mainline:
    return True
order = ["diamonds", "clubs", "hearts", "spades"]
idx = order.index(mainline[-1].suit)
return card.suit == order[(idx + 1) % 4]


return card.suit in {"hearts", "spades"}