mfan Posted March 19, 2013 Share Posted March 19, 2013 *************************** ~ online dating algorithm ~ *************************** 10 write to girl 20 wait for reply 30 goto 20 40 get married Link to comment
itsallgrand Posted March 19, 2013 Share Posted March 19, 2013 ha! so are you currently waiting for replies?...? Link to comment
Angler Posted March 19, 2013 Share Posted March 19, 2013 You need a counter to break that loop, and GOTO is poor form Link to comment
LonelyPast Posted March 19, 2013 Share Posted March 19, 2013 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
mfan Posted March 19, 2013 Author Share Posted March 19, 2013 Um... I'd replace "CASE AVAILABLE" with "CASE ELSE" and an inline comment saying this should never happen Link to comment
Recommended Posts