even more baking ahead of time
This commit is contained in:
parent
6854b850fe
commit
3dd86d3c38
@ -25,8 +25,7 @@ move = do
|
||||
if topDiscA >= topDiscC
|
||||
then return Nothing
|
||||
else do
|
||||
popPegA
|
||||
pushPegC $ fromJust topDiscA
|
||||
pushPegC =<< popPegA
|
||||
Just <$> makeMove "a" "c"
|
||||
|
||||
{------------------------------------------------------------------------------}
|
||||
@ -106,10 +105,13 @@ makeMove from to = do
|
||||
putPegs pegs {pegsMoves = move' : pegsMoves pegs}
|
||||
return move'
|
||||
|
||||
popPegA :: (Monad m) => PegStep m ()
|
||||
popPegA :: (Monad m) => PegStep m Disc
|
||||
popPegA = do
|
||||
peg <- getPegA
|
||||
putPegA $ peg {pegDiscs = init $ pegDiscs peg}
|
||||
let disc = last $ pegDiscs peg
|
||||
rest = init $ pegDiscs peg
|
||||
putPegA $ peg {pegDiscs = rest}
|
||||
return disc
|
||||
|
||||
pushPegC :: (Monad m) => Disc -> PegStep m ()
|
||||
pushPegC disc = do
|
||||
|
Loading…
Reference in New Issue
Block a user