2 Commits
Author SHA1 Message Date
christian 0984a188db set stupid bidding to 0 2022-01-19 11:47:40 +01:00
christian 444e50cdb1 add two vs bot 2022-01-19 11:43:18 +01:00
2 changed files with 24 additions and 3 deletions
+1 -1
View File
@@ -29,7 +29,7 @@ newtype NoBidder = NoBidder Hand
-- | no bidding from that player -- | no bidding from that player
instance Bidder NoBidder where instance Bidder NoBidder where
hand (NoBidder h) = h hand (NoBidder h) = h
askBid _ _ bid = return $ Just 120 askBid _ _ bid = return Nothing
askResponse _ _ bid = if bid < 24 then return True else return False askResponse _ _ bid = if bid < 24 then return True else return False
askGame _ _ = return $ Grand Hand askGame _ _ = return $ Grand Hand
askHand _ _ = return True askHand _ _ = return True
+23 -2
View File
@@ -1,11 +1,11 @@
module Skat.Matches ( module Skat.Matches (
singleVsBots, pvp, singleWithBidding, Match(..), Unfinished(..), continue, singleVsBots, pvp, singleWithBidding, Match(..), Unfinished(..), continue,
Table(..) Table(..), twoWithBidding, H(..), randomPositions
) where ) where
import Control.Monad.State import Control.Monad.State
import Control.Monad.Reader import Control.Monad.Reader
import System.Random (mkStdGen) import System.Random (mkStdGen, newStdGen)
import Skat import Skat
import Skat.Operations import Skat.Operations
@@ -14,6 +14,7 @@ import Skat.Pile
import Skat.Card import Skat.Card
import Skat.Preperation import Skat.Preperation
import Skat.Bidding import Skat.Bidding
import Skat.Utils (shuffle)
import Skat.AI.Rulebased import Skat.AI.Rulebased
import Skat.AI.Online import Skat.AI.Online
@@ -122,6 +123,26 @@ singleWithBidding comm = do
env = makePrep ps bs env = makePrep ps bs
void $ match env void $ match env
--- helper object for twoWithBidding
data H = P1 | P2 | AI
randomPositions :: IO [H]
randomPositions = do
gen <- newStdGen
return $ shuffle gen [P1, P2, AI]
twoWithBidding :: Communicator c => [H] -> c -> c -> IO ()
twoWithBidding positions comm1 comm2 = do
cards <- shuffleCards
let bds = zipWith mkBidder [Hand1, Hand2, Hand3] positions
ps = distribute cards
mkBidder hand P1 = BD $ PrepOnline hand comm1 (map toCard $ handCards hand ps)
mkBidder hand P2 = BD $ PrepOnline hand comm2 (map toCard $ handCards hand ps)
mkBidder hand AI = BD $ NoBidder hand
bs = Bidders (bds !! 0) (bds !! 1) (bds !! 2)
env = makePrep ps bs
void $ match env
pvp :: Communicator c => c -> c -> c -> IO Table pvp :: Communicator c => c -> c -> c -> IO Table
pvp comm1 comm2 comm3 = do pvp comm1 comm2 comm3 = do
cards <- shuffleCards cards <- shuffleCards