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

Commit 5326322

Browse files
authored
Merge pull request #117 from tristancazenave/tristan_breakthrough
I fixed static
2 parents 4edb132 + f844228 commit 5326322

File tree

4 files changed

+12
-28
lines changed

4 files changed

+12
-28
lines changed

src_cpp/elfgames/tasks/Game.h

Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ class State {
130130
// helper functions for compatibility with some parts of ELF2, you might ignore this..
131131
int nextPlayer() const {
132132
if (_status == 0) return 1; // S_BLACK FIXME
133-
if (_status == 1) return 2; // S_WHITE FIXME dirty hack, I do not use S_WHITE because common.h not included
133+
if (_status == 1) return 0; // S_WHITE FIXME dirty hack, I do not use S_WHITE because common.h not included
134134
//std::cout << "OTG-nextplayer crashes " << _status << std::endl;
135135
return 0;
136136
}
@@ -217,6 +217,9 @@ const int MaxPlayoutLength = 1000;
217217

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

220+
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}}};
221+
const unsigned long long HashTurn = 7558115252641239713ULL;
222+
220223
class Move {
221224
public :
222225
int x, y, x1, y1, color;
@@ -246,9 +249,6 @@ class Move {
246249

247250
class StateForChouFleur : public State {
248251
public:
249-
unsigned long long HashArray [2] [Dx] [Dy];
250-
unsigned long long HashTurn;
251-
252252
int board [Dx] [Dy];
253253
unsigned long long hash;
254254
Move rollout [MaxPlayoutLength];
@@ -267,7 +267,7 @@ class StateForChouFleur : public State {
267267
hash = 0;
268268
length = 0;
269269
turn = White;
270-
initHash ();
270+
//initHash ();
271271
}
272272

273273
bool won (int color) {
@@ -460,25 +460,6 @@ class StateForChouFleur : public State {
460460
return nb;
461461
}
462462

463-
void initHash () {
464-
static bool initHashCalled = false;
465-
if (initHashCalled == false) {
466-
initHashCalled = true;
467-
for (int player = 0; player < 2; player++)
468-
for (int i = 0; i < Dx; i++)
469-
for (int j = 0; j < Dy; j++) {
470-
HashArray [player] [i] [j] = 0;
471-
for (int k = 0; k < 64; k++)
472-
if ((rand () / (RAND_MAX + 1.0)) > 0.5)
473-
HashArray [player] [i] [j] |= (1ULL << k);
474-
}
475-
HashTurn = 0;
476-
for (int k = 0; k < 64; k++)
477-
if ((rand () / (RAND_MAX + 1.0)) > 0.5)
478-
HashTurn |= (1ULL << k);
479-
}
480-
}
481-
482463
StateForChouFleur():State() {
483464
// std::cout << "OTGChouFleur CreateState" << std::endl;
484465
Initialize();

src_py/elf/utils_elf.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,7 @@ def _call(self, smem, *args, **kwargs):
403403
# If reply is meaningful, send them back.
404404
if isinstance(reply, dict) and sel_reply is not None:
405405
if self.gpu is not None:
406+
print ("self.gpu = ", self.gpu)
406407
with torch.cuda.device(self.gpu):
407408
keys_extra, keys_missing = sel_reply.copy_from(reply)
408409
else:

src_py/elfgames/tasks/df_model3.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ def get_option_spec(cls):
159159
'gpu',
160160
'which gpu to use',
161161
-1)
162+
# 1)
162163

163164
spec.merge(GoResNet.get_option_spec())
164165

@@ -213,10 +214,10 @@ def __init__(self, option_map, params):
213214
self.resnet = GoResNet(option_map, params)
214215

215216
if torch.cuda.is_available() and self.options.gpu is not None:
216-
#self.init_conv.cuda(self.options.gpu)
217-
#self.resnet.cuda(self.options.gpu)
218-
self.init_conv.cuda(0)
219-
self.resnet.cuda(0)
217+
self.init_conv.cuda(self.options.gpu)
218+
self.resnet.cuda(self.options.gpu)
219+
#self.init_conv.cuda(1)
220+
#self.resnet.cuda(1)
220221

221222
if self.options.use_data_parallel:
222223
if self.options.gpu is not None:

src_py/rlpytorch/model_interface.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ def clone(self, gpu=None):
7373
"""
7474
mi = ModelInterface(self.option_map)
7575
for key, model in self.models.items():
76+
print ("gpu = ", gpu)
7677
mi.models[key] = model.clone(gpu=gpu)
7778
if key in self.optimizers:
7879
# Same parameters.

0 commit comments

Comments
 (0)