missionaries_game/js/sketch.js
// Function to check and add/delete the newly generated states.
Function to check and add/delete the newly generated states.
Function to check and add / delete the newly generated states .
function addState(parent, value) {
  var temp = new CreateState();
  temp.value = value;
  temp.parent = parent.value;
  temp.visited = false;
  if(goalState[0] === value[0] && goalState[1] === value[1]) {
    state.push(temp);
    iterator = false;
  }else if((temp.value[0] === 0) || temp.value[0] >= temp.value[1]) {
    if((3 - temp.value[0] === 0) || (3 - temp.value[0] >= 3 - temp.value[1])){
      if(repetitionChecker(value)) {
        killedState.push(temp);
      } else {
        state.push(temp);
      }
    }else {
      killedState.push(temp);
    }
  }else if(temp.value[0] < temp.value[1]) {
    killedState.push(temp);
  }
}
function addState ( parent , value ) { var temp = new CreateState ( ) ; temp . value = value ; temp . parent = parent . value ; temp . visited = false ; if ( goalState [ 0 ] === value [ 0 ] && goalState [ 1 ] === value [ 1 ] ) { state . push ( temp ) ; iterator = false ; } else if ( ( temp . value [ 0 ] === 0 ) || temp . value [ 0 ] >= temp . value [ 1 ] ) { if ( ( 3 - temp . value [ 0 ] === 0 ) || ( 3 - temp . value [ 0 ] >= 3 - temp . value [ 1 ] ) ) { if ( repetitionChecker ( value ) ) { killedState . push ( temp ) ; } else { state . push ( temp ) ; } } else { killedState . push ( temp ) ; } } else if ( temp . value [ 0 ] < temp . value [ 1 ] ) { killedState . push ( temp ) ; } }
Function to check and add/delete the newly generated states.
Function to check and add / delete the newly generated states .