<commit_before>{-# LANGUAGE ViewPatterns, TypeFamilies, DefaultSignatures, FlexibleContexts, FlexibleInstances #-} 

module BreakthroughGame where

import GenericGame

import qualified Data.HashMap as HashMap
import qualified Data.HashSet as HashSet
import Data.HashMap (Map)
import Data.HashSet (Set)
import Data.Monoid (mempty, mappend)
import Data.Maybe

type Position = (Int,Int) -- ^ (x,y), x=column goes from 0 to width-1, y=row goes from 0 to height-1
type BoardMap = Map Position Player2

data Breakthrough = Breakthrough { board :: BoardMap -- ^ map from position to P1 or P2 piece.
                                 , boardSize :: (Int,Int) -- ^ width, height. height >= 4, width >= 2. each player will be given exactly 2*width pieces. there are 'width' many columns and 'height' many rows.
                                 , winningP1 :: Set Position -- ^ fixed set of winning positions for P1
                                 , winningP2 :: Set Position -- ^ fixed set of winning positions for P2
                                 , countP1 :: !Int -- ^ how many pieces P1 have
                                 , countP2 :: !Int -- ^ how many pieces P2 have
                                 } deriving (Show, Eq, Read)

instance GameTxtRender Breakthrough where
    prettyPrintGame g = let -- ll = "---------------------------" 
                            rl = fst (boardSize g)
                            charPos pos = case HashMap.lookup pos (board g) of
                                            Nothing -> '.'
                                            Just P1 -> '1'
                                            Just P2 -> '2'
                            pprow n = "| " ++ map charPos (row n rl) ++ " |"

                            bareBoard = map pprow [0..(snd (boardSize g))-1]
                        in
                          unlines bareBoard
                          
--                         unlines ( 
--                         [ll
--                         ,show g
--                         ,ll] ++
--                         bareBoard<commit_msg>use funny unicode symbols for pretty printing Breakthrough<commit_after>{-# LANGUAGE ViewPatterns, TypeFamilies, DefaultSignatures, FlexibleContexts, FlexibleInstances #-} 

module BreakthroughGame where

import GenericGame

import qualified Data.HashMap as HashMap
import qualified Data.HashSet as HashSet
import Data.HashMap (Map)
import Data.HashSet (Set)
import Data.Monoid (mempty, mappend)
import Data.Maybe

type Position = (Int,Int) -- ^ (x,y), x=column goes from 0 to width-1, y=row goes from 0 to height-1
type BoardMap = Map Position Player2

data Breakthrough = Breakthrough { board :: BoardMap -- ^ map from position to P1 or P2 piece.
                                 , boardSize :: (Int,Int) -- ^ width, height. height >= 4, width >= 2. each player will be given exactly 2*width pieces. there are 'width' many columns and 'height' many rows.
                                 , winningP1 :: Set Position -- ^ fixed set of winning positions for P1
                                 , winningP2 :: Set Position -- ^ fixed set of winning positions for P2
                                 , countP1 :: !Int -- ^ how many pieces P1 have
                                 , countP2 :: !Int -- ^ how many pieces P2 have
                                 } deriving (Show, Eq, Read)

instance GameTxtRender Breakthrough where
    prettyPrintGame g = let -- ll = "---------------------------" 
                            rl = fst (boardSize g)
                            charPos pos = case HashMap.lookup pos (board g) of
                                            Nothing -> '☐'
                                            Just P1 -> '♙' 
                                            Just P2 -> '♟'
                            pprow n = "| " ++ map charPos (row n rl) ++ " |"

                            bareBoard = map pprow [0..(snd (boardSize g))-1]
                        in
                          unlines bareBoard
                          
--                         unlines ( 
--                         [ll
--                         ,show g
--                         ,ll] ++
--                         bareBoard
{'fraction_non_alphanumeric': 0.0948316737790422, 'fraction_numerical': 0.010905642484589853, 'mean_word_length': 1.1747422680412372, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 24, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3913774', 'n_tokens_mistral': 1012, 'n_tokens_neox': 972, 'n_words': 367}