Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Switch from an ExpPair to a small int, shrink the Node size by 8 byte…

…s, and find part of the cause of the segfaults...
  • Loading branch information...
commit d27ab80f047e926df559a3af515fe491928f415a 1 parent b135336
@tewalds authored
Showing with 15 additions and 14 deletions.
  1. +8 −7 player.h
  2. +7 −7 playeruct.cpp
View
15 player.h
@@ -94,7 +94,7 @@ class Player {
struct Node {
class Children {
- uint16_t _num;
+ uint32_t _num;
Node * _children;
public:
typedef Node * iterator;
@@ -161,15 +161,16 @@ class Player {
public:
ExpPair rave;
ExpPair exp;
- ExpPair know;
+ int16_t know;
+ int16_t outcome;
Move move;
Move bestmove; //if outcome is set, then bestmove is the way to get there
- int16_t outcome;
Children children;
+ //seems to need padding to multiples of 8 bytes or it segfaults?
//don't forget to update the copy constructor/operator
- Node() : outcome(-1) { }
- Node(const Move & m, char o = -1) : move(m), outcome(o) { }
+ Node() : know(0), outcome(-1) { }
+ Node(const Move & m, char o = -1) : know(0), outcome(o), move(m) { }
Node(const Node & n) { *this = n; }
Node & operator = (const Node & n){
if(this != & n){ //don't copy to self
@@ -270,8 +271,8 @@ class Player {
if(exp.num()) val += (1-alpha)*exp.avg();
}
- if(know.sum() > 0)
- val += knowfactor * know.sum() / sqrt((float)(exp.num() + 1));
+ if(know > 0)
+ val += knowfactor * know / sqrt((float)(exp.num() + 1));
return val;
}
View
14 playeruct.cpp
@@ -289,20 +289,20 @@ void Player::update_rave(const Node * node, const RaveMoveList & movelist, int w
}
void Player::add_knowledge(Board & board, Node * node, Node * child){
- if(localreply){ //give exp boost for moves near the previous move
+ if(localreply){ //boost for moves near the previous move
int dist = node->move.dist(child->move);
if(dist < 4)
- child->know.addwins(4 - dist);
+ child->know += 4 - dist;
}
- if(locality) //give exp boost for moves near previous stones
- child->know.addwins(board.local(child->move));
+ if(locality) //boost for moves near previous stones
+ child->know += board.local(child->move);
if(connect) //boost for moves that connect to edges/corners
- child->know.addwins(board.test_connectivity(child->move));
+ child->know += board.test_connectivity(child->move);
- if(bridge && test_bridge_probe(board, node->move, child->move))
- child->know.addwins(5);
+ if(bridge && test_bridge_probe(board, node->move, child->move)) //boost for maintaining a virtual connection
+ child->know += 5;
}
//test whether this move is a forced reply to the opponent probing your virtual connections
Please sign in to comment.
Something went wrong with that request. Please try again.