# Path: modules/game/Player.py
# class Player(NamedTuple('Player', [
#     ('id', 'PlayerID'),
#     ('titled', bool),
#     ('engine', bool),
#     ('gamesPlayed', int)])):
# class PlayerBSONHandler:
# class PlayerDB(NamedTuple('PlayerDB', [
#         ('playerColl', 'Collection')
#     ])):
#     def fromJson(userData: Dict):
#     def reads(bson: Dict) -> Player:
#     def writes(player: Player) -> Dict:
#     def byId(self, playerId: PlayerID) -> Opt[Player]:
#     def byPlayerId(self, playerId: PlayerID) -> Opt[Player]:
#     def unmarkedByUserIds(self, playerIds: List[PlayerID]) -> List[Player]:
#     def engineSample(self, engine: bool, size: int) -> List[Player]:
#     def oldestNonEngine(self) -> Opt[Player]:
#     def byEngine(self, engine: bool = True) -> List[Player]:
#     def all(self) -> List[Player]:
#     def write(self, player: Player):
# 
# Path: modules/game/Game.py
# class Game(NamedTuple('Game', [
#         ('id', GameID),
#         ('white', PlayerID),
#         ('black', PlayerID),
#         ('pgn', List[str]),
#         ('emts', Opt[List[Emt]]),
#         ('analysis', Analysis)
#     ])):
# class GameBSONHandler:
# class GameDB(NamedTuple('GameDB', [
#         ('gameColl', Collection)
#     ])):
#     def fromDict(d: Dict):
#     def fromJson(json: Dict):
#     def toJson(self):
#     def playable(self):
#     def boardTensors(self, colour):
#     def boardTensorsByPlayerId(self, playerId: PlayerID, length: int = 60, safe: bool = True):
#     def tensor(self, playerId: PlayerID, length: int = 60, noisey: bool = False, safe: bool = True) -> Opt[GameTensor]:
#     def emtsByColour(self, colour: Colour, emts: Opt[List[int]] = None) -> List[Emt]:
#     def moveTensor(analysis: Analysis, emt: Emt, boardTensor: List[int], avgEmt: Number, colour: Colour) -> MoveTensor:
#     def nullBoardTensor():
#     def nullMoveTensor() -> MoveTensor:
#     def ply(moveNumber: int, colour: Colour) -> int:
#     def reads(bson: Dict) -> Game:
#     def writes(game: Game) -> Dict:
#     def byId(self, _id: GameID) -> Opt[Game]:
#     def byIds(self, ids: List[GameID]) -> List[Game]:
#     def byPlayerId(self, playerId: PlayerID) -> List[Game]:
#     def byPlayerIdAndAnalysed(self, playerId: PlayerID, analysed: bool = True) -> List[Game]:
#     def write(self, game: Game):
#     def writeMany(self, games: List[Game]):
# 
# Path: modules/game/AnalysedGame.py
# class AnalysedGame(NamedTuple('AnalysedGame', [
#         ('id', AnalysedGameID),
#         ('playerId', PlayerID),
#         ('gameId', GameID),
#         ('analysedMoves', List[AnalysedMove])
#     ])):
# class GameAnalysedGame(NamedTuple('GameAnalysedGame', [
#         ('analysedGame', AnalysedGame),
#         ('game', Game)
#     ])):
# class AnalysedGameBSONHandler:
# class AnalysedGameDB(NamedTuple('AnalysedGameDB', [
#         ('analysedGameColl', Collection)
#     ])):
#     def new(gameId: GameID, colour: Colour, playerId: PlayerID, analysedMoves: List[AnalysedMove]):
#     def makeId(gameId: GameID, colour: Colour) -> AnalysedGameID:
#     def tensor(self, length: int = 60) -> AnalysedGameTensor:
#     def toJson(self):
#     def emtAverage(self) -> Number:
#     def wclAverage(self) -> Number:
#     def gameLength(self) -> int:
#     def emts(self) -> List[Emt]:
#     def emtSeconds(self) -> List[Number]:
#     def winningChances(self) -> List[Number]:
#     def winningChancesPercent(self) -> List[Number]:
#     def winningChancesLossPercent(self, usePV: bool = True) -> List[Number]:
#     def winningChancesLossByPV(self):
#     def ranks(self) -> List[TrueRank]:
#     def ambiguities(self) -> List[int]:
#     def length(self) -> int:
#     def ranksJSON(self) -> str:
#     def binnedSeconds(self, bins: int = 10) -> Dict:
#     def binnedLosses(self, bins: int = 10) -> Dict:
#     def binnedPVs(self, bins: int = 6) -> Dict:
#     def moveRankByTime(self) -> List[Dict]:
#     def moveRankByTimeJSON(self) -> str:
#     def lossByTime(self) -> List[Dict]:
#     def lossByTimeJSON(self) -> str:
#     def lossByRank(self) -> List[Dict]:
#     def lossByRankJSON(self) -> str:
# def round_sig(x, sig=2):
#     def length(self):
#     def tensor(self):
#     def reads(bson: Dict) -> AnalysedGame:
#     def writes(analysedGame: AnalysedGame) -> Dict:
#     def write(self, analysedGame: AnalysedGame):
#     def writeMany(self, analysedGames: List[AnalysedGame]):
#     def byPlayerId(self, playerId: PlayerID) -> List[AnalysedGame]:
#     def byPlayerIds(self, playerIds: List[PlayerID]) -> List[AnalysedGame]:
#     def byId(self, _id: AnalysedGameID) -> Opt[AnalysedGame]:
#     def byIds(self, ids: List[AnalysedGameID]) -> List[AnalysedGame]:
#     def allBatch(self, batch: int, batchSize: int = 500):
#     def byGameIdAndUserId(self, gameId: GameID, playerId: PlayerID) -> Opt[AnalysedGame]:


