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

Update to Python 3 #163

Open
13 of 17 tasks
hawkerm opened this issue Nov 18, 2019 · 11 comments
Open
13 of 17 tasks

Update to Python 3 #163

hawkerm opened this issue Nov 18, 2019 · 11 comments

Comments

@hawkerm
Copy link
Member

hawkerm commented Nov 18, 2019

Plan:

  • Update to Python 3.8 - ✔️ Update to Python 3 #163
    • Network Lib needs some love due to unicode/str updates
  • Update to pygame 1.9.6 (should be easiest of bunch) - ✔️
  • Update to pymunk 5.6 - ✔️ Refactor to use PyMunk 5.0.0 #71
  • Update to py2exe 0.9.2.2 Switch to cx_Freeze 6.1 for packaging - 🟡 In Progress

Open Issues:

  • Asteroids not wrapping properly (so something wrong with edges of space?)
  • Asteroids hitting planets now?
  • Nebula collision detection/shape/display off???
  • BrakeCommand no longer works [pymunk change WorldCommands.py Line 244]

Auxiliary:

  • VS Code environment
    • Run/Debug Server
    • Run Unit Tests

Docs:

To Test:

  • Unit Tests
  • Weapons
  • Sub-games
  • Tournaments

Started in py3 branch

@hawkerm
Copy link
Member Author

hawkerm commented Nov 19, 2019

Did quick patch on the boundaries of the network lib for compatibility with client, gets us forward for now. Network lib is oldest part, as it predates the project anyway.

Biggest known problem left is the world wrap-around, looking at that next. Otherwise, we're pretty good???

Will investigate if we can run the existing unit tests from VS Code or not.

@hawkerm
Copy link
Member Author

hawkerm commented Nov 19, 2019

Found the wrapping issue here in WorldMap: https://github.com/Mikeware/SpaceBattleArena/blob/py3/SBA_Serv/World/WorldMap.py#L222

The vector seems immutable now, but haven't found correct pattern yet.

This is also a problem in the Warp command here: https://github.com/Mikeware/SpaceBattleArena/blob/py3/SBA_Serv/World/WorldCommands.py#L317

@hawkerm hawkerm added this to the v1.3 - TBA milestone Dec 1, 2019
@hawkerm
Copy link
Member Author

hawkerm commented Dec 1, 2019

Hitting this same issue with py2exe, they've changed something, so need to find new paradigm, but not sure what it is. All info around pygame and py2exe seems old.

@hawkerm
Copy link
Member Author

hawkerm commented Dec 1, 2019

Looks like py2exe is pretty old, seeing if cx_Freeze will work instead.

@jaredkrinke
Copy link

Wow, division changed between Python 2 and 3 🙄

http://python-future.org/compatible_idioms.html#division

I could only repro on the py3 branch (and not the master branch). I'm on Python 3.7.6 with dependencies from requirements.txt.

Repro:
Use mousewheel and click to spawn a wormhole
Hit "d" to turn on debug mode

Result: Crash

2020-02-13 15:16:50,335|5153|ERROR|MainThread|main|697|startGame|FATAL Error in GUI!!!
Traceback (most recent call last):
  File "C:\Users\jared\Code\SpaceBattleArena\SBA_Serv\GUI\main.py", line 274, in startGame
    obj.draw(worldsurface, flags)
  File "C:\Users\jared\Code\SpaceBattleArena\SBA_Serv\GUI\ObjWrappers\WormHoleWrapper.py", line 43, in draw
    wrapcircle(surface, c, intpos(self._worldobj.exit.body.position), self._worldobj.radius / 2, self._world.size, 2) # 'target'
  File "C:\Users\jared\Code\SpaceBattleArena\SBA_Serv\GUI\Helpers.py", line 31, in wrapcircle
    pygame.draw.circle(surface, color, pos, radius, thickness)
TypeError: integer argument expected, got float
2020-02-13 15:16:50,340|5158|ERROR|MainThread|main|698|startGame|Traceback (most recent call last):
  File "C:\Users\jared\Code\SpaceBattleArena\SBA_Serv\GUI\main.py", line 274, in startGame
    obj.draw(worldsurface, flags)
  File "C:\Users\jared\Code\SpaceBattleArena\SBA_Serv\GUI\ObjWrappers\WormHoleWrapper.py", line 43, in draw
    wrapcircle(surface, c, intpos(self._worldobj.exit.body.position), self._worldobj.radius / 2, self._world.size, 2) # 'target'
  File "C:\Users\jared\Code\SpaceBattleArena\SBA_Serv\GUI\Helpers.py", line 31, in wrapcircle
    pygame.draw.circle(surface, color, pos, radius, thickness)
TypeError: integer argument expected, got float

Log file: SBA_Serv2020-02-13_151646.log

@hawkerm
Copy link
Member Author

hawkerm commented Feb 20, 2020

@jaredkrinke started a py3-unittest branch that runs in VS 2019. Started fixing a few unit tests like the failing PlayerStat ones. Haven't looked at the above WormHole one yet, but that should be an easy fix, probably easiest to switch to // floor division to make sure there's an int.

@hawkerm
Copy link
Member Author

hawkerm commented Mar 12, 2020

The Unit Tests seem to be mostly working, they seem to have trouble running all together, but run fine individually. Timing can still be an issue... that's a whole other problem. They've at least helped identify some issues with Py3 and PyMunk5, so it's been helpful.

@hawkerm
Copy link
Member Author

hawkerm commented Mar 12, 2020

@jaredkrinke think I have a fix for the wormholewrapper I'm going to push in a minute.

Found another issue that I'm not sure about yet though:

Traceback (most recent call last):
  File "C:\code\SpaceBattleArena\SBA_Serv\GUI\main.py", line 127, in addorremove
    bgobjects[obj.id] = NebulaGUI(obj, world)
  File "C:\code\SpaceBattleArena\SBA_Serv\GUI\ObjWrappers\NebulaWrapper.py", line 13, in __init__
    super(NebulaGUI, self).__init__(nebula, world)
  File "C:\code\SpaceBattleArena\SBA_Serv\GUI\ObjWrappers\GUIEntity.py", line 20, in __init__
    self._points = self.get_world_points(self._worldobj)
  File "C:\code\SpaceBattleArena\SBA_Serv\GUI\ObjWrappers\GUIEntity.py", line 85, in get_world_points
    points += [(vertex.rotated(worldobj.body.angle) + worldobj.body.position).int_tuple]
  File "C:\code\SpaceBattleArena\SBA_Serv\env\lib\site-packages\pymunk\vec2d.py", line 481, in __get_int_xy
    return int(self.x), int(self.y)
ValueError: cannot convert float NaN to integer

Happened when deleting stuff from the world in the Server GUI.

@jaredkrinke
Copy link

FYI: I see that error every time I run the server (with no arguments).

@jaredkrinke
Copy link

I see the problem. In PhysicalEllipse.__init__, the following division should have been left as a float division (in the py3 branch, it truncates to zero so all the points in the polygon end up being the same):

    def __init__(self, size, mass, pos, segments=16):
        ...
        ang = math.pi * 2 // segments

@hawkerm
Copy link
Member Author

hawkerm commented Mar 15, 2020

Ah, thanks @jaredkrinke! That's a recent change I did, I was over-aggressive on my changes back to int division.

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

No branches or pull requests

2 participants