Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
OneEightHundred
Feb 28, 2008

Soon, we will be unstoppable!

poemdexter posted:

Server with 2 threads? Server with no threads and 2 objects inside a loop? Event handlers for recieving messages passing messages between objects or just straight up call a updateGame() method passing what I'm parsing from messages?
Game state serialization is usually done in the game thread because that means you don't need to maintain multiple copies of the game state.

Usually the game loops go like this:

Server:
- Run per-frame code for all objects and the global simulation
- Send state updates to clients

Client:
- Predict next game state from previous state
- Update prediction using networked state updates
- Fire "updated" or "created" events for objects modified/created by the networked state update if necessary
- Run per-frame code for all objects and the global simulation


It's really common for objects to be tightly integrated in both environments, i.e. the server-side behavior and client-side prediction methods for a type of object will be in the same class.

OneEightHundred fucked around with this message at 21:51 on May 26, 2011

Adbot
ADBOT LOVES YOU

poemdexter
Feb 18, 2005

Hooray Indie Games!

College Slice
Right, so for just the Server part, would you separate your two parts listed into separate threads with messaging? Would you mash them together inside one object and just handle inputs as fast as possible while ticking and updating players?

OneEightHundred
Feb 28, 2008

Soon, we will be unstoppable!
Same object? Probably not, but if you want to run it in separate threads then you'd need to do something like double or triple buffering so that state updates don't get applied to the state that the networking layer is digesting.

i.e.
myGameState.ApplyPlayerInteractions(playerInputStates)
myGameState.RunFrame()
myNetworkStateSerializer.Send(myGameState)

poemdexter
Feb 18, 2005

Hooray Indie Games!

College Slice
I guess a better question would be how would YOU implement a dedicated server? What classes/objects/threads/etc would you create and how would the interact with the client and each other?

OneEightHundred
Feb 28, 2008

Soon, we will be unstoppable!
Any sort of threading model needs to be weighed against the performance need for threads in the first place.

Personally?

SerializableProperty - Generic data container with an update timestamp.

GameObject - Base class for everything clients need to know about. Contains and exposes an array of SerializableProperties. SerializableProperties that can be predicted are flagged as "always send." Exposed properties of the class do not access members, but rather, update or retrieve data from a SerializableProperty. Also exposes ClientNotifyUpdate, ClientPredict, ClientRunFrame, and ServerRunFrame methods.

GameState - Collection of GameObjects.

NetworkStateSerializer - Digests serializable properties. Write(SerializableProperty, int lastTimeStamp) writes a 1 bit and property data if the object is newer than the timestamp or marked always send, 0 if not. Read(SerializableProperty) parses that sort of data. Can scale this up to GameObject and GameState.


foreach (client in myClients)
myGameState.ApplyClientInput(client.InputState)
myGameState.ServerRunFrame()
foreach (client in myClients)
myNetworkStateSerializer.Write(myGameState, client.NetworkStream, client.LastConfirmedTimestamp)

...

myGameState.ClientPredict()
myNetworkStateSerializer.Read(myGameState, myNetworkStream)
myGameState.NotifyUpdatedObjects()
myGameState.ClientRunFrame()

poemdexter
Feb 18, 2005

Hooray Indie Games!

College Slice
Money.

That's just the sort of thing I was looking for. I guess we needed to dip a little deeper into exactly what goes into networking games. This stuff is pretty complicated! You've been a tremendous help 1 800.

xgalaxy
Jan 27, 2004
i write code

poemdexter posted:

Money.

That's just the sort of thing I was looking for. I guess we needed to dip a little deeper into exactly what goes into networking games. This stuff is pretty complicated! You've been a tremendous help 1 800.

It's GPL code, but may give you some ideas.
https://github.com/nardo/tnl2

