From 39f4fa3d6cf2cc13684f0a130bdf9ce53395facb Mon Sep 17 00:00:00 2001 From: drbob Date: Sat, 24 May 2008 20:20:16 +0000 Subject: [PATCH] Modified rankings to take into account the User Score (-2 -> +2). Scores can be based on: Time: Average Comment Age. Ranking: Sum of peer scores. Combo: Sum of (score * age) These are still rather crude and could be improved significantly if anyone is interested in trying. git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@562 b45a01b8-16f6-495d-af2f-9b41ad6348cc --- libretroshare/src/services/p3ranking.cc | 45 +++++++++++++++++++++---- 1 file changed, 39 insertions(+), 6 deletions(-) diff --git a/libretroshare/src/services/p3ranking.cc b/libretroshare/src/services/p3ranking.cc index 1a96e5fbe..a7f2dcf66 100644 --- a/libretroshare/src/services/p3ranking.cc +++ b/libretroshare/src/services/p3ranking.cc @@ -32,8 +32,8 @@ const uint32_t RANK_MAX_FWD_OFFSET = (60 * 60 * 24 * 2); /* 2 Days */ -//const uint32_t FRIEND_RANK_REPUBLISH_PERIOD = 60; /* every minute for testing */ -const uint32_t FRIEND_RANK_REPUBLISH_PERIOD = 1800; /* every 30 minutes */ +const uint32_t FRIEND_RANK_REPUBLISH_PERIOD = 60; /* every minute for testing */ +//const uint32_t FRIEND_RANK_REPUBLISH_PERIOD = 1800; /* every 30 minutes */ std::string generateRandomLinkId(); @@ -619,6 +619,8 @@ float p3Ranking::locked_calcRank(RankGroup &grp) uint32_t count = 0; float algScore = 0; + float comboScore = 0; + float popScore = 0; #ifdef RANK_DEBUG std::string normlink(grp.link.begin(), grp.link.end()); @@ -684,6 +686,15 @@ float p3Ranking::locked_calcRank(RankGroup &grp) algScore += timeScore; count++; + + /* for more advanced scoring (where each peer gives a score +2 -> -2) */ + /* combo = SUM value * timeScore */ + /* time = same as before (average) */ + /* popScore = SUM value */ + + float value = it->second->score; + comboScore += value * timeScore; + popScore += value; } #ifdef RANK_DEBUG @@ -704,18 +715,40 @@ float p3Ranking::locked_calcRank(RankGroup &grp) if ((doScore) && (doTime)) { #ifdef RANK_DEBUG - std::cerr << "Final (alg) score:" << algScore; + std::cerr << "Old (alg) score:" << algScore; + std::cerr << std::endl; + std::cerr << "Final (Combo) score:" << comboScore; std::cerr << std::endl; #endif - return algScore; + + if (comboScore < 0) + { +#ifdef RANK_DEBUG + std::cerr << "Combo score reset = 0"; + std::cerr << std::endl; +#endif + comboScore = 0; + } + return comboScore; + } else if (doScore) { #ifdef RANK_DEBUG - std::cerr << "Final (pop) score:" << count; + std::cerr << "Old (tally) score:" << count; + std::cerr << std::endl; + std::cerr << "Final (pop) score:" << popScore; std::cerr << std::endl; #endif - return count; + if (popScore < 0) + { +#ifdef RANK_DEBUG + std::cerr << "Pop score reset = 0"; + std::cerr << std::endl; +#endif + popScore = 0; + } + return popScore; } else if (doTime) {