private IEnumerable <ConnectFourState> GetStatesFromData(string dataFileName) { var fileProvider = new EmbeddedFileProvider(Assembly.GetAssembly(GetType())); var boards = fileProvider.ReadAllText(dataFileName) .SplitOnNewLine() .Batch(ConnectFourState.NumRows + 1); foreach (var rows in boards) { var board = rows .Reverse() // reverse the order because the bottom-left position is actually the first element in the board state .Skip(1) // skip the delimiter row at the bottom of the board (i.e. "-------") .Select(row => row.PadRight(ConnectFourState.NumCols)) .SelectMany(s => s.Select(c => c == 'X' ? X : c == 'O' ? O : _)) .ToArray(); var state = new ConnectFourState(board); yield return(state); } }