Alright so I now have usable maps, but have to re-write my pathfinding code.
Again, I'm using libtcod with Python. I want each tile on the map to have a specific movement cost (which ranges from 1 to 4) based on its terrain. Then whenever I hover my mouse over a unit, it should display all the tiles that unit can move to (based on the unit's hard-coded range).
Heh. When I used libtcod for a PyWeek project, I was accused of not having done anything myself. Yes, I started with what it gave me, but had to write my own map generator, field of view, and path finder to deal with a feature that the reviewer hadn't even noticed. I also revised the tileset for another feature.
Anyway, for this particular case, it seems like a flood-fill would be more efficient than pathfinding. Mark each tile next to the unit with the remaining range, then mark each unmarked tile next to those tiles, continuing until you run out of range.
Static typing saves a lot of headaches down the track. The main "pain in the ass" is that you get more compiler errors. But this doesn't mean you had more errors than in a dynamic typed program, it just means that the compiler picked up potential flaws in your logic before you actually ran the program.
Yes, I've found myself making about the same number of stupid mistakes in both static and dynamic languages, but I've tended to find the important ones faster in Python than in C++. Partly because automated test cases replace the compiler as my first line of defense, and partly because Python's error messages are actually useful.
Think about how often you wrap "ParseInt" or "IsANumber?" around variables in PHP/Javascript programs. It's something you always need to guard against.
Almost never, if I'm the one calling the function. Unless we're talking user or network input, which is
so much more convenient to deal with in PHP, Javascript, and Python than in C/C++.
Python is just slow compared to c++. It has zero to do with your optimization abilities. The same exact algorithm will almost always be faster in c++.
That's only true while cpython remains the default implementation. And doesn't usually matter, because I/O wait time tends to dominate almost everything.
I didn't say that C++ is slower than Python. I said that it's harder to optimize things in Python than it is in C++. Mainly because it hides a lot of memory thingies from you.
Still possible to get algorithmic optimization, and this applies to any language. :v
Fair point about the memory thingies; it's so much simpler to write code that does stupid things to memory when you don't have to worry about your own allocations. Then again, Python sometimes makes it more convenient to change the hotspot implementation without having to change everything that touches the memory structures involved. Likewise, certain algorithmic optimizations are far easier in a dynamic language. (I've written iterators in C++, and was appalled at the required boilerplate, both in implementation and in use.)