This is basically a rewrite of the first open source version which was called OpenTNL, which has a long standing history in the Starsiege/Tribes series of games. And is to this day, in my opinion, one of the most capable game networking systems in existence. I think the only company competing in this area is Valve with all of the stuff they've done for Counterstrike, etc. Every one else seems to have gone rather lazy in the networking area, with id games and Unreal games being the worst offenders of poor networking.

Old Paper about TNL before it was TNL:
http://www.pingz.com/wordpress/wp-content/uploads/2009/11/tribes_networking_model.pdf

Valve has some information about their stuff:
http://developer.valvesoftware.com/wiki/Category:Networking
http://developer.valvesoftware.com/wiki/Source_Multiplayer_Networking
http://developer.valvesoftware.com/wiki/Latency_Compensating_Methods_in_Client/Server_In-game_Protocol_Design_and_Optimization

xgalaxy fucked around with this message at 20:34 on May 27, 2011

OneEightHundred
Feb 28, 2008

Soon, we will be unstoppable!
Source's networking actually isn't that amazing, it's still doesn't do partial syncs and the way it does player movement makes vehicles in multiplayer almost impossible. The COD series continues to have no vehicles for largely the same reason.

id Tech 4's net code is actually pretty bad (full entity state writes!), but Unreal has actually been really good about it since day one. Prioritization, partial syncs, gamecode-level integration, and really flexible player control mechanics, it's probably the best example of the features you want to consider if high-performance cleanly-integrated network code is your goal.

roomforthetuna
Mar 22, 2005

I don't need to know anything about virii! My CUSTOM PROGRAM keeps me protected! It's not like they'll try to come in through the Internet or something!

OneEightHundred posted:

