Coder Social home page Coder Social logo

Update to Python 3 about spacebattlearena HOT 11 OPEN

hawkerm avatar hawkerm commented on June 16, 2024
Update to Python 3

from spacebattlearena.

Comments (11)

hawkerm avatar hawkerm commented on June 16, 2024 1

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.

from spacebattlearena.

jaredkrinke avatar jaredkrinke commented on June 16, 2024 1

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

from spacebattlearena.

hawkerm avatar hawkerm commented on June 16, 2024

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.

from spacebattlearena.

hawkerm avatar hawkerm commented on June 16, 2024

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

from spacebattlearena.

hawkerm avatar hawkerm commented on June 16, 2024

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.

from spacebattlearena.

hawkerm avatar hawkerm commented on June 16, 2024

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

from spacebattlearena.

jaredkrinke avatar jaredkrinke commented on June 16, 2024

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

from spacebattlearena.

hawkerm avatar hawkerm commented on June 16, 2024

@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.

from spacebattlearena.

hawkerm avatar hawkerm commented on June 16, 2024

@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.

from spacebattlearena.

jaredkrinke avatar jaredkrinke commented on June 16, 2024

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

from spacebattlearena.

hawkerm avatar hawkerm commented on June 16, 2024

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

from spacebattlearena.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.