-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Mikel
committed
Nov 15, 2024
1 parent
ed1d7d3
commit 662259a
Showing
15 changed files
with
205 additions
and
0 deletions.
There are no files selected for viewing
55 changes: 55 additions & 0 deletions
55
craftium-envs/multi-agent-combat/clientmods/craftium_mod/init.lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
channel_name = "craftium_channel" | ||
mod_channel = nil | ||
|
||
minetest.register_globalstep(function(dtime) | ||
-- If soft-reset is requested by craftium, thoen send a message to | ||
-- the server to reset the environment | ||
if get_soft_reset() == 1 then | ||
mod_channel:send_all( | ||
minetest.serialize({ | ||
agent = "server", | ||
reset = true, | ||
}) | ||
) | ||
reset_termination() | ||
end | ||
end) | ||
|
||
-- Function to check if the client has fully loaded | ||
wait_for_client_ready = function() | ||
if minetest.localplayer then | ||
-- Client has joined the server and is fully loaded | ||
callback() | ||
else | ||
-- Retry after a short delay if not yet fully initialized | ||
minetest.after(0.01, function() wait_for_client_ready() end) | ||
end | ||
end | ||
|
||
-- Callback executed once the client is fully initialized | ||
callback = function() | ||
-- Join the mod channel and set up listeners here | ||
mod_channel = minetest.mod_channel_join(channel_name) | ||
|
||
minetest.register_on_modchannel_message(function(channel, sender, str_message) | ||
if channel ~= channel_name then | ||
return | ||
end | ||
|
||
local msg = minetest.deserialize(str_message) | ||
|
||
if msg.agent ~= minetest.localplayer:get_name() then | ||
return | ||
end | ||
|
||
if msg.reward ~= nil then | ||
set_reward_once(msg.reward, 0.0) | ||
end | ||
|
||
if msg.termination == true then | ||
set_termination() | ||
end | ||
end) | ||
end | ||
|
||
wait_for_client_ready() |
3 changes: 3 additions & 0 deletions
3
craftium-envs/multi-agent-combat/clientmods/craftium_mod/mod.conf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
name = craftium_mod | ||
description = Craftium environment | ||
# depends = default |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
load_mod_craftium_mod = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../minetest_game |
70 changes: 70 additions & 0 deletions
70
craftium-envs/multi-agent-combat/mods/craftium_env/init.lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
local channel = minetest.mod_channel_join("craftium_channel") | ||
|
||
num_players = 0 | ||
|
||
reset_player = function(player) | ||
-- Set the name tag color to transparent | ||
player:set_nametag_attributes({color = {a = 0, r = 0, g = 0, b = 0}}) | ||
|
||
player:set_hp(20, {type = "set_hp", from = "mod" }) | ||
|
||
-- Set the player's initial position and yaw | ||
if player:get_player_name() == "agent0" then | ||
player:set_pos({x = -2.5, y = 4.5, z = -1.7}) | ||
player:set_look_horizontal(3.1416) | ||
else | ||
player:set_pos({x = -2.5, y = 4.5, z = -8.5}) | ||
player:set_look_horizontal(0) | ||
end | ||
|
||
-- Disable HUD elements | ||
player:hud_set_flags({ | ||
hotbar = false, | ||
crosshair = false, | ||
healthbar = false, | ||
chat = false, | ||
}) | ||
end | ||
|
||
minetest.register_on_joinplayer(function(player, _last_login) | ||
num_players = num_players + 1 | ||
reset_player(player) | ||
end) | ||
|
||
minetest.register_globalstep(function(dtime) | ||
-- Set timeofday to midday | ||
minetest.set_timeofday(0.5) | ||
end) | ||
|
||
minetest.register_on_modchannel_message(function(channel, sender, str_message) | ||
if channel ~= "craftium_channel" then | ||
return | ||
end | ||
|
||
local msg = minetest.deserialize(str_message) | ||
|
||
if msg.agent ~= "server" then | ||
return | ||
end | ||
|
||
if msg.reset == true then | ||
for _, player in pairs(minetest.get_connected_players()) do | ||
reset_player(player) | ||
end | ||
end | ||
end) | ||
|
||
minetest.register_on_punchplayer(function(player, hitter, time_from_last_punch, tool_capabilities, dir, damage) | ||
-- Get the names of both players involved | ||
local player_name = player:get_player_name() | ||
-- local hitter_name = hitter:get_player_name() | ||
|
||
-- NOTE The player's health is updated after this callback, so the real hp will be get_hp()-1 | ||
channel:send_all( | ||
minetest.serialize({ | ||
agent = hitter:get_player_name(), | ||
reward = 1.0, | ||
termination = (player:get_hp() - 1) <= 5 | ||
}) | ||
) | ||
end) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
name = craftium_env | ||
description = Craftium environment | ||
depends = default |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../common_mods/superflat |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
day_count = 12480 | ||
lbm_introduction_times = :farming:start_nodetimer_cotton~0;default:convert_saplings_to_node_timer~0;:doors:replace_doors_door_glass~0;:doors:replace_doors_door_obsidian_glass~0;default:upgrade_chest_v2~0;xpanes:gen2~0;default:3dtorch~0;:farming:start_nodetimer_wheat~0;:doors:replace_doors_door_wood~0;:doors:replace_doors_door_steel~0;default:upgrade_chest_locked_v2~0;:doors:replace_xpanes_door_steel_bar~0; | ||
lbm_introduction_times_version = 1 | ||
last_clear_objects_time = 0 | ||
time_of_day = 12000 | ||
game_time = 1330 | ||
EnvArgsEnd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
return {} |
Binary file not shown.
47 changes: 47 additions & 0 deletions
47
craftium-envs/multi-agent-combat/worlds/world/map_meta.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
mg_biome_np_humidity_blend = { | ||
flags = defaults | ||
lacunarity = 2 | ||
persistence = 1 | ||
seed = 90003 | ||
spread = (8,8,8) | ||
scale = 1.5 | ||
octaves = 2 | ||
offset = 0 | ||
} | ||
mg_biome_np_heat_blend = { | ||
flags = defaults | ||
lacunarity = 2 | ||
persistence = 1 | ||
seed = 13 | ||
spread = (8,8,8) | ||
scale = 1.5 | ||
octaves = 2 | ||
offset = 0 | ||
} | ||
mg_flags = caves, dungeons, light, decorations, biomes, ores | ||
chunksize = 5 | ||
mapgen_limit = 31007 | ||
mg_biome_np_heat = { | ||
flags = defaults | ||
lacunarity = 2 | ||
persistence = 0.5 | ||
seed = 5349 | ||
spread = (1000,1000,1000) | ||
scale = 50 | ||
octaves = 3 | ||
offset = 50 | ||
} | ||
water_level = 1 | ||
mg_biome_np_humidity = { | ||
flags = defaults | ||
lacunarity = 2 | ||
persistence = 0.5 | ||
seed = 842 | ||
spread = (1000,1000,1000) | ||
scale = 50 | ||
octaves = 3 | ||
offset = 50 | ||
} | ||
seed = 13264707149538330578 | ||
mg_name = singlenode | ||
[end_of_params] |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
sflat.Y_ORIGIN = 1 | ||
sflat.BLOCKS = "superflat:bedrock,default:steelblock" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
enable_damage = false | ||
creative_mode = true | ||
mod_storage_backend = sqlite3 | ||
auth_backend = sqlite3 | ||
player_backend = sqlite3 | ||
backend = sqlite3 | ||
gameid = minetest | ||
world_name = world | ||
server_announce = false | ||
load_mod_superflat = mods/superflat | ||
load_mod_craftium_env = mods/craftium_env | ||
load_mod_mobs_monster = mods/mobs_monster | ||
load_mod_mobs = mods/mobs | ||
load_mod_mobs_animal = false |