소스 검색

add two vs bot

master
flavis 4 년 전
부모
커밋
444e50cdb1
1개의 변경된 파일23개의 추가작업 그리고 2개의 파일을 삭제
  1. +23
    -2
      src/Skat/Matches.hs

+ 23
- 2
src/Skat/Matches.hs 파일 보기

@@ -1,11 +1,11 @@
module Skat.Matches (
singleVsBots, pvp, singleWithBidding, Match(..), Unfinished(..), continue,
Table(..)
Table(..), twoWithBidding, H(..), randomPositions
) where

import Control.Monad.State
import Control.Monad.Reader
import System.Random (mkStdGen)
import System.Random (mkStdGen, newStdGen)

import Skat
import Skat.Operations
@@ -14,6 +14,7 @@ import Skat.Pile
import Skat.Card
import Skat.Preperation
import Skat.Bidding
import Skat.Utils (shuffle)

import Skat.AI.Rulebased
import Skat.AI.Online
@@ -122,6 +123,26 @@ singleWithBidding comm = do
env = makePrep ps bs
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 comm1 comm2 comm3 = do
cards <- shuffleCards


불러오는 중...
취소
저장