1234 ->
^^
vv
List results:
Search options:
Use \ before commas in usernames
Fear Me! (Or else...)
Hey all. I figured this was the best section in the forum for a thread like this, and didn't see another, so I'm starting it here. If you know where another is, Acheron, feel free to delete this one. Sorry if there's a mix-up there!

Ok, to kick this off, I'll ask what's probably a really dumb question: What does the C++ command 'Return' do? I've only ever seen it at the end of programs, like 'Return 0' and 'Return EXIT_SUCCESS'. A little help here?


Also, in advance, Acheron, if there's not already a thread dedicated to this, could I request sticky status for this one?
Thread title: 
Acclaimed Threshold
Constant Sorrows
TBH I'm not sure how I feel about this thread. There are better places to discuss coding (Romhacking.net, for example). I'll leave it be, but not going to sticky and add ANOTHER thread to the list of long stickies unless the community makes this one worth it.
Fear Me! (Or else...)
Ok. Do you want this in another section of this forum, then?
¯\_(ツ)_/¯
Quote from Bioniclegenius:
What does the C++ command 'Return' do?
I haven't worked with C++, but if its return command is similar to that of C, Python, or TI-BASIC, which it should be, then it will exit a function and pass the value or string you specify for returning.

Example (in C):
Code:
#include <stdio.h>
retex(int x=0){return(x);}
main(){printf(retex());printf("The above value is 0.");}
It's been a while since I've used C, but you should get the idea.
Edit history:
Zhs2: 2008-10-07 10:45:44 pm
Yo.
Oh, boy! C++! I haven't used that language in, like, three years.
Now that I think about it, it's been closer to two than three...

The return function (which is a reserved word, mind you) works just like uNsane said: It returns the value or string specified at the end of the function to the main program or to DOS itself. When used at the end of main(), your main program function, it will usually exit the program after returning the value or string to DOS (not sure where it goes after that; I forget whether or not it gets printed after, but I know it disappears completely into the great beyond...) However, if return is used at the end of a function, it has the capability of returning a value or string you came up with in the function back to the main program (or you can just return 0, skipping that entirely.)

The variable EXIT_SUCCESS that you mentioned is just a dummy variable programmers stick onto the return function to make it look like it does something important. To put it simply, it's eye-candy, nothing more; although that's probably assuming that's the only purpose the variable EXIT_SUCCESS is used for in the entire program.
I like Big Butts and I can not lie
In ASM, there is an instruction to branch to a subroutine (bl in THUMB, jsr in 65816), which jumps from where that instruction is in the middle of a routine, to the start of another routine; when that routine is done, it 'returns' to execute the rest of original routine.

A more technical explanation is that when you jump to a subroutine, the 'return value' is saved to the stack (the return value is the address to return back to), and the return instruction pulls that value from the stack, and branches to it. In many processors though, the return address is saved to the 'link register' (r14 in THUMB) which can optionally be pushed to the stack to allow subroutines within subroutines
(user is banned)
Edit history:
J-SNAKE: 2008-10-08 08:03:54 am
thats me
in short starting understandable for beginners, I will keep it as easy as possible :-)

just imagine you need a function like this in your program:

int area_rectangle (int width, int height)        //int in front simply means returning an integer is expected when leaving the function
{
  return width*heigth;
}


main()
{
  int w=10;
  int h=20;
  int area;
 
  area=w*h;                        // one possibility

  area=area_rectangle (w,h); //now second possibility, when function finishes after return there simply stands invisible: area=200;
}                                      // and this is simply the thing "return" is doing: just leave the function and go to the next step or line
                                      // "return value" returns a value in addition (just like here)

You can imagine now if your calculation routine is more complicated and expansive and you need it often, then you would prefer to implement the routine in a function once and then simply use the function where needed. Wink






(user is banned)
Edit history:
J-SNAKE: 2008-10-08 10:18:06 am
thats me
But for such basic things you are actually asking, Bioniclegenius: You better first google a good piece of literature of C++.
It cannot be the point this thread here replaces a solid C++-book.

But if you then have problems with some things which are more advanced, I think then it would make more sense to ask.
For example some pointer stuff etc... For example if you manage to understand how this very small humble functions (simulating each a basic mathematical operation) work and what they do one day, you surely can say my understanding in programming has significantly advanced.
There are even people who will not really figure out what they do in their whole live.

int f(int a, int b)            //for positive a and b
{
if (a<b) return a;
if (a==b) return 0;
return f(a-b,b);
}

