Re: Slowness!




Alistair Hutton wrote:
> On 1 Jan 2006 09:20:57 -0800, "Pedro Gómez-Esteban"
> <pedro.gomez.esteban@xxxxxxxxx> wrote:
>
> >Thanks to all who've replied! I am using the python profiler - and
> >found a couple of methods that are using a *lot* more CPU time than I
> >expected...and also, I am probably dumping my home-made super-precise
> >LOS algorithm for a simpler one (like Angband's) that takes less time.
> >I will stick with Python until I feel the code is as fast as I can make
> >it, and if that's not enough, I'll switch to something else.
> >
>
> Stiuck with it man, I'm curerently writing overhead 2d shooter (with
> random level generation, which is why I'm reading this news group) in
> Python. The game runs at a steady 45 frames a second even with a
> super-precise LOS algorithm, multiple transparency effects and dozens
> of enemies. As other people have pointed out you can rewrite the most
> used portions in C however, good design and appreciation of algrithms
> and computing fundamnetals will see you further. One of the most
> basic maxims to keep in mind is that you can almost always trade
> space for time. Recently I doubled the amount of memory I used to
> store the map tiles to gain 5 FPS.

Agreed. Python will do the job - providing you profile thoroughly, and
use good algorithms (especially for LOS & pathfinding) and efficient
screen blitting.

Re your LOS algorithm... here you may be able to get a manyfold
improvement in speed at the cost of a small loss of performance. My
advice, FWIW, is to use a well established algorithm and precalculate
as much stuff as possible.

I've just spent a few hours adding GUI features to my Python roguelike.
I'm using Pygame and have now added in the GUI tools from PGU, which
gives me various widgets like dialog boxes, scrollboxes, checkboxes and
whatnot. Took a bit of getting my head around but definitely improves
the look and feel.

A.

.



Relevant Pages

  • Re: hide python code !
    ... doors or installing burglar alarms, ... Compiling code to machine language isn't like locking your door. ... Compiling code doesn't prevent me from seeing your code or your algorithm, ... Would you argue that Python source code hides your ...
    (comp.lang.python)
  • String similarity
    ... The algorithm that I have chosen for the comparison between string was ... Python reducing the code from 1394 lines of "C" to 152 lines of Python ... Initially I have rearranged part of "C" code in one module "simil" ... Comparing string this is not possible and the only way that I have found ...
    (comp.lang.python)
  • Re: hide python code !
    ... Compiling code to machine language isn't like locking your door. ... Compiling code doesn't prevent me from seeing your code or your algorithm, ... Would you argue that Python source code hides your ... 'imperfect protection' with 'pointless protection'. ...
    (comp.lang.python)
  • Re: What is different with Python ?
    ... But I will write better code if I understand how Python ... It makes a difference whether your algorithm runs in constant time, ... linear, quadratic, logarithmic or exponential time -- or something even ... exponential algorithms in something that looks like a linear or constant ...
    (comp.lang.python)
  • Re: LOS is easy
    ... >> get an algorithm that isn't O. ... > mid-sized view distances, I can't draw a line from the observer to the ... This time round I used "Is it within N squares" as the rough ... >> notice if my LOS algorithm was 2-10 times slower. ...
    (rec.games.roguelike.development)