Skip to content

Commit

Permalink
Last fix (I promised)
Browse files Browse the repository at this point in the history
  • Loading branch information
Vincent Riva committed Mar 28, 2019
1 parent b9c8762 commit 01100fe
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions docs/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ GenomeEvent.on(GenomeEventType.GENOME_EVENT_GENERATION_END, chromosomes => {

let finalString = '';
bestChromosome.getGenes().map(gene => {
finalString += String.fromCharCode(gene.get() + 96);
finalString += String.fromCharCode(gene.get() + 97);
});

textOutput.value = `${population.getGenerationNumber()} - ${finalString}\n${textOutput.value}`;
Expand Down Expand Up @@ -49,8 +49,8 @@ runButton.addEventListener('click', () => {
let sum = 1; // Avoid to have 0 on fitness

for (let i = 0; i < genes.length; i += 1) {
const charCode = input.charCodeAt(i) - 96;
const geneCharCode = Math.floor(genes[i].get()) + 1;
const charCode = input.charCodeAt(i) - 97;
const geneCharCode = Math.floor(genes[i].get());
if (charCode === geneCharCode) {
sum += 1;
}
Expand Down

0 comments on commit 01100fe

Please sign in to comment.