• PhantomChess has been getting quite a few updates in recent weeks and it would be good to get feedback from others. It is a Python-based Chess game that has three modes of operations in Pythonista. It starts up in text-only mode where it takes commands on the interactive prompt. The gui command switches it into a ui/scene based gui mode. The sk command switches it into a ui/sk based gui mode for those who are running the Pythonista v1.6 beta.

    To install Phantom, copy the text of Phantom_installer.py into a new Pythonista script window and run it. A local Phantom directory will be created with a Run_this.py file in it. To improve PhantomChess Please open issues or send pull requests.

  • @Saturn031000 This is a known bug for all system text input alerts in Pythonista, and is (I think) fixed in the current 1.6 beta.

  • That was indeed the issue. Thank you!

  • @JonB I import img_names in the main part of the file -- I'll shift it to be in the setup and load it into a list. Originally I had been using load_image_file but I thought I'd rule out the possibility it was that causing the problem so I switched to load_pil_image. I'm assuming load_image_file is faster and will switch back to that.

    @ccc do you think it would be possible to load the images into a dictionary? I'd prefer not to use a list as that might end up needing exec or eval() neither of which are good. From the piece class itself (as youll be able to see shortly - I'm uploading the code today) I have the 'color' and 'ptype' attributres which respectivley represent the color and piece type eg. 'white' & 'pawn'. This would allow me to use a dictionary with keys like {'white_pawn': xxx, 'black_king': yyy} and I could use a loop to render the images something like:

    for piece in self.game.board.pieces: img = self.images['{}_{}'.format(piece.color.color, piece.ptype)] scene.image(img, x, y)

    as opposed to having to do something long and complicated with types of the piece etc.

  • Came up with my own solution after running into some problems with the get_remote_resources() method (the zip file kept getting corrupted in the download process): I loaded the images into Pythonista using a computer program called iFunBox and used the scene.load_image_file() function.

    In the mean time, I have also completely restarted the project from scratch (but mostly just have the GUI left to do) so it'll be some time before it's uploaded.

  • Pythonista posted

    Your should read up on numpy. Its all there and coded efficiently.

  • Thanks for the useful tool. Python is still relatively new to me and whenever learning a new language it always helps to spend as much time as possbile reading existing code. The Python standard library modules are ideal sources (pun intended) for code to study.

  • fmath.is_prime() is slowing you down...

    I will post some replacement code on the gist.

    ======================= Running timing tests... newer_is_prime() 4.03963088989 new_is_prime() 11.5599570274 is_prime() 138.246795177 done.
  • The problem is that 1/2 evaluates to 0 because you're dividing two integers, if you use 1.0/2.0 instead, you should get the expected result (1./2 is actually enough).

Internal error.

Oops! Looks like something went wrong!