Fixed strength calculation, yay
This commit is contained in:
parent
1a555b900c
commit
a71ab74a9c
11
gamedata.cpp
11
gamedata.cpp
|
@ -3,6 +3,7 @@
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <cassert>
|
||||||
|
|
||||||
using std::list;
|
using std::list;
|
||||||
|
|
||||||
|
@ -109,6 +110,8 @@ float GameData::calculate_strength_r(Vertex* node, unsigned int depth, list<Vert
|
||||||
list<Edge> es = get_vertex_edges(node);
|
list<Edge> es = get_vertex_edges(node);
|
||||||
list<Vertex*> to_visit;
|
list<Vertex*> to_visit;
|
||||||
|
|
||||||
|
visited.push_back(node);
|
||||||
|
|
||||||
for (list<Edge>::iterator cursor = es.begin(); cursor != es.end();
|
for (list<Edge>::iterator cursor = es.begin(); cursor != es.end();
|
||||||
cursor++)
|
cursor++)
|
||||||
{
|
{
|
||||||
|
@ -120,19 +123,17 @@ float GameData::calculate_strength_r(Vertex* node, unsigned int depth, list<Vert
|
||||||
{
|
{
|
||||||
to_visit.push_back(e.b);
|
to_visit.push_back(e.b);
|
||||||
}
|
}
|
||||||
else if (e.a == node &&
|
else if (e.b == node &&
|
||||||
find(visited.begin(), visited.end(), e.b) == visited.end())
|
find(visited.begin(), visited.end(), e.a) == visited.end())
|
||||||
{
|
{
|
||||||
to_visit.push_back(e.a);
|
to_visit.push_back(e.a);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
visited.push_back(node);
|
|
||||||
|
|
||||||
// This is the base case - this node has no unvisited neighbors
|
// This is the base case - this node has no unvisited neighbors
|
||||||
if (to_visit.empty())
|
if (to_visit.empty())
|
||||||
{
|
{
|
||||||
fprintf(stderr, "At a leaf, and score=%f, depth=%d\n", (float)node->score, depth);
|
assert(depth > 0);
|
||||||
return (float)(node->score) / depth;
|
return (float)(node->score) / depth;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user