int f2(int a, int b)              //a all, b positive
{
if (b==1) return a+1;
return f2(a,b-1)+1;
}

int f3(int a, int b)              //a and b positive
{
if (b==1) return a;
return f3(a,b-1)+a;
}
Acclaimed Threshold
Constant Sorrows
Don't double-post, please.
Eschews avatars
There will be a number of excellent C++ books at your local library that will easily replace that part of this thread. It's a language with a pretty gentle learning curve, especially if you've started with BASIC. If you're completely new to programming, I'd start with BASIC.
(user is banned)
Edit history:
J-SNAKE: 2008-10-09 11:39:49 am
thats me
No, just start directly with C/C++ if you have a good book, if you are more interested in C/C++, then don't believe all the illusions it will be too difficult just because some people only forgot to open their hands before grabbing it. Wink

It is rather the other way round: more high level language -> less understanding  Wink
¯\_(ツ)_/¯
To be honest, I have to agree with J-SNAKE here. BASIC may be easy to use, but a lower-level language like C will help you to understand how the machine works, thus leading to more efficient coding overall.
Fear Me! (Or else...)
True. Also, remember, this is for ASM as well, so you can all ask questions of your own. Thanks for the help with my little Return problem - I know the command in TI-BASIC, but so much is different in C++ I wasn't sure if it was the same.
(user is banned)
thats me
For motivation:

http://de.youtube.com/watch?v=dKMAG-3GUQA

If someone really wants to learn serious programming my recommandation is to start with programming something like this here but not learning many programming languages instead. 

If it is too difficult, no problem, just think out another interesting thing, but easier to implement and train your understanding in structures-identification. The key to success is always to understand and recognize the main structeres of your subject you want to implement.
It doesn't matter it is a game or a simulation or anything else. "Structures are everywhere", so train your understanding in recognizing structures.
Fear Me! (Or else...)
Wow. That was neat. However, that's a higher programming concept than I can do right now. My teacher says she won't even tell us how to display images until after christmas break (sorry, for those of you out there who prefer it to be referred to as 'winter break'). Actually, never mind that. Wouldn't you just need to find a horizontal point between every two of the major points, and take half that horizontal distance and put that as vertical? That might be it, although that sounds wrong. Hm. Also, wouldn't it be a little slow if it has to redraw it at every pixel as you move it around?
(user is banned)
thats me
some necessary explanation of koch-curve:

http://en.wikipedia.org/wiki/Koch_snowflake

Yeah, but if you manage to do it in some future you can be sure your understanding has advanced. You don't have to think you are bad if you don't understand how to implement it right now. I even claim a huge amount of people learning C++ for example will not manage to implement something like this.

On the other head once you managed it you don't have to think you are so great.

This is nothing compared to the challenge I have implementing an interesting dynamic SMTac-A.I. for example.
Fear Me! (Or else...)
AI is actually simpler. Is the player to the left or right? Is it higher or lower? Then pick a random attack. AI is pretty simple, when you think about it. This, on the other hand... I can kind of get the rough concept. It's still a little weird.
Yo.
AI is more tricky the more advanced you need it, I believe. If you want an enemy that walks around on the floor or ceiling minding its own business, that's a bit easier. If you want a smart enemy that predicts where you'll be next, and missiles the crap out of you accordingly, that's a bit tougher. It really all depends on what the creator wants it to be able to do...
(user is banned)
Edit history:
J-SNAKE: 2008-11-16 11:10:05 am
thats me
Quote from Bioniclegenius:
AI is actually simpler. Is the player to the left or right? Is it higher or lower? Then pick a random attack. AI is pretty simple, when you think about it. This, on the other hand... I can kind of get the rough concept. It's still a little weird.



ROFL. (you have no idea how wrong you are Wink)

