Day 4 - phentos/rl-tutorial-godot GitHub Wiki

Retrospective

A lot was added on Day 3, so I'll definitely be reviewing the project structure to start. One thing I wasn't strong on was how the map tiles were being placed relative to the viewport. Since we're using flat tile array indexing, the current (temporary) approach to placing walls (via for x in range(30, 34): inside the _setup_tiles function of map_data.gd) is basically impossible to intuit. @SelinaDev discussed this decision at some length, but I do miss the strength of a nested list setup (e.g. tiles[x][y]) where the accessor is also a representation of the grid position a la row/col. Internally the grid position Vector2i have that information, so I may want to refactor down the road to more explicitly use that representation, depending on how map generation progresses.

Progress

  • Don't forget review ^
  • Begin Part 3
  • Completed Part 3. Onward to Part 4 during Day 5.

Thoughts

"exported configuration variables"

Need to look this up later:

@export_category("Map Dimensions")
@export var map_width: int = 80
@export var map_height: int = 45

Partial application

Doesn't look to be supported natively, but I achieved it via lambda:

Handy.map(func(r) : _carve_room(dungeon, r), rooms)

My readability in this language is probably suffering since I'm in a functional programmer mode still, but for now this feels better to me to write. For example, the use of slashes here let me pretend I'm still in Rust lol.

func _carve_tile(dungeon: MapData, x: int, y: int) -> void:
  var tile_position = Vector2i(x, y)
  dungeon\
    .get_tile(tile_position)\
    .set_tile_type(dungeon.tile_types.floor)

Side effects concerns

@SelinaDev chose to pass around the dungeon: MapData as an argument in the generation process, which I find a bit sus. But now (updating generate_dungeon to implement the randomization), we're also passing in the player: Entity, with the purpose of updating the player's position correctly in the updated map. That's an out of scope side effect in my view that I'm not a fan of, but once again I'll be shelving the concern to see how things develop going forward.

Issues

Rooms aren't all connected -- since I didn't look closely at the overall generation process, I'm not sure this isn't my fault. I'll start Day 5 by making sure I have a good grasp of the current generation state.