
Advertisement

Content Count
8006 
Joined

Last visited

Days Won
4
alvaro last won the day on October 13 2018
alvaro had the most liked content!
Community Reputation
21438 ExcellentAbout alvaro

Rank
Legend
Personal Information

Role
Programmer

Interests
Programming
Recent Profile Visitors

[SDL] shoot bullet projectile toward mouse position by calculating angle
alvaro replied to venonumuis's topic in General and Gameplay Programming
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; 
What problem?

Dynamic/static allocation of an array c11
alvaro replied to _WeirdCat_'s topic in General and Gameplay Programming
First link in a Google search for "c11": https://en.wikipedia.org/wiki/C11_(C_standard_revision) 
Dynamic/static allocation of an array c11
alvaro replied to _WeirdCat_'s topic in General and Gameplay Programming
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. 
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.

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 }

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.

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.

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: https://en.wikipedia.org/wiki/Multiarmed_bandit

My Math Disability and Learning Calculus for Procedural Generation and Artificial Intelligence
alvaro replied to RidiculousName's topic in Math and Physics
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. 
My Math Disability and Learning Calculus for Procedural Generation and Artificial Intelligence
alvaro replied to RidiculousName's topic in Math and Physics
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. 
That squaresincirclesinsquares 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.
 1 reply

2

My Math Disability and Learning Calculus for Procedural Generation and Artificial Intelligence
alvaro replied to RidiculousName's topic in Math and Physics
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. 
My Math Disability and Learning Calculus for Procedural Generation and Artificial Intelligence
alvaro replied to RidiculousName's topic in Math and Physics
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: https://www.youtube.com/playlist?list=PLZHQObOWTQDMsr9Krj53DwVRMYO3t5Yr 
Is There any way to Make this Method More Elegant?
alvaro replied to RidiculousName's topic in General and Gameplay Programming
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 nonconst reference.

Advertisement