Jump to content

Online Dating Algorithm


mfan

Recommended Posts

You need a counter to break that loop, and GOTO is poor form

 

I think that's the point he's trying to make; It just goes on indefinitely. Here's a revised algorithm for you in C++:

 

// Effort thread

while(you.single)

{

queue
toMessage;

DatingProfile* currentlyReading = null;

bool interested = false;

for(int i = 0; i

{

currentlyReading = datingService.getNextProfile(you.preferences);

interested = you.browse(nextProfile);

if(interested)

{

toMessage.push(currentlyReading);

}

}

for(int i = toMessage.size(); i > 0; i--)

{

you. composeFirstMessage(toMessage.front(), you.moreFreeTime / toMessage.size());

toMessage.pop();

}

}

 

// Response thread

void onResponse(Message reply)

{

responseCode = you.readReply();

switch(responseCode)

{

case NOTINTERESTED:

case NOTINTERESTING:

case CRAZY:

case SEEINGSOMEBODYELSE:

case LEADINGYOUON:

break;

case BUSYRIGHTNOW:

you. composePlanningMessage(reply.DatingProfile, you.evenMoreFreeTime);

break;

case AVAILABLE

secondDate = you.actuallyGoOnDate(you.awesome);

if(secondDate == true)

{

if(!you.multiDating)

{

you.single = false;

throwDatingException("Too clingy!");

you.single = true;

}

}

break;

}

}

Link to comment
×
×
  • Create New...