Skip to content
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
47 changes: 28 additions & 19 deletions config/craftax.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,37 @@
env_name = craftax

[vec]
total_agents = 16384
num_buffers = 16
num_threads = 16
total_agents = 8192
num_buffers = 4
num_threads = 8

[env]
seed_offset = 0
# Pre-generated world pool. Each reset memcpys from a pool entry
# instead of re-running generate_world (~ms -> ~us per reset).
# Bounds world diversity: at most reset_pool_size unique maps are
# ever seen per process. Set to 0 to disable (required for the
# parity harness to maintain exact per-seed determinism).
reset_pool_size = 1024
action_mask = 1

[policy]
hidden_size = 1024
num_layers = 3.95689535

[train]
total_timesteps = 20_000_000_000
learning_rate = 0.008
ent_coef = 0.02
gamma = 0.997
gae_lambda = 0.95
horizon = 128
minibatch_size = 32768
gpus = 1
total_timesteps = 200_000_000
learning_rate = 0.00212870375
anneal_lr = 1
min_lr_ratio = 0.0
gamma = 0.980109215
gae_lambda = 0.741049647
replay_ratio = 1.59645867
clip_coef = 0.361835271
vf_coef = 3.47198796
vf_clip_coef = 3.29685092
max_grad_norm = 1.08277392
ent_coef = 8.97720674e-05
anneal_ent_coef = 0
min_ent_coef_ratio = 0.1
momentum = 0.965376794
minibatch_size = 4096
horizon = 32

[policy]
hidden_size = 32
num_layers = 3
[sweep]
max_suggestion_cost = 7200
38 changes: 0 additions & 38 deletions config/craftax_clean.ini

This file was deleted.

Binary file removed craftax_clean
Binary file not shown.
543 changes: 0 additions & 543 deletions ocean/craftax/PORT_NOTES.md

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
// Environment parameters
#define DEFAULT_MAX_TIMESTEPS 100000
#define DAY_LENGTH 300
#define VISIBLE_LIGHT_THRESHOLD 12
#define MAX_ATTRIBUTE 5
#define MOB_DESPAWN_DISTANCE 14
#define MONSTERS_KILLED_TO_CLEAR_LEVEL 8
Expand Down Expand Up @@ -447,11 +448,13 @@ static const DungeonConfig DUNGEON_LEVEL_CONFIGS[3] = {
};


// Rendering parameters. tiles.png is 16x16 RGBA tiles, row-major, 16 columns:
// Rendering parameters. textures.png is 16x16 RGBA tiles, row-major, 16 columns:
// [0..36] blocks [37..41] player [42..46] items [47..49] generic mobs
// [50..53] arrows [54..61] armour [62..70] tools [71..76] potions
// [77..79] HUD [80..87] melee [88..90] passive [91..98] ranged
// [99..102] projectiles
// [103..104] sword enchant [105..106] arrow enchant
// [107..110] armour fire overlay [111..114] armour ice overlay
#define TEX_TILE_PX 16
#define TEX_SHEET_COLS 16
#define TEX_SCALE 3
Expand Down
49 changes: 20 additions & 29 deletions ocean/craftax/craftax.c
Original file line number Diff line number Diff line change
@@ -1,40 +1,30 @@
// Standalone viewer for Craftax (random-action policy).
//
// Build:
// ./build.sh craftax --cpu # optimized
// ./build.sh craftax --debug # debug with sanitizers
// Run:
// ./craftax

#define CRAFTAX_ENABLE_ENV_IMPL
#include "craftax.h"
#include "step_crafting.h"
#include "step_update_mobs.h"
#include "step_spawn_mobs.h"

#include <stdio.h>
#include <stdlib.h>
#include <time.h>

int main(int argc, char** argv) {
uint64_t seed = (argc > 1) ? strtoull(argv[1], NULL, 10) : (uint64_t)time(NULL);

int main(void) {
Craftax env;
memset(&env, 0, sizeof(env));
env.num_agents = 1;
env.seed = seed;
env.rng = (uint32_t)seed;

// Minimal buffers for a single agent
env.agents[0].observations = calloc(CRAFTAX_OBS_SIZE, sizeof(float));
env.agents[0].actions = calloc(1, sizeof(float));
env.agents[0].rewards = calloc(1, sizeof(float));
env.agents[0].terminals = calloc(1, sizeof(float));

c_init(&env);
env.rng = 1;
env.seed = 1;
env.use_action_mask = 1;

env.agents[0].observations = (obs_t*)calloc(OBS_SIZE, sizeof(obs_t));
env.agents[0].actions = (float*)calloc(1, sizeof(float));
env.agents[0].rewards = (float*)calloc(1, sizeof(float));
env.agents[0].terminals = (float*)calloc(1, sizeof(float));
env.agents[0].action_mask = (unsigned char*)calloc(ATN_DIM, 1);
puf_reset(&env);
env.agents[0].actions[0] = -1.0f;

puf_render(&env);
while (!WindowShouldClose()) {
int action = key_to_action();
if (action < 0) {
env.agents[0].actions[0] = -1.0f;
puf_render(&env);
continue;
}
env.agents[0].actions[0] = (float)action;
puf_step(&env);
puf_render(&env);
}
Expand All @@ -44,5 +34,6 @@ int main(int argc, char** argv) {
free(env.agents[0].actions);
free(env.agents[0].rewards);
free(env.agents[0].terminals);
free(env.agents[0].action_mask);
return 0;
}
Loading
Loading