Skip to content

Commit 579f978

Browse files
committed
models
1 parent a919ca7 commit 579f978

5 files changed

Lines changed: 10 additions & 11 deletions

File tree

ocean/g2048/g2048.c

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#include "g2048.h"
2-
#include "g2048_net.h"
2+
#include "puffernet.h"
33

44
#define OBS_DIM 16
55
#define HIDDEN_DIM 512
@@ -8,7 +8,6 @@
88
#define NO_RENDER false
99
#define NUM_EVAL_RUNS 200
1010

11-
/*
1211
void demo() {
1312
srand(time(NULL));
1413
Game env = {
@@ -17,8 +16,8 @@ void demo() {
1716
init(&env);
1817

1918
unsigned char observations[OBS_DIM] = {0};
20-
unsigned char terminals[1] = {0};
21-
int actions[1] = {0};
19+
float terminals[1] = {0};
20+
float actions[1] = {0};
2221
float rewards[1] = {0};
2322

2423
env.observations = observations;
@@ -27,7 +26,8 @@ void demo() {
2726
env.rewards = rewards;
2827

2928
Weights* weights = load_weights("resources/g2048/g2048_weights.bin", 3466859);
30-
G2048Net* net = make_g2048net(weights, HIDDEN_DIM);
29+
int logit_sizes[1] = {4};
30+
PufferNet* net = make_puffernet(weights, 1, OBS_DIM, HIDDEN_DIM, 5, logit_sizes, 1);
3131
c_reset(&env);
3232
if (!NO_RENDER) c_render(&env);
3333
printf("Starting...\n");
@@ -53,7 +53,9 @@ void demo() {
5353
continue;
5454
} else {
5555
action = 1;
56-
forward_g2048net(net, env.observations, env.actions);
56+
float obs_f[OBS_DIM];
57+
for (int i = 0; i < OBS_DIM; i++) obs_f[i] = (float)env.observations[i];
58+
forward_puffernet(net, obs_f, env.actions);
5759
}
5860

5961
if (action > 0) {
@@ -86,13 +88,11 @@ void demo() {
8688
if (NO_RENDER && trial > NUM_EVAL_RUNS) break;
8789
}
8890

89-
free_g2048net(net);
91+
free_puffernet(net);
9092
free(weights);
9193
c_close(&env);
9294
printf("Finished %d trials.\n", NUM_EVAL_RUNS);
93-
return 0;
9495
}
95-
*/
9696

9797
void perftest() {
9898

@@ -104,7 +104,7 @@ void perftest() {
104104

105105
unsigned char observations[OBS_DIM] = {0};
106106
float terminals[1] = {0};
107-
double actions[1] = {0};
107+
float actions[1] = {0};
108108
float rewards[1] = {0};
109109

110110
env.observations = observations;
@@ -135,4 +135,3 @@ int main() {
135135
perftest();
136136
return 0;
137137
}
138-
-451 KB
Binary file not shown.

resources/moba/moba_weights.bin

-1.09 MB
Binary file not shown.

resources/nmmo3/nmmo3_weights.bin

3.98 MB
Binary file not shown.

resources/pong/pong_weights.bin

-509 KB
Binary file not shown.

0 commit comments

Comments
 (0)