Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't access map_array: TypeError: 'int' object is not subscriptable #37

Open
pahp opened this issue May 22, 2018 · 2 comments
Open

Can't access map_array: TypeError: 'int' object is not subscriptable #37

pahp opened this issue May 22, 2018 · 2 comments
Labels

Comments

@pahp
Copy link
Contributor

pahp commented May 22, 2018

I tried to add in the map_array[][] using the code that worked for Space Invaders, but when I touch map_array in bot code, I get the following errors:

Traceback (most recent call last):
  File "/home/pedro/src/CYLGame/CYLGame/Server.py", line 242, in sim
    gtoken = runner.run(room, playback=True).save(self.gamedb)
  File "/home/pedro/src/CYLGame/CYLGame/Game.py", line 308, in run
    player.run_turn(game.random)
  File "/home/pedro/src/CYLGame/CYLGame/Player.py", line 55, in run_turn
    nxt_state = self.prog.run(self.get_state(), max_op_count=max_ops, random=random)
  File "/home/pedro/.local/share/virtualenvs/pac-bot-CuEVk7J3/lib/python3.6/site-packages/littlepython/interpreter.py", line 279, in run
    self.handle(self.ast, sym_tbl)
  File "/home/pedro/.local/share/virtualenvs/pac-bot-CuEVk7J3/lib/python3.6/site-packages/littlepython/interpreter.py", line 267, in handle
    return handler(node, sym_tbl)
  File "/home/pedro/.local/share/virtualenvs/pac-bot-CuEVk7J3/lib/python3.6/site-packages/littlepython/interpreter.py", line 188, in handle_block
    self.handle(child, sym_tbl)
  File "/home/pedro/.local/share/virtualenvs/pac-bot-CuEVk7J3/lib/python3.6/site-packages/littlepython/interpreter.py", line 267, in handle
    return handler(node, sym_tbl)
  File "/home/pedro/.local/share/virtualenvs/pac-bot-CuEVk7J3/lib/python3.6/site-packages/littlepython/interpreter.py", line 183, in handle_assign
    sym_tbl[node.left.value] = self.handle(node.right, sym_tbl)
  File "/home/pedro/.local/share/virtualenvs/pac-bot-CuEVk7J3/lib/python3.6/site-packages/littlepython/interpreter.py", line 267, in handle
    return handler(node, sym_tbl)
  File "/home/pedro/.local/share/virtualenvs/pac-bot-CuEVk7J3/lib/python3.6/site-packages/littlepython/interpreter.py", line 219, in handle_getarrayitem
    var = self.handle(node.left, sym_tbl)
  File "/home/pedro/.local/share/virtualenvs/pac-bot-CuEVk7J3/lib/python3.6/site-packages/littlepython/interpreter.py", line 267, in handle
    return handler(node, sym_tbl)
  File "/home/pedro/.local/share/virtualenvs/pac-bot-CuEVk7J3/lib/python3.6/site-packages/littlepython/interpreter.py", line 220, in handle_getarrayitem
    return var[self.handle(node.right, sym_tbl)]
TypeError: 'int' object is not subscriptable
pahp pushed a commit that referenced this issue May 22, 2018
I updated the code to use ConstMapping like Space Invaders does.

I did this in the process of trying to solve Issue #37, which is that when I touch map_array[][] in an LP program it crashes with the errors quoted in #37. As far as I can tell, I am creating and providing the map to users in bot_vars exactly the same way I do with Space Invaders.
@pahp
Copy link
Contributor Author

pahp commented May 22, 2018

The bot code in question was

foo = map_array[0][0]

@pahp pahp added the bug label May 23, 2018
@pahp
Copy link
Contributor Author

pahp commented May 23, 2018

I have punted this issue for now -- I just removed map_array from the code (commented it out) and removed it from the documentation. The game should be playable without the map.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant