nnfc

No-nonsense FreeCell game
git clone git://git.luxferre.top/nnfc.git
Log | Files | Refs

commit 4401ed7dde997733bc4ccfba18b860b775e74df1
parent 9ec944946c613844f6bd82a30d45c74f15d85012
Author: Luxferre <lux@ferre>
Date:   Thu, 18 Jan 2024 11:56:30 +0200

Fixed column movement

Diffstat:
Mnnfc.awk | 27+++++++++++++++------------
1 file changed, 15 insertions(+), 12 deletions(-)

diff --git a/nnfc.awk b/nnfc.awk @@ -190,22 +190,25 @@ function domove(cmd, isauto, valid, nums, from, to, amt, i, si, ec, efc) { efc = 0 # reuse for starting index in source tableau if(from < 9) efc = tablens[rfrom] - amt if(efc > -1) { # check if we aren't moving more cards than allowed - for(i=0;i<amt;i++) { # move the cards as usual - if(from < 9) { # re-read the source value if looping over a column - cval = table[rfrom, efc+i] - if(cval == "") break # we try to read more than is available - else cval = int(cval) - } - si = table[rto,tablens[rto]-1] # target value - if(stackcond(si, cval) || length(si) == 0) { - table[rto,tablens[rto]] = cval # copy the card there - tablens[rto]++ # increase tableau length + if(from < 9) { # re-read the source value if looping over a column + cval = table[rfrom, efc] # checking the first stack value + if(cval == "") cval = -1 # we try to read more than is available + else cval = int(cval) + } + si = table[rto,tablens[rto]-1] # target value + if(cval > -1 && (stackcond(si, cval) || tablens[rto] == 0)) { + for(i=0;i<amt;i++) { # move the cards directly if(from < 9) { # moving from a tableau + table[rto,tablens[rto]] = table[rfrom,efc+i] # copy the card there delete table[rfrom,efc+i] # delete the card tablens[rfrom]-- # decrease tableau length - } else fcell[from - 9] = -1 # moving from a free cell + } else { # moving from a free cell + table[rto,tablens[rto]] = fcell[from - 9] # copy the card there + fcell[from - 9] = -1 + } + tablens[rto]++ # increase tableau length valid = 1 # mark the move as valid - } else break + } } } } else if(fcell[to - 9] == -1) { # moving to a free cell