Skip to content

Commit

Permalink
Merge 587220a into 2586c82
Browse files Browse the repository at this point in the history
  • Loading branch information
BarbourSmith committed Mar 13, 2022
2 parents 2586c82 + 587220a commit eccbd17
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 9 deletions.
12 changes: 9 additions & 3 deletions dist/maslowWorker.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,12 +188,18 @@ const agent = async ({ ask, message }) => {

try{
const returnedGeometry = foo({...inputs, ...api });
await api.saveGeometry(message.writePath, returnedGeometry);
return 1;

if(typeof returnedGeometry == 'number'){
return {success: true, type: "number", value: returnedGeometry};
}
else{
await api.saveGeometry(message.writePath, returnedGeometry);
return {success: true, type: "path"};
}
}
catch(err){
console.warn(err);
return -1;
return {success: false};
}
break;
case "text":
Expand Down
46 changes: 45 additions & 1 deletion src/js/molecules/code.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,51 @@ export default class Code extends Atom {
})

const values = { op: "code", code: this.code, paths: argumentsArray, writePath: this.path }
this.basicThreadValueProcessing(values)

var go = true
this.inputs.forEach(input => {
if(!input.ready){
go = false
}
})
if(go){ //Then we update the value

this.waitOnComingInformation() //This sends a chain command through the tree to lock all the inputs which are down stream of this one. It also cancels anything processing if this atom was doing a calculation already.

/**
* Indicates that this atom is computing
* @type {boolean}
*/
this.processing = true
this.decreaseToProcessCountByOne()


this.clearAlert()

const {answer, terminate} = window.ask(values)
answer.then(result => {
if (result.success){
if(result.type == "path"){
this.displayAndPropagate()
}
else{
if(this.output){
this.output.setValue(result.value)
this.output.ready = true
}
}
}else{
this.setAlert("Unable to compute")
}
this.processing = false
})

/**
* This can be called to interrupt the computation
* @type {function}
*/
this.cancelProcessing = terminate
}

}catch(err){this.setAlert(err)}
}
Expand Down
6 changes: 2 additions & 4 deletions src/js/molecules/geneticAlgorithm.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,13 +144,13 @@ export default class GeneticAlgorithm extends Atom {
this.population[this.individualIndex].fitness = this.findIOValue('fitness function')

//Evaluate the next individual
this.individualIndex ++
this.individualIndex = this.individualIndex + 1
if(this.individualIndex < this.findIOValue('population size')){
//Evaluate the next individual by updating all of the inputs
this.beginEvaluatingIndividual()
}
else{
this.generation++
this.generation = this.generation + 1
if(this.generation < this.findIOValue('number of generations')){
// Generate a new generation from the existing generation and start the process over
this.breedAndCullPopulation()
Expand All @@ -177,8 +177,6 @@ export default class GeneticAlgorithm extends Atom {
*/
updateSidebar(){



if(this.evolutionInProcess){

//Remove everything in the sidebar
Expand Down
7 changes: 6 additions & 1 deletion src/js/molecules/molecule.js
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,12 @@ export default class Molecule extends Atom{
pushPropagation(){
//Only propagate up if
if(this != GlobalVariables.currentMolecule){
this.output.setValue(this.path)
if(typeof this.readOutputAtomPath() == "number"){
this.output.setValue(this.readOutputAtomPath())
}
else{
this.output.setValue(this.path)
}
this.output.ready = true
}
else{
Expand Down

0 comments on commit eccbd17

Please sign in to comment.