<commit_before>package rogue

import (
	"fmt"
	"math"
	"math/rand"
)

// Point ...
type Point struct {
	X float64
	Y float64
}

func (n Point) String() string {
	return fmt.Sprintf("%f,%f", n.X, n.Y)
}

func (n *Obj) distanceTo(pos Point) float64 {

	xd := n.Position.X - pos.X
	yd := n.Position.Y - pos.Y
	return math.Hypot(xd, yd)
}

func (n *Point) empty() bool {
	// XXX
	if n.X == 0 && n.Y == 0 {
		return true
	}
	return false
}

func (p *Point) intMatches(t *Point) bool {
	if math.Floor(p.X) == math.Floor(t.X) && math.Floor(p.Y) == math.Floor(t.Y) {
		return true
	}
	return false
}

func (p *Point) randomNearby() (Point, error) {
	// select 3x3 square of positions around n.pos, pick one at random (never p)
	var m []Point

	for y := p.Y - 1; y <= p.Y+1; y++ {
		for x := p.X - 1; x <= p.X+1; x++ {
			pp := Point{x, y}
			if pp != *p && island.isAboveWater(pp) {
				m = append(m, pp)
			}
		}
	}

	if len(m) == 0 {
		empty := Point{}
		return empty, fmt.Errorf("Cant find nearby points to %s", p)
	}

	// select something by random
	return m[rand.Intn(len(m))], nil
}<commit_msg>fix out of bounds read<commit_after>package rogue

import (
	"fmt"
	"math"
	"math/rand"
)

// Point ...
type Point struct {
	X float64
	Y float64
}

func (n Point) String() string {
	return fmt.Sprintf("%f,%f", n.X, n.Y)
}

func (n *Obj) distanceTo(pos Point) float64 {

	xd := n.Position.X - pos.X
	yd := n.Position.Y - pos.Y
	return math.Hypot(xd, yd)
}

func (n *Point) empty() bool {
	// XXX
	if n.X == 0 && n.Y == 0 {
		return true
	}
	return false
}

func (p *Point) intMatches(t *Point) bool {
	if math.Floor(p.X) == math.Floor(t.X) && math.Floor(p.Y) == math.Floor(t.Y) {
		return true
	}
	return false
}

func (p *Point) randomNearby() (Point, error) {
	// select 3x3 square of positions around n.pos, pick one at random (never p)
	var m []Point

	for y := p.Y - 1; y <= p.Y+1; y++ {
		for x := p.X - 1; x <= p.X+1; x++ {
			if y >= 0 && y < float64(island.Height) && x >= 0 && x < float64(island.Width) {
				pp := Point{x, y}
				if pp != *p && island.isAboveWater(pp) {
					m = append(m, pp)
				}
			}
		}
	}

	if len(m) == 0 {
		empty := Point{}
		return empty, fmt.Errorf("Cant find nearby points to %s", p)
	}

	// select something by random
	return m[rand.Intn(len(m))], nil
}
{'fraction_non_alphanumeric': 0.18722659667541558, 'fraction_numerical': 0.015748031496062992, 'mean_word_length': 2.706645056726094, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 5, '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': '7399705', 'n_tokens_mistral': 1047, 'n_tokens_neox': 967, 'n_words': 283}