battlecode / battlehack20

🐍
https://bh2020.battlecode.org
GNU General Public License v3.0
12 stars 3 forks source link

Errors Thrown on Certain In-Place Operations #125

Open pashneal opened 4 years ago

pashneal commented 4 years ago
def turn():
    i = 1

    #commented lines produce an error
    #uncommented lines work just fine
    i += 1
    i -= 1000
    i *= 500
    i /= 500
    i = i // 500
    #i //= 500

    i = 50
    i = i << 1
    #i <<= 1
    i = i >> 1
    #i >>= 1
    i = i % 1
    #i %= 1

    i = {0,1,2,3,4,5}
    #i ^= { 1 }
    i = i ^ {1}
    #i |= {0}
    i = i | {0}
    # i &= i
    i = i & i

It seems that only the most common operations have their equivalent in place operation allowed. The following error is produced:

File "/home/user/.local/lib/python3.6/site-packages/battlehack20/engine/container/runner.py", line 218, in do_turn
    exec(self.locals['turn'].__code__, self.globals, self.locals)
  File "bot.py", line 26, in turn
    i &= i
  File "/home/user/.local/lib/python3.6/site-packages/battlehack20/engine/container/runner.py", line 122, in inplacevar_call
    raise SyntaxError('Unsupported in place op "' + op + '".')
  File "<string>", line None
SyntaxError: Unsupported in place op "&=".