<commit_before>package main

import (
	twodee "../libs/twodee"
	"github.com/kurrik/tmxgo"
	"io/ioutil"
	"strings"
)

type Level struct {
	Grids []*twodee.Grid
}

func LoadLevel(path string) (l *Level, err error) {
	var (
		data  []byte
		m     *tmxgo.Map
		layer tmxgo.Layer
		i, j  int
		grids = []*twodee.Grid{}
		grid  *twodee.Grid
		tiles []*tmxgo.Tile
		tile  *tmxgo.Tile
	)
	if data, err = ioutil.ReadFile(path); err != nil {
		return
	}
	if m, err = tmxgo.ParseMapString(string(data)); err != nil {
		return
	}
	for i, layer = range m.Layers {
		if !strings.HasPrefix(layer.Name, "layer") {
			continue
		}
		if tiles, err = m.TilesFromLayerIndex(int32(i)); err != nil {
			return
		}
		grid = twodee.NewGrid(m.Width, m.Height)
		for i, tile = range tiles {
			if tile != nil {
				grid.SetIndex(int32(i), true)
			}
		}
		grids = append(grids, grid)
	}
	l = &Level{
		Grids: grids,
	}
	return
}<commit_msg>Fix issue and add a new function.<commit_after>package main

import (
	twodee "../libs/twodee"
	"fmt"
	"github.com/kurrik/tmxgo"
	"io/ioutil"
	"strings"
)

type Level struct {
	Grids []*twodee.Grid
}

func LoadLevel(path string) (l *Level, err error) {
	var (
		data  []byte
		m     *tmxgo.Map
		layer tmxgo.Layer
		i, j  int
		grids = []*twodee.Grid{}
		grid  *twodee.Grid
		tiles []*tmxgo.Tile
		tile  *tmxgo.Tile
	)
	if data, err = ioutil.ReadFile(path); err != nil {
		return
	}
	if m, err = tmxgo.ParseMapString(string(data)); err != nil {
		return
	}
	for i, layer = range m.Layers {
		if !strings.HasPrefix(layer.Name, "layer") {
			continue
		}
		if tiles, err = m.TilesFromLayerIndex(int32(i)); err != nil {
			return
		}
		grid = twodee.NewGrid(m.Width, m.Height)
		for j, tile = range tiles {
			if tile != nil {
				grid.SetIndex(int32(i), true)
			}
		}
		grids = append(grids, grid)
	}
	l = &Level{
		Grids: grids,
	}
	return
}

func GetTexturePath(m *tmxgo.Map) (path string, err error) {
	for i := 0; i < len(m.Tilesets); i++ {
		if m.Tilesets[i].Image == nil {
			continue
		}
		path = m.Tilesets[i].Image.Source
		return
	}
	err = fmt.Errorf("Could not find suitable tileset")
	return
}
{'fraction_non_alphanumeric': 0.1510859301227573, 'fraction_numerical': 0.00424929178470255, 'mean_word_length': 2.9830827067669174, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 3, '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': '3982443', 'n_tokens_mistral': 974, 'n_tokens_neox': 893, 'n_words': 212}