<commit_before>module Main where

import System.IO
import Control.Monad
import Data.Graph
import Data.Default


type From = Int
type To = Int
type Qnt = Int
type Dest = Int

data Command = Move From To
             | Buy Qnt Dest
             | Wait
             deriving (Eq, Show)

type Zone = (Int,Gold)
type Drone = Int
type Gold = Int

data Player = Player{pid :: Int
                    ,zones :: [Zone]
                    ,gold :: Gold
                    ,drones :: [Drone]
                    }
              deriving (Eq, Show)

instance Default Player where
  def = Player (-1) [] 0 []

type Area = Tree Vertex

data GameState = GameState{turn :: Int
                          ,areas :: [Area]
                          ,allZones :: [Zone]
                          ,players :: [Player]
                          ,droneCost :: Int
                          ,myId :: Int
                          }
                 deriving (Eq, Show)

instance Default GameState where
  def = GameState 0 [] [] [] 0 (-1)

main :: IO ()
main = do
  hSetBuffering stdout NoBuffering -- DO NOT REMOVE
    
  -- Auto-generated code below aims at helping you parse
  -- the standard input according to the problem statement.
    
  input_line <- getLine
  hPutStrLn stderr input_line
  let input = words input_line
      playercount = read (input!!0) :: Int -- the amount of players (2 to 4)
      myid = read (input!!1) :: Int -- my player ID (0, 1, 2 or 3)
      zonecount = read (input!!2) :: Int -- the amount of zones on the map
      linkcount = read (input!!3) :: Int -- the amount of links between all zones

  
  zones <- replicateM zonecount $ do
    input_line <- getLine
    --hPutStrLn stderr input_line
    let input = words input_line
        zoneid = read (input!!0) :: Int -- this zone's ID (between 0 and zoneCount-1)
        platinumsource = read (input!!1) :: Int -- the amount of Platinum this zone can provide per game turn
    return (zoneid,platinumsource)
    
  edges <- replicateM linkcount $ do
    input_line <- getLine
    --hPutStrLn stderr input_line
    let input = words input_line
        zone1 = read (input!!0) :: Int
        zone2 = read (input!!1) :: Int
    return (zone1,zone2) --[(zone1, zone2),(zone2,zone1)]
  let field = buildG (0,zonecount-1) (edges)
--      areas = dff field
--  print (edges)
--  print areas
  putStrLn "Start game loop"
  loop def{areas=dff field, allZones=zones}

loop :: GameState -> IO ()
loop st = do
  let zonecount = length $ allZones st
  print zonecount
{--
  input_line <- getLine
  let platinum = read input_line :: Int -- my available Platinum
      zonecount = length $ areas st
  replicateM zonecount $ do
    input_line <- getLine
    let input = words input_line
        zid = read (input!!0) :: Int -- this zone's ID
        ownerid = read (input!!1) :: Int -- the player who owns this zone (-1 otherwise)
        podsp0 = read (input!!2) :: Int -- player 0's PODs on this zone
        podsp1 = read (input!!3) :: Int -- player 1's PODs on this zone
        podsp2 = read (input!!4) :: Int -- player 2's PODs on this zone (always 0 for a two player game)
        podsp3 = read (input!!5) :: Int -- player 3's PODs on this zone (always 0 for a two or three player game)
    return ()
    
    -- hPutStrLn stderr "Debug messages..."
    
    -- first line for movement commands, second line for POD purchase (see the protocol in the statement for details)
  putStrLn "WAIT"
  putStrLn "1 73"
--}    
  --loop st

g1 = buildG (0,153) [(21,28),(28,21)
                    ,(21,29),(29,21)
                    ,(21,22),(22,21)
                    ,(4,8),(8,4)
                    ,(4,9),(9,4)
                    ,(4,5),(5,4)<commit_msg>fts run:)<commit_after>module Main where

import System.IO
import Control.Monad
import Data.Graph


type From = Int
type To = Int
type Qnt = Int
type Dest = Int

data Command = Move From To
             | Buy Qnt Dest
             | Wait
             deriving (Eq, Show)

type Zone = (Int,Gold)
type Drone = Int
type Gold = Int

