Jump to content

  • Log In with Google      Sign In   
  • Create Account


Storyyeller

Member Since 18 Jan 2009
Offline Last Active Sep 17 2012 12:11 PM

#4923185 Java or C++?

Posted by Storyyeller on 18 March 2012 - 09:33 PM

I don't see what the issue with different syntax is. I regularly program in both C++ and Python, and occasionally do Java too, and I don't have any troubles.


#4923040 Java or C++?

Posted by Storyyeller on 18 March 2012 - 08:25 AM

Even though Python is designed to be user friendly (which i still doubt), its syntax is very different than C++ or Java.
Therefor i would suggest you to go on either C# or Java, then move on to C++.

Both C# and Java are taking care of alot of programming aspect for you already, so you can skip things and keep learning, and when you feel ready, you can start learning C++ and learn all those "dark corners" as mhagain has mentioned.

Good luck.


Java syntax is also very different from C++. C# is a lot closer. But I don't think there's a problem anyway. If you're going to C++ from a managed language, you're going to have to relearn a lot anyway, so a different syntax doesn't make things any harder. And it might even be an advantage because it stops you from trying to just do the same things, which is usualy a bad idea. (Ever seen Java coders write C++ which is full of void pointers and pointless dynamic allocations everywhere)?


#4889890 C++11 hash containers

Posted by Storyyeller on 02 December 2011 - 02:07 PM

[source lang='cpp']#include <unordered_set>//other includesnamespace Symmetry{struct Offset { int y, x; };namespace std { template <> class hash<Offset>{ public : size_t operator()(const Offset& arg ) const { return 0; } };};inline bool operator == (const Offset& a, const Offset& b) {return a.y == b.y && a.x == b.x;}}[/source]

I also tried changing std to ::std but that didn't help.


#4885710 use boost without include path?

Posted by Storyyeller on 19 November 2011 - 03:33 PM

If you know regular expression and a decent script, such as Perl or Python, or you are a master of Unix commands, it's easy to change all headers to remove "boost/".
Or if you only use several boost headers, how about change them manually, just spending half an hour?


I actually tried writing a Python script to fix all the include paths. It's harder than it sounds because they use macros to define some of the includes, and filenames of headers also appear in the comments. However, I managed it eventually.


#4881991 C++ unordered vector erasure

Posted by Storyyeller on 08 November 2011 - 11:35 PM

For a standard vector, random access erasures are linear time, due to shifting all the elements. However, sometimes you don't care about ordering, so you instead want to do a constant time erasure by swapping with the final element and then removing it. Is there any standard implementation of this? It seems like a common task, but I couldn't find anything by googling.


#4868830 How can I improve this code? (C++ enums)

Posted by Storyyeller on 03 October 2011 - 09:18 PM

I'm the one defining the enum. It's right there in the code. Of course I know what values it can take.


#4867658 Making an AI Fun (Space Duel)

Posted by Storyyeller on 30 September 2011 - 11:35 AM

Here's a brief summary of the current implementation

Dodging: For this part, the other player is completely ignored.
The ai projects the trajectories of everything into the future and essentially does a tree search of possible actions to minimize future damage. Obviously a full search has exponential complexity, so it uses the heuristic of using the same input for many consecutive frames, so that it only branches occasionally. It searches 123 frames into the future but it only branches 3 times. To make it easier, I also set it to completely ignore bullets and mines after 25 frames of depth. The rest of the search tree is only to avoid the moon.

Aiming: Calculate whether firing a bullet would cause it to hit if the other player does nothing. If so fire. A small error amount is added to the collision detection so that it sometimes has a close miss.


The main requirement of the dodging is that I want to make it so that the ai virtually never crashes into the moon. It looks really stupid and gives the player an instant unearned victory. This is why it searches far into the future for moon collisions even though it ignores bullets and mines after the first few frames.


#4867434 Making an AI Fun (Space Duel)

Posted by Storyyeller on 29 September 2011 - 08:10 PM

I made an approximate clone of Space Duel. Each player controls a little spaceship which orbits around the moon and can shoot bullets or lay mines. Trajectories follow the inverse square gravity from the moon and wrap around the sides of the screen. Collision with the moon or another player is instant death.

Anyway, I have had a lot of difficulty making a fun AI opponent. I want something that is very challenging, but which can be mastered with a little practice. I want an opponent that doesn't fall for cheap tricks but is beatable normally. The problem is that no matter what I try, I can't manage it.
I've figured out how to make a near unbeatable AI, but not how to make a fun one. Even when I try weakening it, it doesn't really work.

