Switched to a bit more standard notation

This commit is contained in:
Luxferre
2024-01-16 12:25:31 +02:00
parent 42bcb48ae4
commit 06d1ddbcf3
+16 -7
View File
@@ -1,10 +1,10 @@
# no-nonsense FreeCell in POSIX AWK # no-nonsense FreeCell in POSIX AWK
# run as: [n]awk -f nnfc.awk [-v ASCII=1] [-v MONOCHROME=1] [-v SEED=x] # run as: [n]awk -f nnfc.awk [-v ASCII=1] [-v MONOCHROME=1] [-v SEED=x]
# commands: q - quit, u - undo, # commands: q - quit, u - undo,
# [number] [number] - move from column/freecell to column/freecell/foundation: # [number][number] - move from column/freecell to column/freecell/foundation:
# - 0 is foundation (can be omitted) # - 0 is foundation (can be omitted)
# - 1 to 8 are column numbers # - 1 to 8 are column numbers
# - 9 to 12 are freecell numbers # - a, b, c, d are freecell numbers
# SEED variable can be used to init games M$-style # SEED variable can be used to init games M$-style
# no supermove support for now, need to move cards one at a time # no supermove support for now, need to move cards one at a time
# created by Luxferre in 2024, released into public domain # created by Luxferre in 2024, released into public domain
@@ -98,11 +98,20 @@ function domove(cmd, valid, nums, from, to, si) {
} }
valid = 0 # invalid by default until all checks are done valid = 0 # invalid by default until all checks are done
# if cmd is not q or one of the above, then it must be two numbers # if cmd is not q or one of the above, then it must be two numbers
# 1 to 8 is the column (tableau) number split(cmd, nums, "") # numbers must be space-separated
# 9 to 12 are free cell indices, 0 means foundation from = nums[1] # location from which we're moving
split(cmd, nums, " ") # numbers must be space-separated to = nums[2] # location to which we're moving
from = int(nums[1]) # location from which we're moving # identify free cells
to = int(nums[2]) # location to which we're moving if(from == "a") from = 9
if(from == "b") from = 10
if(from == "c") from = 11
if(from == "d") from = 12
if(to == "a") to = 9
if(to == "b") to = 10
if(to == "c") to = 11
if(to == "d") to = 12
from = int(from)
to = int(to)
rfrom = from - 1 # real from location rfrom = from - 1 # real from location
rto = to - 1 # real to location rto = to - 1 # real to location
if(from > 0 && from < 13 && to > -1 && to < 13) { # first check if(from > 0 && from < 13 && to > -1 && to < 13) { # first check