Only to shock you:
The class of something like SMTac-A.I. has to be even more complex than Far Cry- A.I. (doesn't matter here it is "only" 2d). It is also because the SMTac- moving and combat system is much more complex than in a 3D-shooter. The A.I. has to get a SENSE of their moving and their huge combat possibilities and adapt them properly to the opponent. And also not only that you forget something like pathfinding but the A.I. shall get a SENSE of their environment and use it in EVERY case properly for offense as well as for defense.

In a 3D shooter for example the A.I. is a lot simpler to implement. It is because you can aim-directly in any direction you want and every move in each direction has mostly the same level of repercussion.
But with the SMTac movement/and combat-system the level of repercussion can easily go high. That is the important point why the nature of SMTac is a lot more interesting than the nature of a custom 3D-shooter.

Just one aspect in SMTac A.I. which is already a huge challenge: You see just a small amount ot the tricky and cool moving in SMTac-Videos. Now just imagine now A.I. is playing and the A.I. has the task to figure out what way is the most efficient and/or most quick to come from A to B in a certain situation.  Now the A.I. has to calculate and evaluate what is possible and probably decide to do a cross-shinespark combinded with an mid-air-morph to pass a hole and then unmorph while keeping the speed for a vertical shinespark combined with a mid-air morph again and then crush against ceiling and applying the spider-ball. And it is still not enough, now you have to calculate all the controls for this decision as exactly as you can to synchronize all this moving with success. It is not just go right or left until point A like in a custom 3D-shooter you see.

Now you see if you want to make something at this level a custom 3D-shooter A.I. is nothing compared to it.


(user is banned)
thats me
For interested people just to get an impression why developing SMTac (also for SM2 for innovative dynamic bounty hunter-enemys)
is probably the most challenging thing:

http://de.youtube.com/watch?v=_SPJIwIfHJ4
...
Quote from Bioniclegenius:
AI is actually simpler. Is the player to the left or right? Is it higher or lower? Then pick a random attack. AI is pretty simple, when you think about it. This, on the other hand... I can kind of get the rough concept. It's still a little weird.

Sometimes, you can mess up the AI by simply hiding inside a wall, like this:

(user is banned)
thats me
Yeah, but this is not really A.I. (I use the word A.I. here for something what has a sense of its environment and so on, this thing surely has no sense of it, just straight forward-approach or similar.

(I repost since a new page opened and someone like bionicle probably won't look 1 page back)
http://de.youtube.com/watch?v=_SPJIwIfHJ4
Super Secret Area - Dead Ahead!
Quote from J-SNAKE:
someone like bionicle probably won't look 1 page back


Isn't that a little harsh?  Eh?

Anyway, question:

How does that AI deal with a moving target at the moment?  The reason that I ask is that it looks like it currently just looks for the shortest route to the player, but if you were to circle around a platform, would it currently just follow you, allowing it to be cheated?

Also, if it's looking to attack you, is it able (or when you're done, will it be able) to 'track' the player, meaning that it shoots where it thinks you're going to be, not where you are?
(user is banned)
thats me
ooooh oooh ooh hey hey slowly but thanks for interest

No, the A.I. itself is only able to reach a setted target, nothing more by now. And I hope the video helps to understand how difficult
it is to make it. Just imagine the A.I. needs to do a shinespark combined with a morph-ball. You have not only to evaluate this is a good technique for certain situation but also synchronize the moving. It is not just go straight forward from point A to B and then to C. So it is already challenging enoug to make it reaching a target efficiently. Fortunately I have the possibility to use the jet, so I
will avoid very challenging calculations and synchronization using techniques like wall-jumping, precise high-speed-morphs and so on. And if I use them I will encode them specifically like shown in the video


That is what makes the difference and it is probably the first REAL A.I. in such a Genre. What you already see in this video is probably something you have never seen before.
Fear Me! (Or else...)
Well, also, the AI could possibly store in a pattern of motion that you make, and the most direct route to harm you and/or interfere with that pattern at any given point, like circling - if you do it more than once, it knows where you'll be if you keep implementing that pattern, and goes to the most direct route to get in front of you, just as you get to it, which could be pretty dangerous for you to keep a certain strategy. It could also check a spot where you are, then attack - if it gets hurt and doesn't do that much to you, then it needs to come up with a better strategy. This would make some pretty big arrays, but for a bit, it'd do just fine. It'd also have to track your missiles' motions and paths, and make sure that in a linear graph, it wouldn't come across those paths. Or, if it did, then they'd be past it. Also, you don't really want the AI to collide with the player - that's dangerous to both of you. What you would want is for the AI to get maybe 4-5 tiles away, shoot while still moving, and continue to avoid you, shooting all the while. Also, it could take a defensive strategy when it gets low on hp, like looking for the nearest solid object and try to get to the other side of it from you. This would all be pretty much hard to do, but would create a great and very difficult AI when implemented - you have to change your strategy throughout because it tracks your strategies, and you have to come up with some to counter the ones it makes to counter yours. It'd be pretty impossible if the AI has a lot of hp, though, because it'd drag on so long that you wouldn't be able to come up with any new strategies that it can't counter.