Skip to content

Commit

Permalink
Merge pull request #401 from MaslowCNC/add-evolve-checks-to-constant
Browse files Browse the repository at this point in the history
Add evolve check boxes to constant
  • Loading branch information
BarbourSmith committed Apr 3, 2020
2 parents 9ecd1db + 5839051 commit b15619d
Showing 1 changed file with 36 additions and 2 deletions.
38 changes: 36 additions & 2 deletions src/js/molecules/constant.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,24 @@ export default class Constant extends Atom{
*/
this.atomType = 'Constant'
/**
* This atom's height as drawn on the screen...probably doesn't need to be in this scope
* @type {string}
* This atom's height as drawn on the screen
*/
this.height = 16
/**
* A flag to indicate if this constant should be evolved by genetic algorithms
* @type {boolean}
*/
this.evolve = false
/**
* Minimum value to be used when evolving constant
* @type {float}
*/
this.min = 0
/**
* Maximum value to be used when evolving constant
* @type {float}
*/
this.max = 20

this.setValues(values)

Expand All @@ -41,6 +55,7 @@ export default class Constant extends Atom{
if (typeof this.ioValues == 'object') {
this.output.setValue(this.ioValues[0].ioValue)
}

}

/**
Expand All @@ -59,6 +74,21 @@ export default class Constant extends Atom{
var valueList = super.updateSidebar() //call the super function
this.createEditableValueListItem(valueList,this,'name', 'Name', false)
this.createEditableValueListItem(valueList,this.output,'value', 'Value', true)

this.createCheckbox(valueList,"Evolve",this.evolve,(event)=>{
if(event.target.checked){
this.evolve = true
this.updateSidebar()
} else{
this.evolve = false
this.updateSidebar()
}
})

if(this.evolve){
this.createEditableValueListItem(valueList,this,'min', 'Min', true)
this.createEditableValueListItem(valueList,this,'max', 'Max', true)
}
}

/**
Expand All @@ -73,6 +103,10 @@ export default class Constant extends Atom{
ioValue: this.output.getValue()
}]

valuesObj.evolve = this.evolve
valuesObj.min = this.min
valuesObj.max = this.max

return valuesObj

}
Expand Down

0 comments on commit b15619d

Please sign in to comment.