Advertisement Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

  • Days Won


alvaro last won the day on October 13 2018

alvaro had the most liked content!

Community Reputation

21438 Excellent


About alvaro

  • Rank

Personal Information

  • Role
  • Interests

Recent Profile Visitors

44401 profile views
  1. I want to point out that using atan2 followed by cos and sin is needlessly complicated, as it’s often the case when you use angles. You don’t need angles. Here’s how you normalize a vector: float inv_length = 1.0f / sqrt(x*x + y*y); x *= inv_length; y *= inv_length;
  2. alvaro

    Sphere-AABB Intersection Problem

    What problem?
  3. First link in a Google search for "c11":
  4. Why is this tagged "C++" but has "c11" in the title? Which is it? It's good to know what language we are talking about.
  5. alvaro

    AI for strategic decider

    Try to use proper grammar. I honestly don't understand what you are asking. You should also provide some context: Tell us what you are trying to do, what you have found in searching for a solution, what options you are considering based on what you have read, what you have tried, what relevant experience you have, etc.
  6. alvaro

    float rounding problem

    Another solution if you need "exact numbers" is to work with rationals. You could define a class that has two integer members, `numerator' and `denominator'. You then define all the usual operations with those numbers without ever losing precision. Make sure to eliminate common factors between numerator and denominator after each operation. One potential problem is that the numbers might get very large. For instance, 1/2 + 1/3 + 1/5 + 1/7 + 1/11 + 1/13 + 1/17 + 1/19 + 1/23 + 1/29 + 1/31 = 314016924901/200560490130 So at some point your integer type is going to overflow and you are going to get nonsensical results. The solution is to use an underlying integer type that uses a vector of "limbs" (think of them as "digits", except you are using base 2^64 instead of base 10). This part is tricky to implement right, although it's a good programming exercise. Fortunately people already have done all of this work for you, so you can install the GNU MP library and use the type mpq_class. #include <iostream> #include <gmpxx.h> int main() { mpq_class x = mpq_class(1,2) + mpq_class(1,3) + mpq_class(1,5) + mpq_class(1,7) + mpq_class(1, 11) + mpq_class(1, 13) + mpq_class(1, 17) + mpq_class(1, 19) + mpq_class(1, 23) + mpq_class(1, 29) + mpq_class(1, 31); std::cout << x << '\n'; // prints 314016924901/200560490130 }
  7. I mean that I don't know where this question was found. See Lactose's question. I don't know what a "test paper" is. I don't usually encounter questions worth "2 marks" (whatever that is) in the wild.
  8. I think the question is perfectly clear, although I don't know the context in which it is being posed. The OP was asked to demonstrate his understanding of the exploration versus exploitation dilemma, and he demonstrated that he only understands the exploitation side.
  9. No, I don't think you understand the issue at all. The result of the action is somewhat random, and the utility is assigned not to the actions, but to the individual outcomes. In other words, every time you take a particular action some utility is observed, but this is only a sample from a random variable, whose distribution is not known. You want to pick actions with high expected utility (exploitation), but you only have a noisy estimate of this expected utility, so over time you want to try every action enough times that you discover which action that is (exploration). Further reading here:
  10. Oh, sorry I missed that question at first. Calculus is necessary to understand the world, so I recommend taking it in general. I don't know how necessary it is specifically in procedural generation. Perhaps to understand Perlin noise it's a good idea to know some calculus. But you can probably just treat it as a black box, use it to make some pictures and never bother with the fine details. For AI, the only place where you absolutely need it is for computing the gradient of a loss function in machine learning ("backpropagation"). And again, these days there are many libraries that do the dirty work for you, so you can probably get away with very little understanding of the details.
  11. Here's how I'd figure out the relation between cos(2x) and cos(x) (which I actually don't remember). One of the very few formulas I do remember is: exp(i*x) = cos(x) + i*sin(x) Even for this formula, what I really remember is that exp(i*x) is a point in the unit circle at an angle x, and the rest I can write down from there. Computing the square of that, I get exp(i*2*x) = (cos(x) + i*sin(x))^2 But we also have exp(i*2x) = cos(2x) + i*sin(2x) If I look at the real part of those two expressions, I think I'll get the identity I want: cos(x)^2 - sin(x)^2 = cos(2x) I can get rid of the sin(x)^2 because I know that cos(x)^2+sin(x)^2=1. Again, this is not something I remember, it's just the fact that cos(x) and sin(x) are the coordinates of a point on the unit circle. cos(x)^2 - (1 - cos(x)^2) = cos(2x) 2*cos(x)^2 - 1 = cos(2x) cos(x)^2 = (cos(2x)+1)/2 There you have it. With a little bit of practice, this process doesn't take much time at all. If I have been doing trigonometry problems recently, I might remember the formula for a little while, but in the long term, I know I'll be able to derive it when I need it.
  12. alvaro


    That squares-in-circles-in-squares diagram might give you the qualitative feeling of things getting smaller as you move to the middle of the image, which is a feature of perspective. However, it's not correct in the details. The size of things changes exponentially in that diagram, but things only get hyperbolically smaller in correct perspective. Imagine a 3D space of points with coordinates (x,y,z), with your eye at the origin. The plane of the screen in front of you consists of all the points where z=1. If you have an arbitrary point in front of you (i.e., (x,y,z) with z>0), you can consider the ray that starts at your eye and passes through that point. That ray will intersect the screen plane at (x/z,y/z,1). So just draw the point at (x/z,y/z) on the screen. That's nearly all there is to perspective.
  13. If the explanations in those videos make sense to you, there is a good chance you can do calculus just fine. The key test is whether you can learn to solve problems. Math really is about solving problems. Knowing formulas and arithmetic facts is not very important. I do math for a living, and I remember very few formulas myself. But if I understand the concepts well, I can usually make a little diagram of the situation and derive whatever formulas I need. It sounds like in your math classes so far things have been framed as "here's a type of problem we may ask you about, here's a formula where you can plug in some numbers to solve that type of problem." That's not at all what real mathematics feels like. Good luck to you, whatever you end up doing.
  14. Disclaimer: I don't have any experience with people with math disabilities. With that out of the way, if it makes sense for your academic career to get that waiver, do it. Whatever you don't learn by not taking calculus you can always learn when you need it. Actually, most people will learn math better if they have a motivating problem they are trying to solve. I'm curious if you can follow the explanations in these videos:
  15. How's this? case "Weapon": Main.organ.swap(this.weapon, item); // This function can check if this.weapon is null if it needs to this.weapon = item; break; EDIT: Depending on the semantics of function calls in Java, you might be able to do the assignment inside that function as well. In C++ one could do that by passing the first argument as a non-const reference.
  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!