The main advantage of the AI is the ability to calculate exact trajectories into the future. I've intentionally simulated some uncertainty in the aiming calculations so the AI will sometimes shoot a close miss. However this isn't enough.


Anyway, here is a download link for the game so you can see the problem. (This is a precompiled Windows version. If you want to run it on other platforms, just pm me and I'll send you the source code)

Here's a video of the AI's dodging abilities at full strength. Obviously, the version in the actual game is weakened a bit.


#4852591 [C++ Question] How to Compile or Compress Resources

Posted by Storyyeller on 22 August 2011 - 06:35 PM

Use PHYSFS and put them into a renamed 7z archive. That will stop anyone whose is worthwhile stopping. I don't really see why you'd bother though.


#4832635 How do people stand Java?

Posted by Storyyeller on 07 July 2011 - 10:05 PM

I don't have much experience in Java (I've mostly done C++). However, whenever I try it, it seems very awkward to program in. A lot of common features like operator overloading and first class functions are missing, so it seems to require unnecessarily complicated constructs and boilerplate code to accomplish simple tasks. This isn't a necessary difference with high level languages either. I've done a little C# and Python programming, and they are much nicer to work with.

But Java is a commonly used language. So I feel I'm missing something. Perhaps due to my unfamiliarity with the language, I don't understand all the tricks and idioms that people use in Java to make programming easier. So the question is, how do people stand Java?


#4829128 Learning C++ or Python

Posted by Storyyeller on 29 June 2011 - 10:14 AM

I'm also making some games for fun. I started with C++ and have made several games, including one that I've been working on for almost two years. I haven't made any games in Python, but I do find it useful for automating other tasks involved in game development. For example, I wrote a script which takes in a description of a level and automatically generates the background image and collision data, which I can then put into my C++ game.

Python is really useful when you want to code stuff quickly and the task isn't performance intensive. I've heard there are ways to improve it, like Psyco or adding C modules, but I think these are way beyond the scope of a beginner. I haven't managed to do either of those successfully yet.


#4826096 AI method to approximate the maximum volume?

Posted by Storyyeller on 21 June 2011 - 12:41 PM

Is the solution always a subset of the convex hull of the point cloud? If true, that would simplify the search enormously.


#4825829 Why must a variable be initialized ?

Posted by Storyyeller on 20 June 2011 - 10:49 PM


1. Some compilers require that no variables are null.


Too True! Some compilers will actually, if you leave a variable null, grab whatever randomness is/was in that memory space and assign that value to your variable (if you attempt an operation with that variable unassigned).

So, for example, if I have three variables, call them FirstNumber, SecondNumber, and Thirdnumber, and I don't initialize them, then I get some user input and assign that to FirstNumber, and do Thirdnumber = FirstNumber*SecondNumber ...... ThirdNumber is gonna be something totally random, because SecondNumber was never declared and is now whatever random garbage was in that memory space. Added bonus, I'll have zero errors and zero warnings. In a big block of code it could be a pain in the keister trying to figure out why (maybe not so much why, as where) I keep getting random answers when nothing is wrong. Granted, having something like that happen means you goofed big time, but maybe that was the moment you started thinking about a ham sandwich.


It's not just SecondNumber which is an unknown state. If you invoke undefined behavior, then literally anything could happen. While compilers don't intentionally mess things up, compiler optimizations can spread the errors around. For example, I read about one case in which an unexpected interaction between two different GCC optimizations caused a signed overflow to result in an infinite loop in a seemingly unrelated loop.


#4824744 C++ error with line of code

Posted by Storyyeller on 18 June 2011 - 01:45 AM


I guess you've all seen c++ apps that display an error along with the line of code that causes it. It's usually used in games, but other apps use it, too.
I heard that this can be implemented using macros, but I can't seem to find any resource on the interwebs.
Anyone has any ideas how this is implemented?


are you talking about assertion failed errors ?

those are caused by the assert macro (which basically takes an expression, if it evaluates to true nothing happens, if it evaluates the false the program displays an error and exits) , normally those aren't used in release builds though. (most assert macros are written so that they'll be automatically stripped out unless its a debug build)


For a large commerical game that is performance intensive maybe. But often times it is helpful to leave asserts in the release build. I've had cases where I could fix bugs because users reported an assertion failure. Without asserts it would be significantly harder, if at all possible to locate such bugs. I'd say when in doubt, leave them in.


#4824231 SDL platformer, 'moving platform' issue

Posted by Storyyeller on 16 June 2011 - 03:20 PM

Look carefully at the code you posted. Try plugging in dist and see what it simplifies to.




PARTNERS