Skip to content

Commit

Permalink
made several modifications. doesn't really learn anymore, so probably…
Browse files Browse the repository at this point in the history
… removed some vital obs.
  • Loading branch information
xinpw8 committed Jan 24, 2025
1 parent 70481aa commit 598d741
Show file tree
Hide file tree
Showing 5 changed files with 174 additions and 365 deletions.
21 changes: 9 additions & 12 deletions pufferlib/ocean/blastar/blastar.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,10 @@

#include "puffernet.h"

const char* WEIGHTS_PATH =
"/home/daa/pufferlib_testbench/PufferLib/pufferlib/resources/blastar/"
"blastar_weights.bin";
#define OBSERVATIONS_SIZE 31
const char* WEIGHTS_PATH = "/home/daa/pufferlib_testbench/PufferLib/pufferlib/resources/blastar/blastar_weights.bin";
#define OBSERVATIONS_SIZE 20
#define ACTIONS_SIZE 6
#define NUM_WEIGHTS 137095
#define NUM_WEIGHTS 135687

void get_input(BlastarEnv* env) {
// Left
Expand All @@ -35,28 +33,28 @@ void get_input(BlastarEnv* env) {
else if (IsKeyDown(KEY_SPACE)) {
env->actions[0] = 5;
}
// No action
// Noop
else {
env->actions[0] = 0;
}
}

int demo() {
Weights* weights = load_weights(WEIGHTS_PATH, NUM_WEIGHTS);
LinearLSTM* net =
make_linearlstm(weights, 1, OBSERVATIONS_SIZE, ACTIONS_SIZE);
LinearLSTM* net = make_linearlstm(weights, 1, OBSERVATIONS_SIZE, ACTIONS_SIZE);

BlastarEnv env = {
.player.x = SCREEN_WIDTH / 2,
.player.y = SCREEN_HEIGHT - PLAYER_HEIGHT,
.num_obs = OBSERVATIONS_SIZE,
};
allocate(&env);

Client* client = make_client(&env);

unsigned int seed = 12345;
srand(seed);
reset(&env);
c_reset(&env);

int running = 1;
while (running) {
Expand All @@ -67,7 +65,7 @@ int demo() {
}

c_step(&env);
render(client, &env);
c_render(client, &env);

if (WindowShouldClose() || env.game_over) {
running = 0;
Expand All @@ -83,12 +81,11 @@ int demo() {

void perftest(float test_time) {
BlastarEnv env;
init(&env);
allocate(&env);

unsigned int seed = 12345;
srand(seed);
reset(&env);
c_reset(&env);

int start = time(NULL);
int steps = 0;
Expand Down
Loading

0 comments on commit 598d741

Please sign in to comment.