From ff9194d416e059db695c0354bb466e84fd992aac Mon Sep 17 00:00:00 2001 From: Tissevert Date: Sat, 18 Jan 2020 09:36:01 +0100 Subject: [PATCH] =?UTF-8?q?Follow=20=C2=ABCoordinates=C2=BB=20change=20in?= =?UTF-8?q?=20protocol?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/AI.hs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/AI.hs b/src/AI.hs index 3acd028..422c530 100644 --- a/src/AI.hs +++ b/src/AI.hs @@ -14,10 +14,11 @@ import Hanafuda ( ) import Hanafuda.KoiKoi (Move(..), PlayerID, Step(..)) import Hanafuda.Message (PublicGame(..), PublicState(..), PublicPlayer) +import qualified Hanafuda.Message as Message (Coordinates(..)) move :: PlayerID -> PublicGame -> Move -move me (PublicGame {playerHand, public = PublicState {step = ToPlay, month, players, river}}) = +move me (PublicGame {playerHand, public = PublicState {coordinates, step = ToPlay, players, river}}) = case getAvailableCards hand (cardsOfPack river) of [] -> Play $ worstFor month opponent hand available -> @@ -25,11 +26,14 @@ move me (PublicGame {playerHand, public = PublicState {step = ToPlay, month, pla let matchingCards = cardsOfPack . sameMonth riverCard $ playerHand in capture (bestFor month (players ! me) matchingCards) riverCard river where + month = Message.month $ coordinates hand = cardsOfPack playerHand opponent = snd . findMin $ delete me players -move me (PublicGame {public = PublicState {step = Turned card, month, players, river}}) = +move me (PublicGame {public = PublicState {coordinates, step = Turned card, players, river}}) = Choose . bestFor month (players ! me) . cardsOfPack $ sameMonth card river + where + month = Message.month $ coordinates move _ (PublicGame {playerHand, public = PublicState {step = Scored}}) = KoiKoi $ playerHand /= empty