0

I am making a roguelike game using the python-tocd roguelike engine. My game is based off the python libtcod roguelike tutorial.

I'm making a list of constants that I use to generate maps

game_map.make_map(constants['max_rooms'], constants['room_min_size'], constants['room_max_size'],
                  constants['map_width'], constants['map_height'],entities,player,
                  constants['maze_min_size'], constants['max_maze_rooms'], ['maze_max_size'])

Now i'm using some code in a function to determine the size of the room.

for r in range(max_rooms):
    # random width and height
    w = randint(room_max_size, room_min_size)
    h = randint(room_max_size, room_min_size)

    # random position without going out of the boundaries of the map
    x = randint(0, map_width - w - 1)
    y = randint(0, map_height - h - 1)

I've defined the variables here

map_width = 80
map_height = 45

room_max_size = 10
room_min_size = 6
max_rooms = 30

Now when I start up the game this appears?

  File "C:/Users/Al Abraham/Documents/CaveRL/CaveRL/engine.py", line 466, in <module>
    main()
  File "C:/Users/Al Abraham/Documents/CaveRL/CaveRL/engine.py", line 445, in main
    player, entities, game_map, message_log, game_state, ggender = get_game_variables(constants)
  File "C:\Users\Al Abraham\Documents\CaveRL\CaveRL\initialize_new_game.py", line 115, in get_game_variables
    constants['maze_min_size'], constants['max_maze_rooms'], ['maze_max_size'])
  File "C:\Users\Al Abraham\Documents\CaveRL\CaveRL\map_objects\game_map.py", line 110, in make_map
    w = randint(room_max_size, room_min_size)
  File "C:\Python37\lib\random.py", line 222, in randint
    return self.randrange(a, b+1)
  File "C:\Python37\lib\random.py", line 184, in randrange
    istart = _int(start)
TypeError: int() argument must be a string, a bytes-like object or a number, not 'list'

What should I do?

brandonwang
  • 1,603
  • 10
  • 17
  • 4
    You should debug it by printing the variables before the failing function call and see what they actually contain. One of them must be a list. – John Zwinck Sep 09 '18 at 00:32
  • Or use `pdb; pdb.set_trace()` to enter the debugger (similar to gdb). – Matt Messersmith Sep 09 '18 at 00:34
  • Please show you you created the `constants` dict. It would appear from the error that `constants['room_max_size`]` is a list rather than a simple int or string. – Kurtis Rader Sep 10 '18 at 03:39

1 Answers1

0

When you use the int() function, you must have a string, or some number. What this error says is that at least one of your parameters is a list, not a number.

You should check the line where you declare the "w" variable, it seems that the source of trouble is either from room_max_size or room_min_size.

Prometheus
  • 618
  • 1
  • 7
  • 23