Skip to content

Instantly share code, notes, and snippets.

@backnotprop
Created October 27, 2017 17:27
Show Gist options
  • Save backnotprop/4a12ddb24e84032a671fb28188813a84 to your computer and use it in GitHub Desktop.
Save backnotprop/4a12ddb24e84032a671fb28188813a84 to your computer and use it in GitHub Desktop.
/**
* Proposal Stage 1
* - everyone sends out a proposal and they are either accepted or rejected
* - recursive until everone has accepted proposal
*/
function _proposalStage(start){
let i = typeof start !== 'undefined' ? start : 1;
while(i < Object.keys(_DB).length + 1) {
let sender = _DB[i];
if(!sender.hasAcceptedSentProposal) {
// need to go through proposal stages for this person and their preferences
// next offer is first choice in preference list that hasn't been proposed to yet
// send offer to that person, propose Offer will accept or reject the offer
proposalProcess( sender, _DB[sender.choices[0].id], sender.choices[0].strength );
}
i++;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment