Nypyren

Members
  • Content count

    4757
  • Joined

  • Last visited

Community Reputation

12062 Excellent

About Nypyren

Personal Information

  • Interests
    Programming
  1. I like to put spaces between statement groups like that as well. Managing large files: Most IDEs can collapse functions, letting you hide anything you're not working on. I usually jump between functions using GoToDefinition, NavigateBack, and symbolic searching; this reduces the need to scroll through files manually to look for something. If a file gets uncomfortably big, maybe it's just doing too much! It might be time to split it up.
  2. You're right, it comes down to personal preference.
  3. You're welcome However 'var' is still requires a bit of thought about when to use it or not. Things I consider are: - Can a programmer reading the code figure out the type quickly or not? If not then perhaps it's better to type out the name. - Do I save effort? I don't usually bother if the explicit type is 'int' or 'bool', etc. - If you explicitly want a less-derived type. For example if you say 'var x = SomeFunctionThatReturnsADerivedType();' but you want the type of the variable x to be BaseType instead of DerivedType so that you can reuse the variable with a BaseType value (or a DerivedType2 in a different fork of the inheritance hierarchy) later. In that case you have to either change the function to return the base type (the type inference happens using the statically-determined type, not the runtime type), or replace 'var' with the explicit type you want. - 'var' can automatically change if you refactor something involved in the inferred expression. This can be good or bad. Perhaps you use 'var' for a numeric type like int, but someone changes the expression to be 'long' instead. That might result in the code using that variable to change in behavior but still compile correctly. This isn't a big risk but it can occasionally lead to really strange bugs. - 'var' is very handy with generic code, and in foreach loops over Dictionaries, so that you don't have to type out a potentially complex thing like KeyValuePair<KeyType,List<ElementType>>.
  4. 'var' in C# is static type inference (the compiler replaces 'var' with the appropriate type name at compile time). It has nothing to do with dynamic typing. You can use it any time you want, if it makes things more convenient for you. The type of the variable cannot be changed to a non-assignable type later like a dynamically typed variable allows. (What I mean here is that if your 'var' resolves to class X at compile time, you can assign that variable a value of type X or any type derived from the class (or implementing the interface) X, just like an explicit typed variable). The C# keyword for dynamic typing is 'dynamic'.
  5. The Spawner class probably shouldn't be static - it would make it difficult to deal with if you ever needed two separate spawners, so you might as well change it and get the pain out of the way now. SpawnPatterns seems OK as a static class for now. The MSDN recommendations for public variables in C# are to use PascalCase (capitalized first letter), and private variables camelCase (lowercase first letter). Though these are coding conventions and you're free to choose whatever you want. That Func is complicated enough that you might want to define your own delegate type for it - this lets you give each parameter a name which will be helpful for remembering what each parameter does. For cumbersome types like the KeyValuePair<Enemy, float> you could use 'var' instead to shorten it. The {return;} all on one line looks weird. Just take the braces off and indent the 'return;', or put the { } on separate lines. This is another coding convention choice to make. Overall your code looks pretty good to me.
  6. I want a way to hide entire threads that I have no interest in, so they don't pollute the 'All Activity' section with their nonsense. Threads which I've already examined that I no longer have any interest in, or threads created by that petulant Cybergod dude. I'd like the ability to ignore both types of threads completely.
  7. AI will lead to the death of capitalism?

    If we do in fact manage to kill ourselves off (which seems like a possibility that cannot be ignored), it seems like we have a window of opportunity to bootstrap an AI that can carry on after we're gone. As individuals, we all eventually die anyway. It's more important in my mind that someone or something can continue where we left off, regardless of the form that entity takes.
  8. Affiliate links have always felt like clickbait to me. I was really sad when I started seeing them here.
  9. I watched the video you posted but did not see any mention of any-angle pathing. However I could see how it might be extended it to any angle pathfinding if you allowed more than 8 jump links per node. (i.e. links to all visible intersection/corner nodes). I looked at the source code and I don't see anything about any-angle support. Do you have a specific spot where an any-angle implementation is mentioned? Or did the example he gave in the video just happen to align with 8-direction, and the four diagonals are actually allowed to be any diagonal direction?
  10. C# Spaceship steering problem

    Update: OK, I examined the physics engine source code and it looks like it expects torques in world space. Looking at your code again, I'm worried about how you're manipulating the transformed vector on the AddTorque line. The fact that you're discarding the Z component could be what's causing the gimbal lock (see below for thought experiment). Ideally I think that your post-transformed torque vector should be passed directly to AddTorque with no further modifications, which means you should be making your tweaks before you transform it. Thought experiment: Torque vectors point along the axis of rotation that they would cause. If you want to rotate the nose to the left/right (yaw), your torque vector will be along the up/down axis of your ship. If you want to rotate the nose up/down (pitch), your torque vector will be along the ship's right/left axis. Assuming your base orientation is X=left/right, Y=up/down, and Z=forward/backward axis, if you put your ship into a 90 degree left/right orientation, your ship's front-back will be along the X axis and your ship's left-right axis will now correspond to world space Z axis. That means if you want to pitch up, your torque vector will need to be along the Z axis. But since you're zeroing out the Z component when you call AddTorque, this will result in zeroing out your torque vector completely and no torque will be applied.
  11. C# Spaceship steering problem

    It sounds like gimbal lock, but looking at the code I think that the high level concept of constructing a torque to apply should work like you want it to, regardless of orientation. My initial thought is that the transform step is somehow cancelling out the resulting torque whenever orientation starts significantly differing from your starting value (which is likely Identity?). Perhaps the torque needs to be applied in local space? Try just removing the Vector3.Transform line and pass (rot.TurnMultiplier*phys.SteeringTorque*0.00025f) directly to AddTorque and see what happens.
  12. I've interpreted the original question differently than all of the other posters.I believe you're asking about allowing "any-angle" paths (allowing continuous movement in arbitrary directions, not just 4 or 8 directions between cells). None of the previous responses are applicable to any-angle pathfinding. For a quick example, see Figure 1 in the following page: http://aigamedev.com/open/tutorials/theta-star-any-angle-paths/ The options I know of are: Find a path using the grid, and then use "string pulling" to straighten segments of that path. You will not get an optimal path using this approach, though, and it can be slow to perform something that tries to be close to optimal. Start with an "any-angle" algorithm such as Theta*. The stock implementation is slower than A*, however it may be possible to employ clever optimizations that are similar to JPS+ to an algorithm such as Theta*.
  13. Multithreading questions

    Don't use multiple mutexes to limit the number of simultaneous accessors - use a semaphore. If you use multiple mutexes, how do you pick which one to wait on? Then suddenly you have to synchronize that selection process as well or you're in for a world of hurt.
  14. Help me to better understand Rotation Matrix

    [redacted] I missed the part where you're doing axis+angle rotation.
  15. Team Explorer Remote and Local Master Branches

    Each dot is a "commit" - they represent changes made to one or more files. A single line between two commits means that the upper commit was created from the lower commit. In other words, the person who created the upper commit had the lower commit checked out when they committed their changes. The lower commit is called the "parent". A commit which has more than one parent is a "merge". These happen because two people can begin their work at the same time on different computers from the same (or different) starting points, make commits separately which don't know about each other, then try to push later. When the second person tries to push, git will tell them that they need to pull first. When they pull, git will merge the other person's work into their branch (and possibly need to resolve conflicts). This 'merge' step creates the multi-parent merge commits. After that, the second person can push. At any time, you or someone else can check out any commit in the history they want, and start making commits at that point. You can then merge those commits into any branch you want, if you feel like it, or leave them separated if you decide not to merge them (perhaps they are an experiment that you want to keep separate, for example). Clarification about 'local' and 'remote' branches: The branch you see on your own computer called "origin/master" is sometimes called a "remote tracking branch", frequently shortened to just "remote branch" and represents where your computer last fetched/pulled that branch from the 'origin'. 'origin' is the default name of whatever host (github, bitbucket, visual studio team services, etc) you cloned from, and where you push/pull to by default. The remote branch on your computer can differ from where the equivalent branch is on github/bitbucket/etc. It only updates when you fetch, pull, or push that branch. When you commit, you only update your local branch.