Unreal has actually been really good about it since day one.
I was assuming that when xgalaxy said "Unreal games" he meant the games made using the engine, rather than the engine - I briefly worked for a company who was using the Unreal engine and thus I can confirm that at the very least one Unreal game had terrible terrible networking. Though that game was never released because the company collapsed pretty quickly. But yeah, the Unreal engine had the capacity to do lots of clever things, it's just that the people making games don't necessarily use it right. (One horror in the game I'm thinking of was actions being triggered on end of an animation, which thus worked in the client but not necessarily in the server which doesn't necessarily do all the animations for actions it's sent.)

Mike1o1
Sep 5, 2004
Tiluvas
I'm using XNA and C# and I'm working on a simple RPG style fighting game. I'm trying to figure out the best way to communicate between my world/player entities and the UI elements.

For example, if I have a player class

code:
class Player
{
  public string Name { get; set; }
  public string Status { get; set; }
  ...
}
I also have a UITextControl class, which I'm trying to get to display the health of the player
code:
class UITextControl : UIControl
{
  public string Text { get; set; }
  ...
}
In my main game screen, I setup both a Player object and a UITextControl object. I want to display the status of the player, so I then set
code:
UITextControl.Text = Player.Status;
In cases where Status (or health, etc.) changes often, how do I update the UITextControl? What is the best way to handle this?

My limited understanding of C or C++ tells me I would just set UIControl.Text to be a pointer to Player.Status, but I'm not familiar enough with C# to do this, and my understanding is that type of practice was meant to be avoided.

Right now I just have a bunch of statements in my game update loop to assign the necessary entity values to their respective UI elements, but this is getting more and more tedious as I add more and more UI elements (like progress bars).

Any suggestions?

roomforthetuna
Mar 22, 2005

I don't need to know anything about virii! My CUSTOM PROGRAM keeps me protected! It's not like they'll try to come in through the Internet or something!

Mike1o1 posted:

Right now I just have a bunch of statements in my game update loop to assign the necessary entity values to their respective UI elements, but this is getting more and more tedious as I add more and more UI elements (like progress bars).

Any suggestions?
I think you could use delegates for this - when you create a self-updating UI element give it a function and an object reference to use to get its data. I'm not a C# person so no example code from me, sorry.

ninjeff
Jan 19, 2004

Mike1o1 posted:

I'm using XNA and C# and I'm working on a simple RPG style fighting game. I'm trying to figure out the best way to communicate between my world/player entities and the UI elements.

For example, if I have a player class

code:
class Player
{
  public string Name { get; set; }
  public string Status { get; set; }
  ...
}
I also have a UITextControl class, which I'm trying to get to display the health of the player
code:
class UITextControl : UIControl
{
  public string Text { get; set; }
  ...
}
In my main game screen, I setup both a Player object and a UITextControl object. I want to display the status of the player, so I then set
code:
UITextControl.Text = Player.Status;
In cases where Status (or health, etc.) changes often, how do I update the UITextControl? What is the best way to handle this?

My limited understanding of C or C++ tells me I would just set UIControl.Text to be a pointer to Player.Status, but I'm not familiar enough with C# to do this, and my understanding is that type of practice was meant to be avoided.

Right now I just have a bunch of statements in my game update loop to assign the necessary entity values to their respective UI elements, but this is getting more and more tedious as I add more and more UI elements (like progress bars).

Any suggestions?

A Google search for "INotifyPropertyChanged" should get you on the right track.

OneEightHundred
Feb 28, 2008

Soon, we will be unstoppable!

roomforthetuna posted:

I was assuming that when xgalaxy said "Unreal games" he meant the games made using the engine, rather than the engine - I briefly worked for a company who was using the Unreal engine and thus I can confirm that at the very least one Unreal game had terrible terrible networking. Though that game was never released because the company collapsed pretty quickly. But yeah, the Unreal engine had the capacity to do lots of clever things, it's just that the people making games don't necessarily use it right. (One horror in the game I'm thinking of was actions being triggered on end of an animation, which thus worked in the client but not necessarily in the server which doesn't necessarily do all the animations for actions it's sent.)
I think Unreal still does one nasty thing, which is it doesn't distinguish between client and server contexts at all, so if you're in single-player then you can do all sorts of dumb poo poo (like make player input directly affect world objects) and it will break the instant you take it online.

It still has probably the most complete suite of networking capabilities and the tightest integration with the gamecode, and performance-wise, the Unreal series games themselves tended to fare very well online.

Rocko Bonaparte
Mar 12, 2002

Every day is Friday!
I have an odd problem with rotating stuff when a physics engine is in the way--particularly Bullet here. I wrapped the model representing the player up in a sphere and put it into Bullet's little physics world. I am using a joystick to try to move the player around. Once Bullet has a handle on the model, I can't just rotate or reposition it in Irrlicht; I have to apply forces. For simply translating in space, I provide a linear velocity. But when the player starts moving in a different direction, I want the player to face that way. So I have to apply an angular velocity. But I don't know exactly how much to provide since I don't have an idea when the next frame will come along. I could just as well undershoot as overshoot.

Right now I'm just applying a constant velocity, and implementing a dead zone so that it stops if it gets roughly in there. It kinda sorta works but it still can be jittery.

Also I could take any tips on finding the best angle to use to steer the player around. Given I know the player's current angle and the target angle, is there a trig one-liner to give me the best angle to use in turning at that moment? I'm thinking something like a positive angle implying clockwise and a negative one implying counter-clockwise.

Edit: Confirmed calculating how much to turn is bull simple. Turns out there's something odd going on in the engine when I try to go in a direction increasing between 90 and 270. It gets all jittery there even though when I did a little table to show the math all the correct angles were there. So I have to see a little more what it thinks its doing in those ranges when I ask the engine what angle it thinks the player is facing.

Rocko Bonaparte fucked around with this message at 19:28 on May 28, 2011

PDP-1
Oct 12, 2004

It's a beautiful day in the neighborhood.

Rocko Bonaparte posted:

Edit: Confirmed calculating how much to turn is bull simple. Turns out there's something odd going on in the engine when I try to go in a direction increasing between 90 and 270. It gets all jittery there even though when I did a little table to show the math all the correct angles were there. So I have to see a little more what it thinks its doing in those ranges when I ask the engine what angle it thinks the player is facing.

Are you using an arccosine function to calculate your angles? If so your jitter problem might be caused when you pass through the 180 degree mark and the result of the arccos function switches between interpreting this point as -180 degrees as you come from one direction vs. +180 degrees as you come from the other direction.

If that's the case you just need to add some extra logic to detect when the target and facing vector angles have different signs and adjust one of them by +/-2*Pi so that they both have the same sign.

Rocko Bonaparte
Mar 12, 2002

Every day is Friday!

PDP-1 posted:

Are you using an arccosine function to calculate your angles? If so your jitter problem might be caused when you pass through the 180 degree mark and the result of the arccos function switches between interpreting this point as -180 degrees as you come from one direction vs. +180 degrees as you come from the other direction.

If that's the case you just need to add some extra logic to detect when the target and facing vector angles have different signs and adjust one of them by +/-2*Pi so that they both have the same sign.
Looks like you were generally correct about the problem, although oddly enough it really only seems to come along when my target direction is in the second and third quadrants. In my case I'm not doing a cross product of vectors and then arccos. I was trying to exploit a peculiar situation of the game that it is generally top down, so I just looked at the Y component of the players rotation vector that Irrlicht is maintaining. I'd then compensate if the result was greater than 180 or less than -180 by switching the direction, like this Python code might show:

code:
def calc_angle(current, target):
    diff = target - current
    if(diff < -180):
        return 360 + diff
    elif(diff > 180):
        return diff - 360
    else:
        return diff
So if the current direction is roughly 180 from the target, then there is indeed a sign change. I think the problem stems from the angular velocity. It doesn't take a nap between frames but rather continues to assert itself, so I think I run into a situation where on paper it should go the other way, but with the current velocity it's going to get to the target sooner the way it's going. So with that little lag it's getting shuttered back and forth.

Luigi Thirty
Apr 30, 2006

Emergency confection port.

What are some good books for learning OpenGL with C?

Rocko Bonaparte
Mar 12, 2002

Every day is Friday!

Luigi Thirty posted:

What are some good books for learning OpenGL with C?

I suppose if you want to look at OpenGL in isolation, then the Red Book is the big one:

http://www.opengl.org/documentation/red_book/



Re: my rotation stuff, it looks like I have a larger problem I didn't notice until I slowed the whole thing down. Let's say zero degrees represents north, and 90 degrees represents east. I start my model out facing north and tell it to go to 120 degrees by moving clockwise. I am printing out the Y component of the models rotation vector as it moves to see what it's thinking, and I see stuff like this as it moves clockwise: 0.... 30.... 60.... 90.... 60.... 30.... 0....

How is it that after the 90 degree mark that this angle would begin to decrease while still rotating clockwise? I am so confused. :(

Edit: I looked at the whole rotation vector and noticed that it was running at (0, Y, 0) and then switched to (180, Y, 180) right when it crossed over at 90 degrees. So sad. I assume this is Bullet's doing :colbert:

Rocko Bonaparte fucked around with this message at 04:18 on May 29, 2011

Mr.Hotkeys
Dec 27, 2008

you're just thinking too much
What's the best way to handle clicking? Should everything just have a box and be in a list and everytime a click is detected you go through the list and find what is under the mouse? It seems kind of unwiedly and potentially slow depending on how many things are clickable, and since I'm making a strategy game (tentatively) the latter bothers me somewhat. I initially hashed everything by location but found that if anything wants to move it has to be rehashed, and that quickly loses its luster and benefits. After that, I tried to tackle it by drawing the screen twice, once normal and once with every clickable object having a specific color you can use to identify it, but I can't seem to wrap my mind around how the hell to get RenderTargets to work right.

Also another thing, I rewrote my own SpriteBatch replacement that takes in objects and sorts them based on their depth as well as their texture and the type of primitive used to draw them so that I could make as few calls to the GraphicsDevice to draw as possible, but it seems kind of slow. My implementation for storing comes out to this:
code:
LinkedList<Tuple<Texture2D, LinkedList<IGraphic>[]>>[]
Where everything is hashed by, in order, depth (a byte), texture, and primitive type. This then got put it its own BatchTree class which has methods for accessing parts in the tree and retrieving objects from it in the proper order for drawing. Is this a sane way of going about this or is there a better way of doing it?

Gerblyn
Apr 4, 2007

"TO BATTLE!"
Fun Shoe
A common way is to sort of make a hierarchy of interface components that all have a location on screen. So, at the top of the hierarchy you have the entire screen, and it contains a list of top level panels, which themselves contain more panels or buttons. So, you might have something like:

code:

class InterfaceElement
{
private:
  // The size limits of the elements hit box
  int top, bottom, left, right;
protected:
  bool InBox(int x, int y)
  {
    return (x>=left && x<=right && y>=top && y<=bottom);
  }
public:
  // Function returns true if the element handled the event
  virtual bool OnMouseDown(int x, int y, int buttonCode)
  {
    return false;
  }
};

typedef  std::vector<InterfaceElement*> ElementVector;

class InterfacePanel : public InterfaceElement
{
private:
 ElementVector elements;
public:
  virtual bool OnMouseDown(int x, int y, int buttonCode)
  {
    if (InBox(x,y))
    {
      for (ElementVector::iterator iter=elements.begin(); iter!=elements.end(); iter++)
      {
        if ((*iter)->OnMouseDown(x,y,buttonCode))
        {
          return true;
        }
      }

      return true;
    }
    return false;
  }
};

class InterfaceButton : public InterfaceElement
{
public:
  virtual bool OnMouseDown(int x, int y, int buttonCode)
  {
    if (InBox(x,y) && buttonCode==LEFT_MOUSE_BUTTON)
    {
      // Respond to being clicked
      return true;
    }
  }
}

Since the OnMouseDown call in the panel aborts as soon as one of its children handles the event, you want to make sure that the things on top go earlier in the list than the things underneath them when elements overlap.

Also, I really wouldn't worry about speed here. Unless your running on a 20 year old 486 machine, your PC can easily do 1000 InBox checks on different interface elements in a couple of microseconds.

Mr.Hotkeys
Dec 27, 2008

you're just thinking too much

Gerblyn posted:

A common way is to sort of make a hierarchy of interface components that all have a location on screen.

I had a setup like that at one time, kind of. Objects could define areas of the screen that they've got clickable objects in, and then anything that object creates gets sent to another one that represents that area and when a click occurs the input handler polls each of those and for everyone that covered the area where the click occurred, it told it to test the click itself. But I like the expanded hierarchy of it, I'll probably end up throwing that back in. Thanks.

quote:

Also, I really wouldn't worry about speed here. Unless your running on a 20 year old 486 machine, your PC can easily do 1000 InBox checks on different interface elements in a couple of microseconds.

Performance is really bothering me because when I was fudging with the RenderTarget stuff, my FPS dropped to 50ish. This obviously has partly to do with drawing the screen multiple times but even with the impact that would have I'm still worried there's something bogging it down a lot somewhere and I'm having a bit of trouble finding it. I've pinpointed a few things that need fixed, like I was using yield return (this is C# and XNA by the way) to give the vertices and vertex indices to the batch replacement, and I've read a few things that seem to indicate that this is not a very good way to do things in this case. But I'm not sure event that's going to be the biggest problem and I'm trying to find out what is so I can nip it in the bud before I find out later and have to refactor AGAIN.

Actually now that I type that I see you're talking about the clicking still (duh), so yeah that eases my mind a little bit.

Gerblyn
Apr 4, 2007

"TO BATTLE!"
Fun Shoe
I've never used C# or XNA myself, but you may want to look into running your code through a profiler to help you find bottlenecks. This guy:

http://xna-dev.blogspot.com/2008/10/xna-performance-profiling.html

Seems to have had some luck with a freeware profiler called nProf.

Mr.Hotkeys
Dec 27, 2008

you're just thinking too much

Gerblyn posted:

I've never used C# or XNA myself, but you may want to look into running your code through a profiler to help you find bottlenecks. This guy:

http://xna-dev.blogspot.com/2008/10/xna-performance-profiling.html

Seems to have had some luck with a freeware profiler called nProf.

Very cool, I'll give it a shot. Thanks again.

Internet Janitor
May 17, 2008

"That isn't the appropriate trash receptacle."
If you're ever trying to convert cartesian coordinates to polar (or the equivalent), use Atan2. I've seen this wheel reinvented more times than I can count.

Rocko Bonaparte
Mar 12, 2002

Every day is Friday!

Internet Janitor posted:

If you're ever trying to convert cartesian coordinates to polar (or the equivalent), use Atan2. I've seen this wheel reinvented more times than I can count.
Thanks for this. It's a bit cleaner than what I was coming up with. However, I think the start of all my trouble was something else.

Say I have figured out how much I need to turn and which way, so I have it start turning. I am trying to figure out now how to be sure I got there, given the rotation vector is in 3d and somewhere between Bullet and Irrlicht it likes to play cruel games with me. So imagine the player has started by facing north and I want to turn 135 degrees (southeast). I'm seeing the rotation vector do stuff like this:

(0, 0, 0)
...
(0, 30, 0)
...
(0, 60, 0)
...
(0, 89, 0) ... Right around 90 degrees something stupid happens
...
(180, 89, 180) ... the player is rotated 91 degrees here
...
(180, 60, 180)
...
(180, 45, 180) ... This is what I can see as 135 degrees

I think it's Bullet that is doing it since it seizes control of position and rotation. It also seems to be still doing the right thing when given an angular velocity. I just can't figure out mathematically how to prove I'm getting the correct angle from that pile of stuffs.

Vino
Aug 11, 2010

Mr.Hotkeys posted:

What's the best way to handle clicking? Should everything just have a box and be in a list and everytime a click is detected you go through the list and find what is under the mouse? It seems kind of unwiedly and potentially slow depending on how many things are clickable, and since I'm making a strategy game (tentatively) the latter bothers me somewhat

I think you're overthinking it. It is a slow algorithm but it only runs once each time the user clicks which isn't really all that often. Even the most pro Korean Starcraft player will only click once every 20 frames or so, you won't get a noticeable skip unless there's tens of thousands of units. Do it the simple way, worry about optimization later. In practice it all gets optimized away by the compiler and processor anyway.

PDP-1
Oct 12, 2004

It's a beautiful day in the neighborhood.

Rocko Bonaparte posted:

(0, 89, 0) ... Right around 90 degrees something stupid happens
...
(180, 89, 180) ... the player is rotated 91 degrees here

Longshot guess here since I know nothing about Irrlicht - when you generate your View matrix do you use [0,1,0] as the 'Up' vector (or [0,90,0], however its defined). If so, you may be running into problems when the way the direction the player is facing is equal to 'Up' since constructing the View matrix usually requires taking the cross product of the two directions so if they are the same vector the result is zero and weird poo poo starts to happen.

I only ask this because one of the first camera systems I ever wrote had this problem - everything worked great until the player looked straight up and then the View matrix became totally hosed and right turned into left, forward into backward, etc. It turned out that some parts of the View matrix were becoming negative and this swapped the coordinate system between left-handed and right-handed versions depending on what octant I happened to be looking in a the moment. It sounds like you could be having the 2D equivalent of that same issue since your X and Z values are effectively swapping sign by flipping to 180 degrees.

PDP-1
Oct 12, 2004

It's a beautiful day in the neighborhood.
Doubleposting with a question of my own -

I'm starting to look into AI systems, are there any particularly good websites/books/tutorials out there that you'd recommend? I realize that AI is a very broad topic, I'm just looking for a good overview of common techniques for pathfinding, decision making, etc. to get a feel for what's out there.

Rocko Bonaparte
Mar 12, 2002

Every day is Friday!

PDP-1 posted:

Longshot guess here since I know nothing about Irrlicht - when you generate your View matrix do you use [0,1,0] as the 'Up' vector (or [0,90,0], however its defined). If so, you may be running into problems when the way the direction the player is facing is equal to 'Up' since constructing the View matrix usually requires taking the cross product of the two directions so if they are the same vector the result is zero and weird poo poo starts to happen.
From what I can tell from the camera I am using, the up vector is indeed [0, 1, 0]. But what should I be doing instead? Here the camera is in effect looking down at the world as something rotates around its Y-axis.

PDP-1
Oct 12, 2004

It's a beautiful day in the neighborhood.
Your player can only rotate in the X-Y plane, right? If so you could try setting the camera Up direction to [0,1,0.1] so that the facing direction and Up direction can't ever be the same. It might look a bit off, but if the stuttering goes away you'll at least know you're on the right track.

If you can't change the camera Up direction for whatever reason, you'd need to test each rotation step to see if it would land the player on [0,1,0] and then tweak that value so they never face exactly that direction.

ynohtna
Feb 16, 2007

backwoods compatible
Illegal Hen

PDP-1 posted:

I'm starting to look into AI systems, are there any particularly good websites/books/tutorials out there that you'd recommend? I realize that AI is a very broad topic, I'm just looking for a good overview of common techniques for pathfinding, decision making, etc. to get a feel for what's out there.

I'm a fan of the AI Game Programming Wisdom series of books. They provide a comprehensive overview of practical AI solutions and implementation experience for video-games, unlike the more theoretical academic AI side of things that struggle to integrate into realtime game engines.

http://www.aiwisdom.com/

ynohtna fucked around with this message at 07:50 on May 30, 2011

devilmouse
Mar 26, 2004

It's just like real life.

PDP-1 posted:

I'm starting to look into AI systems, are there any particularly good websites/books/tutorials out there that you'd recommend? I realize that AI is a very broad topic, I'm just looking for a good overview of common techniques for pathfinding, decision making, etc. to get a feel for what's out there.

I like http://aigamedev.com/ - even the unpaid for version has a bunch of decent articles though it's slowed down a lot since he started the site a few years back. While the forums don't get a huge amount of traffic, they'll generally answer your questions if you don't need an answer NOWNOWNOW. The monthly digests he sends out are pretty handy with links to interesting whitepapers and writeups.

Twernmilt
Nov 11, 2005
No damn cat and no damn cradle.
I think I'm having NAT issues. I can establish a TCP connection between two processes on the same machine via the "localhost" address, but I can't establish a connection via my router's external IP address. I have the correct port forwarded to the server. Is there something obvious at the software level that I should be looking at? This does sound like an issue with the router and not something I can easily deal with in code, yes?

roomforthetuna
Mar 22, 2005

I don't need to know anything about virii! My CUSTOM PROGRAM keeps me protected! It's not like they'll try to come in through the Internet or something!

Twernmilt posted:

I think I'm having NAT issues. I can establish a TCP connection between two processes on the same machine via the "localhost" address, but I can't establish a connection via my router's external IP address. I have the correct port forwarded to the server. Is there something obvious at the software level that I should be looking at? This does sound like an issue with the router and not something I can easily deal with in code, yes?
It's possible/probable that the router only forward ports from the 'outside' interface. Have you tried connecting to the machine's localnet IP address?

Twernmilt
Nov 11, 2005
No damn cat and no damn cradle.

roomforthetuna posted:

It's possible/probable that the router only forward ports from the 'outside' interface. Have you tried connecting to the machine's localnet IP address?

That doesn't work either. It should be noted here that I had a friend try to connect as well with no luck. I've also tried making a very simple server/client just as a sanity check and they can't establish a connection outside of the machine either.

Edit: I figured it out. It ended up being me misunderstanding one of the bits of the library I'm using.

Twernmilt fucked around with this message at 22:50 on May 30, 2011

Hubis
May 18, 2003

Boy, I wish we had one of those doomsday machines...

Vino posted:

I think you're overthinking it. It is a slow algorithm but it only runs once each time the user clicks which isn't really all that often. Even the most pro Korean Starcraft player will only click once every 20 frames or so, you won't get a noticeable skip unless there's tens of thousands of units. Do it the simple way, worry about optimization later. In practice it all gets optimized away by the compiler and processor anyway.

This.

BUT... make sure your click resolver code is actually lightweight and not, in fact, doing something that can thrash like allocating memory or streaming resources from the disc. UI code is generally the most OO-abstracted in a game engine, and it's really easy for something nasty but seemingly innocuous (pushing elements into a vector on the heap, for example) that can balloon really nastily. In general, just keep in mind that resolving what gets clicked where should be "read only" is enough to avoid most problems.

Hughlander
May 11, 2005

Twernmilt posted:

I think I'm having NAT issues. I can establish a TCP connection between two processes on the same machine via the "localhost" address, but I can't establish a connection via my router's external IP address. I have the correct port forwarded to the server. Is there something obvious at the software level that I should be looking at? This does sound like an issue with the router and not something I can easily deal with in code, yes?

Few things to check:

1) What address are you binding to? Make sure it's inaddr_any and not inaddr_loopback or something similar.
2) Is it Windows? Is the windows firewall blocking?
3) Can you put any other device on the local network and see if that can connect? (IE: take the router forwarding the port out of the equation.)

OneEightHundred
Feb 28, 2008

Soon, we will be unstoppable!

devilmouse posted:

I like http://aigamedev.com/ - even the unpaid for version has a bunch of decent articles though it's slowed down a lot since he started the site a few years back. While the forums don't get a huge amount of traffic, they'll generally answer your questions if you don't need an answer NOWNOWNOW. The monthly digests he sends out are pretty handy with links to interesting whitepapers and writeups.
Probably one of the most useful things to come out in a while was the writeup on the STRIPS planner in FEAR, which is extremely good at minimizing the amount of effort needed to add new AI behavior, while not really being that complex in itself.

I'd highly recommend it over using FSMs, planning-based AIs are kind of the way things are going right now and they're not even that difficult.

OneEightHundred fucked around with this message at 19:29 on May 31, 2011

Blotto Skorzany
Nov 7, 2008

He's a PSoC, loose and runnin'
came the whisper from each lip
And he's here to do some business with
the bad ADC on his chip
bad ADC on his chiiiiip

OneEightHundred posted:

Probably one of the most useful things to come out in a while was the writeup on the STRIPS planner in FEAR, which is extremely good at minimizing the amount of effort needed to add new AI behavior, while not really being that complex in itself.

Nb. that FEAR's AI was actually pretty lovely outside of very constrained environments and most of the cool poo poo was scripted :(

Adbot
ADBOT LOVES YOU

Rocko Bonaparte
Mar 12, 2002

Every day is Friday!
I have some more physics questions, having hacked through some more Bullet stuff; I think I found a bug in the Irrlicht wrapper that I worked around and I don't know why the (0, y, 0) -> (180, y, 180), but I've worked around them. I am wondering now how collision is generally done for, say, melee attacks. Right now my player model and my enemy are wrapped up in spheres, and that does a decent job of keeping them on the ground. But now I have it set up so the player can hit a button and take a swing. The animation for the swing exits the bounding sphere. How are collisions generally handled here with an enemy?

It's going to feel like crap if the hit only registers if, say, I have hit the button while the two spheres are in contact. Because the enemy could very will toggle their animation too and we'll be pelting away at each other without the swords from other animation actually touching anything. Is this where you switch to a more specific binding method to test collisions? Or generally is it still approximated?

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply