Skip to content

Commit

Permalink
Merge pull request #75 from CarperAI/2.0
Browse files Browse the repository at this point in the history
2.0
  • Loading branch information
jsuarez5341 committed Jun 8, 2023
2 parents 416b7d8 + a670d02 commit b0f0345
Show file tree
Hide file tree
Showing 57 changed files with 2,458 additions and 1,567 deletions.
5 changes: 2 additions & 3 deletions nmmo/__init__.py
Expand Up @@ -4,9 +4,8 @@

from .lib import material, spawn
from .render.overlay import Overlay, OverlayRegistry
from .io import action
from .io.action import Action
from .core import config, agent
from .core import config, agent, action
from .core.action import Action
from .core.agent import Agent
from .core.env import Env
from .core.terrain import MapGenerator, Terrain
Expand Down
10 changes: 6 additions & 4 deletions nmmo/io/action.py → nmmo/core/action.py
Expand Up @@ -117,15 +117,16 @@ def call(realm, entity, direction):
return

assert entity.alive, "Dead entity cannot act"
assert realm.map.is_valid_pos(*entity.pos), "Invalid entity position"

r, c = entity.pos
ent_id = entity.ent_id
entity.history.last_pos = (r, c)
r_delta, c_delta = direction.delta
r_new, c_new = r+r_delta, c+c_delta

# CHECK ME: lava-jumping agents in the tutorial no longer works
if realm.map.tiles[r_new, c_new].impassible:
if not realm.map.is_valid_pos(r_new, c_new) or \
realm.map.tiles[r_new, c_new].impassible:
return

if entity.status.freeze > 0:
Expand All @@ -145,8 +146,9 @@ def call(realm, entity, direction):
realm.event_log.record(EventCode.GO_FARTHEST, entity,
distance=dist_from_spawn)

# CHECK ME: material.Impassible includes lava, so this line is not reachable
if realm.map.tiles[r_new, c_new].lava:
# CHECK ME: material.Impassible includes void, so this line is not reachable
# Does this belong to Entity/Player.update()?
if realm.map.tiles[r_new, c_new].void:
entity.receive_damage(None, entity.resources.health.val)

@staticproperty
Expand Down
33 changes: 18 additions & 15 deletions nmmo/core/config.py
Expand Up @@ -145,10 +145,7 @@ def game_system_enabled(self, name) -> bool:
return hasattr(self, name)


SAVE_REPLAY = False
'''Flag used to save replays'''

PROVIDE_ACTION_TARGETS = False
PROVIDE_ACTION_TARGETS = True
'''Flag used to provide action targets mask'''

PLAYERS = [Agent]
Expand Down Expand Up @@ -220,7 +217,7 @@ def PLAYER_VISION_DIAMETER(self):
############################################################################
### Agent Parameters
IMMORTAL = False
'''Debug parameter: prevents agents from dying except by lava'''
'''Debug parameter: prevents agents from dying except by void'''

BASE_HEALTH = 10
'''Initial Constitution level and agent health'''
Expand Down Expand Up @@ -260,7 +257,7 @@ def MAP_N_OBS(self):
'''Size of each map (number of tiles along each side)'''

MAP_BORDER = 16
'''Number of lava border tiles surrounding each side of the map'''
'''Number of void border tiles surrounding each side of the map'''

@property
def MAP_SIZE(self):
Expand Down Expand Up @@ -329,17 +326,17 @@ class Terrain:
TERRAIN_TILES_PER_OCTAVE = 8
'''Number of octaves sampled from log2 spaced TERRAIN_FREQUENCY range'''

TERRAIN_LAVA = 0.0
'''Noise threshold for lava generation'''
TERRAIN_VOID = 0.0
'''Noise threshold for void generation'''

TERRAIN_WATER = 0.30
'''Noise threshold for water generation'''

TERRAIN_GRASS = 0.70
'''Noise threshold for grass'''

TERRAIN_FOREST = 0.85
'''Noise threshold for forest'''
TERRAIN_FOILAGE = 0.85
'''Noise threshold for foilage (food tile)'''


class Resource:
Expand All @@ -349,7 +346,7 @@ class Resource:
'''Game system flag'''

RESOURCE_BASE = 100
'''Initial level and capacity for Hunting + Fishing resource skills'''
'''Initial level and capacity for food and water'''

RESOURCE_DEPLETION_RATE = 5
'''Depletion rate for food and water'''
Expand All @@ -360,11 +357,11 @@ class Resource:
RESOURCE_DEHYDRATION_RATE = 10
'''Damage per tick without water'''

RESOURCE_FOREST_CAPACITY = 1
'''Maximum number of harvests before a forest tile decays'''
RESOURCE_FOILAGE_CAPACITY = 1
'''Maximum number of harvests before a foilage tile decays'''

RESOURCE_FOREST_RESPAWN = 0.025
'''Probability that a harvested forest tile will regenerate each tick'''
RESOURCE_FOILAGE_RESPAWN = 0.025
'''Probability that a harvested foilage tile will regenerate each tick'''

RESOURCE_HARVEST_RESTORE_FRACTION = 1.0
'''Fraction of maximum capacity restored upon collecting a resource'''
Expand Down Expand Up @@ -433,6 +430,9 @@ class Progression:
PROGRESSION_CONSUMABLE_XP_SCALE = 5
'''Multiplier on top of XP_SCALE for Fishing and Herbalism'''

PROGRESSION_BASE_LEVEL = 1
'''Initial skill level'''

PROGRESSION_LEVEL_MAX = 10
'''Max skill level'''

Expand Down Expand Up @@ -604,6 +604,9 @@ class Exchange:
EXCHANGE_SYSTEM_ENABLED = True
'''Game system flag'''

EXCHANGE_BASE_GOLD = 1
'''Initial gold amount'''

EXCHANGE_LISTING_DURATION = 5
'''The number of ticks, during which the item is listed for sale'''

Expand Down

0 comments on commit b0f0345

Please sign in to comment.