<commit_before>from __future__ import division
import binary_gtype
import evoalg
from math import log
from pylab import plot, show, figure, fill_between

class blotto_ptype(binary_gtype.binary_genotype):
	phenotype = None
	fitness = 0
	morale = 1.
	
	def battle(this, that):
		this.morale = 1.
		that.morale = 1.
		for i in xrange(problem_size):
			diff = this.phenotype[i] - that.phenotype[i]
			if diff > 0:
				this.fitness += 2
				that.morale *= (1-lf)
				if i < problem_size-1:
					distribute = diff*rf/(problem_size-i+1)
					for j in xrange(i+1, problem_size):
						this.phenotype[j] += distribute
			elif diff < 0:
				that.fitness += 2
				this.morale *= (1-lf)
				if i < problem_size-1:
					distribute = -diff*rf/(problem_size-i+1)
					for j in xrange(i+1, problem_size):
						that.phenotype[j] += distribute<commit_msg>Fixed blotto.py to use temporary variables<commit_after>from __future__ import division
import binary_gtype
import evoalg
from math import log
from pylab import plot, show, figure, fill_between
from copy import deepcopy

class blotto_ptype(binary_gtype.binary_genotype):
	phenotype = None
	fitness = 0
	morale = 1.
	
	def battle(this, that):
		this.morale = 1.
		that.morale = 1.
		this_ptype = deepcopy(this.phenotype)
		that_ptype = deepcopy(that.phenotype)
		for i in xrange(problem_size):
			diff = this_ptype[i] - that_ptype[i]
			if diff > 0:
				this.fitness += 2
				that.morale *= (1-lf)
				if i < problem_size-1:
					distribute = diff*rf/(problem_size-i+1)
					for j in xrange(i+1, problem_size):
						this_ptype[j] += distribute
			elif diff < 0:
				that.fitness += 2
				this.morale *= (1-lf)
				if i < problem_size-1:
					distribute = -diff*rf/(problem_size-i+1)
					for j in xrange(i+1, problem_size):
						that_ptype[j] += distribute
{'fraction_non_alphanumeric': 0.11197771587743732, 'fraction_numerical': 0.017827298050139277, 'mean_word_length': 3.306954436450839, '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': '5946933', 'n_tokens_mistral': 803, 'n_tokens_neox': 654, 'n_words': 170}