data Player = Player{pid :: Int
                    ,zones :: [Zone]
                    ,gold :: Gold
                    ,drones :: [Drone]
                    }
              deriving (Eq, Show)

type Area = Tree Vertex

data GameState = GameState{turn :: Int
                          ,areas :: [Area]
                          ,allZones :: [Zone]
                          ,players :: [Player]
                          ,droneCost :: Int
                          ,myId :: Int
                          }
                 deriving (Eq, Show)

data TDZone = TDZone{tdzId :: Int
                    ,tdzOwner :: Int
                    ,tdzP0Drons :: Int
                    ,tdzP1Drons :: Int
                    ,tdzP2Drons :: Int
                    ,tdzP3Drons :: Int
                    }
            deriving (Eq, Show)

data TurnData = TurnData{tdGold :: Int
                        ,tdZones :: [TDZone]
                        }
              deriving (Eq, Show)

main :: IO ()
main = do
  hSetBuffering stdout NoBuffering -- DO NOT REMOVE
    
  -- Auto-generated code below aims at helping you parse
  -- the standard input according to the problem statement.
    
  input_line <- getLine
--  hPutStrLn stderr input_line
  let input = words input_line
      playercount = read (input!!0) :: Int -- the amount of players (2 to 4)
      myid = read (input!!1) :: Int -- my player ID (0, 1, 2 or 3)
      zonecount = read (input!!2) :: Int -- the amount of zones on the map
      linkcount = read (input!!3) :: Int -- the amount of links between all zones

  
  zones <- replicateM zonecount $ do
    input_line <- getLine
    --hPutStrLn stderr input_line
    let input = words input_line
        zoneid = read (input!!0) :: Int -- this zone's ID (between 0 and zoneCount-1)
        platinumsource = read (input!!1) :: Int -- the amount of Platinum this zone can provide per game turn
    return (zoneid,platinumsource)
    
  edges <- replicateM linkcount $ do
    input_line <- getLine
    --hPutStrLn stderr input_line
    let input = words input_line
        zone1 = read (input!!0) :: Int
        zone2 = read (input!!1) :: Int
    return (zone1,zone2) --[(zone1, zone2),(zone2,zone1)]
  let field = buildG (0,zonecount-1) (edges)
--      areas = dff field
--  print (edges)
--  print areas
--  putStrLn "Start game loop"
  loop $ GameState 0 [] zones [] 20 myid

loop :: GameState -> IO ()
loop st = do
  input_line <- getLine
  let platinum = read input_line :: Int -- my available Platinum
      zonecount = length $ allZones st
  tdz <- replicateM zonecount $ do
    input_line <- getLine
    let input = words input_line
        zid = read (input!!0) :: Int -- this zone's ID
        ownerid = read (input!!1) :: Int -- the player who owns this zone (-1 otherwise)
        podsp0 = read (input!!2) :: Int -- player 0's PODs on this zone
        podsp1 = read (input!!3) :: Int -- player 1's PODs on this zone
        podsp2 = read (input!!4) :: Int -- player 2's PODs on this zone (always 0 for a two player game)
        podsp3 = read (input!!5) :: Int -- player 3's PODs on this zone (always 0 for a two or three player game)
    return $ (TDZone zid ownerid podsp0 podsp1 podsp2 podsp3)
    
    -- hPutStrLn stderr "Debug messages..."
  let td = TurnData platinum tdz
      toTake = head $ filter (\z -> (tdzOwner z) == (-1)) tdz
      zid = tdzId toTake
    -- first line for movement commands, second line for POD purchase (see the protocol in the statement for details)
  putStrLn "WAIT"
  putStrLn $ "1 " ++ (show zid)
    
  loop st

g1 = buildG (0,153) [(21,28),(28,21)
                    ,(21,29),(29,21)
                    ,(21,22),(22,21)
                    ,(4,8),(8,4)
                    ,(4,9),(9,4)
                    ,(4,5),(5,4)
{'fraction_non_alphanumeric': 0.1092469262295082, 'fraction_numerical': 0.02420594262295082, 'mean_word_length': 1.8252532561505066, 'pattern_counts': {'":': 0, '<': 18, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5113314', 'n_tokens_mistral': 2499, 'n_tokens_neox': 2350, 'n_words': 849}