more utilities
This commit is contained in:
parent
e61f550abb
commit
219d05dc06
|
@ -58,8 +58,62 @@
|
|||
~ temp x = lastcard(list)
|
||||
~ return is_clubs(x) || is_spades(x)
|
||||
|
||||
=== function can_move_to_full(ref x)
|
||||
~ temp x = lastcard(list)
|
||||
{is_spades(x):
|
||||
~ temp y = lastcard(full1)
|
||||
=== function tonumber(x)
|
||||
{
|
||||
- is_two(x):
|
||||
~ return 2
|
||||
- is_three(x):
|
||||
~ return 3
|
||||
- is_four(x):
|
||||
~ return 4
|
||||
- is_five(x):
|
||||
~ return 5
|
||||
- is_six(x):
|
||||
~ return 6
|
||||
- is_seven(x):
|
||||
~ return 7
|
||||
- is_eight(x):
|
||||
~ return 8
|
||||
- is_nine(x):
|
||||
~ return 9
|
||||
- is_ten(x):
|
||||
~ return 10
|
||||
- is_jack(x):
|
||||
~ return 11
|
||||
- is_queen(x):
|
||||
~ return 12
|
||||
- is_king(x):
|
||||
~ return 13
|
||||
- is_ace(x):
|
||||
~ return 14
|
||||
- else:
|
||||
~ return 0
|
||||
}
|
||||
|
||||
=== function biggerthan(x, y)
|
||||
~ return tonumber(x) > tonumber(y)
|
||||
|
||||
=== function follows(x, y)
|
||||
~ return tonumber(x) - tonumber(y) == -1
|
||||
|
||||
=== function adjacent(x, y)
|
||||
{ biggerthan(x,y):
|
||||
~ return follows(y,x)
|
||||
- else:
|
||||
~ return follows(x,y)
|
||||
}
|
||||
|
||||
=== function can_move_to_full(ref col)
|
||||
~ temp x = lastcard(col)
|
||||
~ temp y = ""
|
||||
{
|
||||
- is_spades(x):
|
||||
~ y = lastcard(full1)
|
||||
- is_diamonds(x):
|
||||
~ y = lastcard(full2)
|
||||
- is_clubs(x):
|
||||
~ y = lastcard(full3)
|
||||
- is_hearts(x):
|
||||
~ y = lastcard(full4)
|
||||
}
|
||||
~ return follows(x,y)
|
||||
|
|
Loading…
Reference in a new issue