Skip to content
This repository was archived by the owner on Dec 11, 2020. It is now read-only.

I fixed static #117

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 5 additions & 24 deletions src_cpp/elfgames/tasks/Game.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ class State {
// helper functions for compatibility with some parts of ELF2, you might ignore this..
int nextPlayer() const {
if (_status == 0) return 1; // S_BLACK FIXME
if (_status == 1) return 2; // S_WHITE FIXME dirty hack, I do not use S_WHITE because common.h not included
if (_status == 1) return 0; // S_WHITE FIXME dirty hack, I do not use S_WHITE because common.h not included
//std::cout << "OTG-nextplayer crashes " << _status << std::endl;
return 0;
}
Expand Down Expand Up @@ -217,6 +217,9 @@ const int MaxPlayoutLength = 1000;

const int MaxMoveNumber = 80 * 2 * 2 * (3 * Dx * Dy) + 1;

const unsigned long long HashArray [2] [Dx] [Dy] = {{{16169835459508955805ULL,8687539127158664826ULL,17108160493861513873ULL,14866772039050829819ULL,6382425218817137013ULL,14755416853480619523ULL,262222823330570628ULL,13725127845745622661ULL},{3636680052915828731ULL,16420612890348964839ULL,6860860612143234356ULL,18319421942982323461ULL,7517309626840007552ULL,10232127189939683483ULL,955717582448734283ULL,8667483786766950674ULL},{2140948988612357176ULL,13169326505115950933ULL,9043089259473408367ULL,14996796748455957877ULL,15690658049786921672ULL,14036214656995497049ULL,8074374651246879349ULL,7438200393285415060ULL},{11187005889026272334ULL,12949944768259122662ULL,15040907901836627032ULL,12763962205942898831ULL,16979172226678533126ULL,4767380695075439596ULL,11357595680782992511ULL,18317812704978456668ULL},{14917024458661891820ULL,7153012356196806730ULL,7046853297116196052ULL,13589609198741071495ULL,6790311378931853624ULL,16395541026852423248ULL,11689928350345550686ULL,11066307942870238330ULL},{166037065768007008ULL,11418603408886607759ULL,12495334242248696588ULL,2313557874151223826ULL,14577118380010101296ULL,15648089824920020193ULL,4971894234579520583ULL,11057316417677697807ULL},{8207667517007284943ULL,8523579834061669855ULL,8940007351769745059ULL,10968608755118922263ULL,1559018261319330017ULL,14782379423393254003ULL,14762225579280523571ULL,10944216625444453360ULL},{3736596993699687090ULL,9537226116780554838ULL,6137756171499266159ULL,15518337951594466340ULL,8949482491910899126ULL,12000694956930405168ULL,17197495493249131043ULL,12035377088540875303ULL}},{{11072182272252713633ULL,18010027927339653559ULL,5566153019321090447ULL,12179673189384747138ULL,13568320540822843442ULL,11695876895037360369ULL,6786324505691748745ULL,11971963882150787078ULL},{3292727085030657134ULL,16040269400726833725ULL,205205274671649419ULL,5414198750221716225ULL,14822232492594364459ULL,8087037031988850037ULL,7074371490665697308ULL,11201942530787631417ULL},{15302063331589353095ULL,10139618060405873107ULL,10885973555582100003ULL,700768787738394253ULL,11436380602037827173ULL,3962337549481533006ULL,7610480833667588795ULL,2068365834880889651ULL},{14479802558981603625ULL,4775538863591284692ULL,11861314192536164614ULL,5571373744305498377ULL,16087187627008913836ULL,12690383218059263823ULL,13938852539599657576ULL,11534571120884325585ULL},{6103925850415086531ULL,16583445213172046727ULL,11055383655933654569ULL,11036500694084901452ULL,1216696450232701521ULL,15355059884847912069ULL,6948082711389627959ULL,13186654485806700998ULL},{1223503520381324471ULL,3202032567972352774ULL,14182058217600591584ULL,16345366887391355636ULL,7938496525083787096ULL,6733969192016572985ULL,1207955508137446886ULL,4689090394441190407ULL},{13051004392307142196ULL,15419649645945058733ULL,8999056803418768900ULL,13866985612211194599ULL,17241193493089699198ULL,6642778445250924916ULL,4214693391800225934ULL,1785700724540658093ULL},{3779965625422541689ULL,18198938396262131434ULL,13755289309211499846ULL,10967706938447926321ULL,10351157047240713263ULL,15428463797457287716ULL,5518344826184209350ULL,15376329534511616666ULL}}};
const unsigned long long HashTurn = 7558115252641239713ULL;

class Move {
public :
int x, y, x1, y1, color;
Expand Down Expand Up @@ -246,9 +249,6 @@ class Move {

class StateForChouFleur : public State {
public:
unsigned long long HashArray [2] [Dx] [Dy];
unsigned long long HashTurn;

int board [Dx] [Dy];
unsigned long long hash;
Move rollout [MaxPlayoutLength];
Expand All @@ -267,7 +267,7 @@ class StateForChouFleur : public State {
hash = 0;
length = 0;
turn = White;
initHash ();
//initHash ();
}

bool won (int color) {
Expand Down Expand Up @@ -460,25 +460,6 @@ class StateForChouFleur : public State {
return nb;
}

void initHash () {
static bool initHashCalled = false;
if (initHashCalled == false) {
initHashCalled = true;
for (int player = 0; player < 2; player++)
for (int i = 0; i < Dx; i++)
for (int j = 0; j < Dy; j++) {
HashArray [player] [i] [j] = 0;
for (int k = 0; k < 64; k++)
if ((rand () / (RAND_MAX + 1.0)) > 0.5)
HashArray [player] [i] [j] |= (1ULL << k);
}
HashTurn = 0;
for (int k = 0; k < 64; k++)
if ((rand () / (RAND_MAX + 1.0)) > 0.5)
HashTurn |= (1ULL << k);
}
}

StateForChouFleur():State() {
// std::cout << "OTGChouFleur CreateState" << std::endl;
Initialize();
Expand Down
1 change: 1 addition & 0 deletions src_py/elf/utils_elf.py
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,7 @@ def _call(self, smem, *args, **kwargs):
# If reply is meaningful, send them back.
if isinstance(reply, dict) and sel_reply is not None:
if self.gpu is not None:
print ("self.gpu = ", self.gpu)
with torch.cuda.device(self.gpu):
keys_extra, keys_missing = sel_reply.copy_from(reply)
else:
Expand Down
9 changes: 5 additions & 4 deletions src_py/elfgames/tasks/df_model3.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ def get_option_spec(cls):
'gpu',
'which gpu to use',
-1)
# 1)

spec.merge(GoResNet.get_option_spec())

Expand Down Expand Up @@ -213,10 +214,10 @@ def __init__(self, option_map, params):
self.resnet = GoResNet(option_map, params)

if torch.cuda.is_available() and self.options.gpu is not None:
#self.init_conv.cuda(self.options.gpu)
#self.resnet.cuda(self.options.gpu)
self.init_conv.cuda(0)
self.resnet.cuda(0)
self.init_conv.cuda(self.options.gpu)
self.resnet.cuda(self.options.gpu)
#self.init_conv.cuda(1)
#self.resnet.cuda(1)

if self.options.use_data_parallel:
if self.options.gpu is not None:
Expand Down
1 change: 1 addition & 0 deletions src_py/rlpytorch/model_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ def clone(self, gpu=None):
"""
mi = ModelInterface(self.option_map)
for key, model in self.models.items():
print ("gpu = ", gpu)
mi.models[key] = model.clone(gpu=gpu)
if key in self.optimizers:
# Same parameters.
Expand Down