Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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
Timo Ewalds authored

Showing 2 changed files with 15 additions and 14 deletions. Show diff stats Hide diff stats

  1. +8 7 player.h
  2. +7 7 playeruct.cpp
15 player.h
@@ -94,7 +94,7 @@ class Player {
94 94
95 95 struct Node {
96 96 class Children {
97   - uint16_t _num;
  97 + uint32_t _num;
98 98 Node * _children;
99 99 public:
100 100 typedef Node * iterator;
@@ -161,15 +161,16 @@ class Player {
161 161 public:
162 162 ExpPair rave;
163 163 ExpPair exp;
164   - ExpPair know;
  164 + int16_t know;
  165 + int16_t outcome;
165 166 Move move;
166 167 Move bestmove; //if outcome is set, then bestmove is the way to get there
167   - int16_t outcome;
168 168 Children children;
  169 + //seems to need padding to multiples of 8 bytes or it segfaults?
169 170 //don't forget to update the copy constructor/operator
170 171
171   - Node() : outcome(-1) { }
172   - Node(const Move & m, char o = -1) : move(m), outcome(o) { }
  172 + Node() : know(0), outcome(-1) { }
  173 + Node(const Move & m, char o = -1) : know(0), outcome(o), move(m) { }
173 174 Node(const Node & n) { *this = n; }
174 175 Node & operator = (const Node & n){
175 176 if(this != & n){ //don't copy to self
@@ -270,8 +271,8 @@ class Player {
270 271 if(exp.num()) val += (1-alpha)*exp.avg();
271 272 }
272 273
273   - if(know.sum() > 0)
274   - val += knowfactor * know.sum() / sqrt((float)(exp.num() + 1));
  274 + if(know > 0)
  275 + val += knowfactor * know / sqrt((float)(exp.num() + 1));
275 276
276 277 return val;
277 278 }
14 playeruct.cpp
@@ -289,20 +289,20 @@ void Player::update_rave(const Node * node, const RaveMoveList & movelist, int w
289 289 }
290 290
291 291 void Player::add_knowledge(Board & board, Node * node, Node * child){
292   - if(localreply){ //give exp boost for moves near the previous move
  292 + if(localreply){ //boost for moves near the previous move
293 293 int dist = node->move.dist(child->move);
294 294 if(dist < 4)
295   - child->know.addwins(4 - dist);
  295 + child->know += 4 - dist;
296 296 }
297 297
298   - if(locality) //give exp boost for moves near previous stones
299   - child->know.addwins(board.local(child->move));
  298 + if(locality) //boost for moves near previous stones
  299 + child->know += board.local(child->move);
300 300
301 301 if(connect) //boost for moves that connect to edges/corners
302   - child->know.addwins(board.test_connectivity(child->move));
  302 + child->know += board.test_connectivity(child->move);
303 303
304   - if(bridge && test_bridge_probe(board, node->move, child->move))
305   - child->know.addwins(5);
  304 + if(bridge && test_bridge_probe(board, node->move, child->move)) //boost for maintaining a virtual connection
  305 + child->know += 5;
306 306 }
307 307
308 308 //test whether this move is a forced reply to the opponent probing your virtual connections

0 comments on commit d27ab80

Please sign in to comment.
Something went wrong with that request. Please try again.