<commit_before>package cellsociety_team08;

import java.util.ArrayList;
import java.util.List;

public class SugarScape extends RuleSet {
	
	public int sugarGrowBackRate = 1;
	
	@Override
	public Patch getNext(Patch curr) {
		
		if (curr.isEmpty && curr.sugarLevel < curr.maxSugar) {
			curr.sugarLevel = curr.sugarLevel + sugarGrowBackRate;
		}
		
		
		
		return null;
	}
	
	@Override
	public List<Patch> getNeighbors(Patch p) {
		return getDirectNeighbors(p);
	}
	
	@Override 
	public List<Patch> getDirectNeighbors(Patch p) {  //don't have a get EXTENDED direct neighbors for hexagonal yet
		
		List<Patch> ret = new ArrayList<Patch>();
		int row = p.myRow;
		int col = p.myCol;
		int vision = p.myCell.vision;
		
		switch (gridShape) {	
		case ("Hexagonal"):
			break;
		case ("Triangular"):
			for (int i = 1; i < vision+1; i++) {
				if (!isOutside(row, col - i))
					ret.add(myPatches[row][col - i]);
				if (!isOutside(row, col + i))
					ret.add(myPatches[row][col + i]);
				if (!isOutside(row - i, col) && col % 2 == 0)
					ret.add(myPatches[row - i][col]);
				if (!isOutside(row + i, col) && col % 2 == 1)
					ret.add(myPatches[row + i][col]);
			}
			break;
		default:
			for (int i = 1; i < vision+1; i++) {
				if (!isOutside(row, col - i))
					ret.add(myPatches[row][col - i]);
				if (!isOutside(row, col + i))
					ret.add(myPatches[row][col + i]);
				if (!isOutside(row - i, col))
					ret.add(myPatches[row - i][col]);
				if (!isOutside(row + i, col))
					ret.add(myPatches[row + i][col]);
			}
			break;
		}
		return ret;
	}
	
}<commit_msg>SugarScape neighbor and getNext implementations not done but working on it<commit_after>package cellsociety_team08;

import java.util.ArrayList;
import java.util.List;

public class SugarScape extends RuleSet {
	
	public int sugarGrowBackRate = 1;
	
	@Override
	public Patch getNext(Patch curr) {
		int row = curr.myRow;
		int col = curr.myCol;
		List<Patch> neighbors = getNeighbors(curr);
		List<Patch> equalNeighbors = new ArrayList<Patch>();
		Patch nextPatch = new Patch(row, col, false);
		
		if (curr.isEmpty && curr.sugarLevel < curr.maxSugar) { //grow the sugar back
			curr.sugarLevel = curr.sugarLevel + sugarGrowBackRate;
		}
		
		int mostSugar = 0;
		for (Patch patch: neighbors) {
			if (patch.sugarLevel >= mostSugar) {
				nextPatch = patch;
				mostSugar = patch.sugarLevel;
			}
		}
		//equalNeighbors.add(nextPatch);
		for (Patch patch: neighbors) {
			if (patch.sugarLevel == nextPatch.sugarLevel) {
				equalNeighbors.add(patch);
			}
		}
		if (equalNeighbors.size() > 0) {
			nextPatch = getClosestNeighbor(curr, equalNeighbors);
		}
		
		
		return nextPatch;
	}
	
	public Patch getClosestNeighbor(Patch patch, List<Patch> neighbors) {
		int smallestDifference = 100000;
		Patch retPatch = new Patch(0, 0, true);
		
		for (Patch p: neighbors) {
			if (p.myCol == patch.myCol) {
				int difference = p.myRow - patch.myRow;
				if (difference < 0) {
					difference = difference * (-1);
				}
				if (difference < smallestDifference) {
					smallestDifference = difference;
					retPatch = p;
				}
			}
			if (p.myRow == patch.myRow) {
				int difference = p.myCol - patch.myCol;
				if (difference < 0) {
					difference = difference * (-1);
				}
				if (difference < smallestDifference) {
					smallestDifference = difference;
					retPatch = p;
				}
			}
		}
		return retPatch;
		
	}
	
	@Override
	public List<Patch> getNeighbors(Patch p) {
		return getDirectNeighbors(p);
	}
	
	@Override 
	public List<Patch> getDirectNeighbors(Patch p) {  //don't have a get EXTENDED direct neighbors for hexagonal yet
		
		List<Patch> ret = new ArrayList<Patch>();
		int row = p.myRow;
		int col = p.myCol;
		int vision = p.myCell.vision;
		
		switch (gridShape) {	
		case ("Hexagonal"):
			break;
		case ("Triangular"):
			for (int i = 1; i < vision+1; i++) {
				if (!isOutside(row, col - i))
					ret.add(myPatches[row][col - i]);
				if (!isOutside(row, col + i))
					ret.add(myPatches[row][col + i]);
				if (!isOutside(row - i, col) && col % 2 == 0)
					ret.add(myPatches[row - i][col]);
				if (!isOutside(row + i, col) && col % 2 == 1)
					ret.add(myPatches[row + i][col]);
			}
			break;
		default:
			for (int i = 1; i < vision+1; i++) {
				if (!isOutside(row, col - i))
					ret.add(myPatches[row][col - i]);
				if (!isOutside(row, col + i))
					ret.add(myPatches[row][col + i]);
				if (!isOutside(row - i, col))
					ret.add(myPatches[row - i][col]);
				if (!isOutside(row + i, col))
					ret.add(myPatches[row + i][col]);
			}
			break;
		}
		return ret;
	}
}
{'fraction_non_alphanumeric': 0.14777461083095814, 'fraction_numerical': 0.007893005919754439, 'mean_word_length': 2.987762237762238, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 17, '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': '6631579', 'n_tokens_mistral': 2040, 'n_tokens_neox': 1651, 'n_words': 411}