from default_imports import *
from modules.game.Player import PlayerID
from modules.game.Game import Game, GameID, GameTensor, Emt
from modules.game.AnalysedGame import AnalysedGame, AnalysedGameTensor
import numpy as np
import math
import json



class GameStore(NamedTuple('GameStore', [
        ('playerId', PlayerID),
        ('games', List[Game]), 
        ('analysedGames', List[AnalysedGame])
    ])):
    @staticmethod

# Path: modules/game/Player.py
# class Player(NamedTuple('Player', [
#     ('id', 'PlayerID'),
#     ('titled', bool),
#     ('engine', bool),
#     ('gamesPlayed', int)])):
# class PlayerBSONHandler:
# class PlayerDB(NamedTuple('PlayerDB', [
#         ('playerColl', 'Collection')
#     ])):
#     def fromJson(userData: Dict):
#     def reads(bson: Dict) -> Player:
#     def writes(player: Player) -> Dict:
#     def byId(self, playerId: PlayerID) -> Opt[Player]:
#     def byPlayerId(self, playerId: PlayerID) -> Opt[Player]:
#     def unmarkedByUserIds(self, playerIds: List[PlayerID]) -> List[Player]:
#     def engineSample(self, engine: bool, size: int) -> List[Player]:
#     def oldestNonEngine(self) -> Opt[Player]:
#     def byEngine(self, engine: bool = True) -> List[Player]:
#     def all(self) -> List[Player]:
#     def write(self, player: Player):
# 
# Path: modules/game/Game.py
# class Game(NamedTuple('Game', [
#         ('id', GameID),
#         ('white', PlayerID),
#         ('black', PlayerID),
#         ('pgn', List[str]),
#         ('emts', Opt[List[Emt]]),
#         ('analysis', Analysis)
#     ])):
# class GameBSONHandler:
# class GameDB(NamedTuple('GameDB', [
#         ('gameColl', Collection)
#     ])):
#     def fromDict(d: Dict):
#     def fromJson(json: Dict):
#     def toJson(self):
#     def playable(self):
#     def boardTensors(self, colour):
#     def boardTensorsByPlayerId(self, playerId: PlayerID, length: int = 60, safe: bool = True):
#     def tensor(self, playerId: PlayerID, length: int = 60, noisey: bool = False, safe: bool = True) -> Opt[GameTensor]:
#     def emtsByColour(self, colour: Colour, emts: Opt[List[int]] = None) -> List[Emt]:
#     def moveTensor(analysis: Analysis, emt: Emt, boardTensor: List[int], avgEmt: Number, colour: Colour) -> MoveTensor:
#     def nullBoardTensor():
#     def nullMoveTensor() -> MoveTensor:
#     def ply(moveNumber: int, colour: Colour) -> int:
#     def reads(bson: Dict) -> Game:
#     def writes(game: Game) -> Dict:
#     def byId(self, _id: GameID) -> Opt[Game]:
#     def byIds(self, ids: List[GameID]) -> List[Game]:
#     def byPlayerId(self, playerId: PlayerID) -> List[Game]:
#     def byPlayerIdAndAnalysed(self, playerId: PlayerID, analysed: bool = True) -> List[Game]:
#     def write(self, game: Game):
#     def writeMany(self, games: List[Game]):
# 
# Path: modules/game/AnalysedGame.py
# class AnalysedGame(NamedTuple('AnalysedGame', [
#         ('id', AnalysedGameID),
#         ('playerId', PlayerID),
#         ('gameId', GameID),
#         ('analysedMoves', List[AnalysedMove])
#     ])):
# class GameAnalysedGame(NamedTuple('GameAnalysedGame', [
#         ('analysedGame', AnalysedGame),
#         ('game', Game)
#     ])):
# class AnalysedGameBSONHandler:
# class AnalysedGameDB(NamedTuple('AnalysedGameDB', [
#         ('analysedGameColl', Collection)
#     ])):
#     def new(gameId: GameID, colour: Colour, playerId: PlayerID, analysedMoves: List[AnalysedMove]):
#     def makeId(gameId: GameID, colour: Colour) -> AnalysedGameID:
#     def tensor(self, length: int = 60) -> AnalysedGameTensor:
#     def toJson(self):
#     def emtAverage(self) -> Number:
#     def wclAverage(self) -> Number:
#     def gameLength(self) -> int:
#     def emts(self) -> List[Emt]:
#     def emtSeconds(self) -> List[Number]:
#     def winningChances(self) -> List[Number]:
#     def winningChancesPercent(self) -> List[Number]:
#     def winningChancesLossPercent(self, usePV: bool = True) -> List[Number]:
#     def winningChancesLossByPV(self):
#     def ranks(self) -> List[TrueRank]:
#     def ambiguities(self) -> List[int]:
#     def length(self) -> int:
#     def ranksJSON(self) -> str:
#     def binnedSeconds(self, bins: int = 10) -> Dict:
#     def binnedLosses(self, bins: int = 10) -> Dict:
#     def binnedPVs(self, bins: int = 6) -> Dict:
#     def moveRankByTime(self) -> List[Dict]:
#     def moveRankByTimeJSON(self) -> str:
#     def lossByTime(self) -> List[Dict]:
#     def lossByTimeJSON(self) -> str:
#     def lossByRank(self) -> List[Dict]:
#     def lossByRankJSON(self) -> str:
# def round_sig(x, sig=2):
#     def length(self):
#     def tensor(self):
#     def reads(bson: Dict) -> AnalysedGame:
#     def writes(analysedGame: AnalysedGame) -> Dict:
#     def write(self, analysedGame: AnalysedGame):
#     def writeMany(self, analysedGames: List[AnalysedGame]):
#     def byPlayerId(self, playerId: PlayerID) -> List[AnalysedGame]:
#     def byPlayerIds(self, playerIds: List[PlayerID]) -> List[AnalysedGame]:
#     def byId(self, _id: AnalysedGameID) -> Opt[AnalysedGame]:
#     def byIds(self, ids: List[AnalysedGameID]) -> List[AnalysedGame]:
#     def allBatch(self, batch: int, batchSize: int = 500):
#     def byGameIdAndUserId(self, gameId: GameID, playerId: PlayerID) -> Opt[AnalysedGame]:


# Path: modules/game/GameStore.py
from default_imports import *
from modules.game.Player import PlayerID
from modules.game.Game import Game, GameID, GameTensor, Emt
from modules.game.AnalysedGame import AnalysedGame, AnalysedGameTensor
import numpy as np
import math
import json




class GameStore(NamedTuple('GameStore', [
        ('playerId', PlayerID),
        ('games', List[Game]), 
        ('analysedGames', List[AnalysedGame])
    ])):
    @staticmethod

    def new(playerId: PlayerID):