Jump to content

  • Log In with Google      Sign In   
  • Create Account

Álvaro

Member Since 07 Mar 2002
Offline Last Active Today, 06:01 AM

#5285009 need help for board games.

Posted by Álvaro on 04 April 2016 - 06:20 AM

First let's try to clear a possible confusion: In the world of board-game programming the word "engine" usually refers to the AI part of the game. The visualization part is called the "GUI".

 

It took a long time for chess programmers to learn that it was best to separate the engine and the GUI, but you can learn from their experience. These days they run as separate processes that communicate via a pipe. The communication between the GUI and the engine usually happens using one of two text protocols: UCI or Winboard. You can also look at what go engines use, which is called GTP. I suggest you take inspiration from these protocols and then come up with one for your game.

 

Programming the engine is something that you probably have to do from scratch. But there is a lot of information on how to do it in places like the Chess Programming Wiki, and I have quite a bit of experience too, so you can ask here. Programming the GUI is where perhaps a game engine like Unity could help, depending on how fancy you want your graphics to be.




#5284943 RSA message limitation (with C++ source code)

Posted by Álvaro on 03 April 2016 - 07:42 PM

Technically the exponent is periodic modulo lcm(p - 1, q - 1) which is smaller than (p - 1)(q - 1) but there is not much difference, the lcm is usually within a small factor of the product depending on how many factors p - 1 and q - 1 share.


Oh, true that. Sorry, I haven't thought about the totient function in a long time.


#5284560 RSA message limitation (with C++ source code)

Posted by Álvaro on 31 March 2016 - 08:02 PM

From what I read, m must be less than p*q = n, and e must be less than (p - 1)*(q - 1) = totient.


It doesn't hurt if e is larger than (p - 1)*(q - 1). By the Euler-Fermat theorem, changing e by adding or subtracting (p - 1)*(q - 1) results in the same encoding.


#5284539 RSA message limitation (with C++ source code)

Posted by Álvaro on 31 March 2016 - 04:07 PM

It has to be coprime to both p - 1 and q - 1, otherwise the security is considerably weakened and/or the encryption is not reversible.


Oh, of course, it's p-1 and q-1, not p and q; sorry about that. You are going to need e' such that e*e' = 1(mod (p-1)*(q-1)), and that wouldn't work.
 

In the end I used e = 65537. I tried 65536 for fun, and the program died with a segfault LOL (I'm using someone else's bigint library).


Well, p-1 and q-1 are both even, so an even value of e won't do.


#5284318 RSA message limitation (with C++ source code)

Posted by Álvaro on 30 March 2016 - 01:18 PM

I am not aware of an attack that could exploit e being a small number. But what's wrong with making e be a random number between 0 and p*q? Technically you would have to verify that you didn't pick a multiple of p or q, but let's not worry about things that will not happen. :)


#5284040 Create triangles out of any set of points

Posted by Álvaro on 29 March 2016 - 07:04 AM

Yeah alvaro thats the fact but, i am not quite sure how to find a pressure of a submerged triangle at all,


The force on a triangle due to pressure is a vector orthogonal to the triangle whose magnitude is the area of the triangle times the average of the depth of the vertices times a couple other things (gravity and density, I think). Of course, if you have a triangle that straddles the surface of the water, you need to clip it before you do this computation.


#5284024 Create triangles out of any set of points

Posted by Álvaro on 29 March 2016 - 05:13 AM

Although a convex hull would not solve the problem you specifically mentioned. It does a damn good job at collecting all the external points. You can then use a trinagalization algorithm to compute triangles, which you  can then create an area from for your buoyancy problem.


I don't think that's right. The convex hull problem is typically understood to require not just selecting the points, but actually giving you a triangle list.

However, I don't think there is any need to compute this at all. The OP says the problem he really needs to solve is computing the submerged volume of an object. I suspect what he really needs is to compute buoyancy, which I haven't done before, but I am sure can be done by adding the pressure at each face of the object, and that would be much easier to do.


#5283638 Can memory leaks only caused by using the new keyword?

Posted by Álvaro on 26 March 2016 - 06:15 PM

How have you determined that there is a memory leak?


#5283153 slerp of two pairs of vectors

Posted by Álvaro on 24 March 2016 - 09:08 AM

No, they do not. Imagine a situation where A=D and B=C (so the two vectors are just swapping roles). At t = 0.5 the two vectors will be the same.


#5282983 Creating a PRNG input from three values

Posted by Álvaro on 23 March 2016 - 03:03 PM

What you are looking for is a hash function.

The following operations are all permutations of the integers in the interval [0,2^32):
* Add a constant: x + C
* Multiply by an odd constant: x * C
* XOR with a constant: x ^ C
* Rotate bits: (x >> S) + (x << (32 - S))

You can mix three integers using a sequence of those operations.

This is the first thing I would try:
// C1, C2, C3, C4, C5 and C6 are unsigned constants; pick some random values
// This code assumes 32-bit unsigned ints, which is what pretty much any compiler provides these days.
unsigned hash(unsigned x, unsigned y, unsigned z) {
  unsigned h = C1 ^ x;
  h *= C2|1u;
  h = (h << 16) + (h >> 16);
  h += C3 ^ y;
  h *= C4|1u;
  h = (h << 16) + (h >> 16);
  h += C5 ^ z;
  h *= C6|1u;
  h = (h << 16) + (h >> 16);
  return h;
}



#5282925 Calculating angular deceleration

Posted by Álvaro on 23 March 2016 - 11:37 AM

Angular deceleration caused by inertia is zero. Easiest formula ever!


#5282464 RSA message limitation (with C++ source code)

Posted by Álvaro on 21 March 2016 - 05:02 PM

No: It needs to be smaller than the product of the two prime numbers.


#5281247 C++ Self-Evaluation Metrics

Posted by Álvaro on 14 March 2016 - 01:58 PM

Stop asking stupid interview questions.


This. If I am at an interview and I get asked this question and something like "What is your greatest weakness?", I am walking out.


#5281139 Figuring out where a projectile will go

Posted by Álvaro on 13 March 2016 - 05:35 PM

Issue still is that you won't be able to generate a full path ^-^; you can get the vector at any given point, but your graph will be for that point in space only. The forces of gravity is not constant. The forces of gravity are a function of your distance relative to each body of mass. Which does not create an ODE. But I think a partial differential equation might be able to solve it. But you will have more than two independents.


This is simply not true. Not only are the equations of motion under a force that is described by a vector field and example of ODEs, but they are actually the first example of ODEs historically.

https://en.wikipedia.org/wiki/Equations_of_motion says:

This is equivalent to saying an equation of motion in r is a second order ordinary differential equation (ODE) in r,[...]




#5280214 Figuring out where a projectile will go

Posted by Álvaro on 08 March 2016 - 12:35 PM

So your gravity-style force is actually proportional to the inverse [not-squared] distance. Neither of my differential-equation experts had thought about this situation before.

I managed to find an energy function, which is something like E = 0.5*velocity^2 - log(distance*5000). Could you see if that quantity is preserved (up to integration error) in your trajectories, so I can see if I am on the right track?




PARTNERS