performance – Which hash algorithm is best for speed and identical hashes. (a lot of collisions)

I’m searching an existing hash function or trying to make a hash function that has a lot of collisions.

Regularly a hash is used for it’s ability to create unique hashes for hash tables or security purposes, but I desire the opposite.
I desire a hash function that has allot of collisions.
Preferably a simplistic hash function so finding a collision is easier/faster.

By the definition of a hash function. The hashes also have a predetermined length. I’d like a hash function that has this as a variable.

I’m new to this subject so I’m searching sources to create a hash function myself or candidate’s that might fulfill the requirements.

If I have definition or terms wrong, please correct me.

networking – Multiplayer tile based movement collisions cause client prediction to fail

I am developing a tile-based online multiplayer game, but I am stuck. Players can move across the grid in the four cardinal directions, as can enemies, but two players/enemies cannot occupy the same tile at the same time. Positions of all players/enemies are synced for all clients.

My current implementation of movement: Clients send a ‘request to move’ to the server whenever they are stationary on a tile.

I have implemented client prediction. When a button is pressed to move, the client shows their character immediately moving in that direction, as opposed to waiting for confirmation from the server, preventing lag between player input and visible results.

The issue arises when the player attempts to move to a position that will soon be occupied. For example, the player presses up when an enemy is very close to entering the tile above the player (though they can’t currently know that the enemy will choose that tile next). Locally this is confirmed and the upwards animation begins, but by the time the request to move up arrives at the server, the tile is no longer free, and the player is not moved up on the server.

This creates a situation where the player’s local position is out of sync with that of the server. My current solution to this is snapping the local player back to the server’s position when this happens, but this looks awful. It seems to be happening a lot, making the game nearly unplayable.

Is there a way around this?
Any help would be very much appreciated, thanks.

Some other notes: I send updates from the server 10 times a second, which consist of every object’s position (and other stuff). When a movement event is processed, the object’s position is updated immediately, even though an animation follows.

IT – Java to resolve hash collisions.

Learn Java. Could someone check my work? Unfortunately, the material I have been given to learn how to resolve hash collisions is terrible at best. Thank you.

h(key) = key modulo 5
list = 4, 6, 20, 14, 31, 29
hash table
index bucket
0 20
1 6, 31
2
3
4 4, 14, 29
//
list = 4, 6, 20, 14, 31, 29
h(key) = key modulo 11 with a hashTable size eleven
a) Linear probing to resolve collisions.
14 4 6 29 20 31
0 1 2 3 4 5 6 7 8 9 10
//
b) Quadratic probing.
14 4 31 6 29 20
0 1 2 3 4 5 6 7 8 9 10
//
c) Double hashing. h2(key) = 7 – ( key mod 7)
31 14 4 6 29 20
0 1 2 3 4 5 6 7 8 9 10
//
list = 4, 6, 15, 26, 8, 5
h(key) = key mod 11
a) Linear probing to resolve collisions.
4 15 6 26 8 5
0 1 2 3 4 5 6 7 8 9 10
//
b) Quadratic probing.
8 4 15 6 26 5
0 1 2 3 4 5 6 7 8 9 10
//
c) Double hashing. h2(key) = 7 – ( key mod 7)
8 4 6 5 26 15
0 1 2 3 4 5 6 7 8 9 10
//
d) Separate chaining. h(key) = key mod 5
list = 4, 6, 15, 26, 8, 5
hash table
index bucket
0 5
1 6, 26
2
3 8
4 4

algorithms – Parallel coloring to minimize collisions?

I have a graph in which there is a set of leader vertices $ L $. There is no edge between a pair of leader line vertices. Each leader summit $ u $ has a common color scheme $ C $ and a set of neighboring vertices $ N (u) $. A leader summit is oblivious to the decisions of other leader summits. Let $ w $ be a common neighbor for leader summits $ u $ and $ v $, that is to say., $ w in N (u) cap N (v) $. If the head vertices $ u $ and $ v $ assign the same color to $ w $, a collision occurs.

I would like to find an algorithm which is executed independently at each vertex and assigns a unique color to one of its neighbors so that the number of collisions is as small as possible.

This problem is probably studied before. Because I have little experience in graph theory, I hope that help from specialists in graph theory? Can you at least tell me a reference that I should read?

For now, I'm looking for "Parallel Graphic Coloring", "Leader Coloring", but I'm a bit confused.

unit – Collisions work in the editor but not in the compilation

This has been asked several times, but none of the responses worked; also, the other questions are very old. I have an object with a mesh collider on it. In the editor, collisions work perfectly. However, in the compiled game, there is no collision. It is important to note that other colliders (box collider, sphere collider, etc.) work perfectly well in the compiled game, as well as in the editor.

The mesh is as follows:
enter description of image here

What I have tried:

  • Recreate the entire prefab that has the collider.
  • Redo the mesh for the mesh collider.
  • Using a different format for the mesh (.fbx, .obj, etc.)

Additional details:
– The object has a rigid body and a convex mesh collider.

  • The object is moved via a script, using the speed of the rigid body.

  • It worked perfectly fine until I reduced each factor in the scene by a factor of 2. So, I opened Blender to half the size of the mesh. Whatever it is, the problem is not the mesh but the fact that it works in the editor and only the editor.

opengl – Help in the detection and resolution of AABB-AABB collisions like Minecraft

I am currently working on a Minecraft type game with OpenGL and C ++. I ended up abstracting a Camera object and configuring motion and even defining basic gravity as simulations, but I'm stuck on collision detection and resolution.

The movement is defined by a function which adds a speed "x" and "z" depending on the key pressed. I finally have a speed vector that can look like (-2.0, 0.0, 2.5). The speed vector is then added to the position vector of the camera in a Move function. Then I look for collisions and try to resolve them (currently only with the y-axis but even that doesn't work). The Move function code looks like:

void Camera::Move(const std::vector& cubePositions)
{
  glm::vec3 nPos = glm::vec3((int)(round(Position.x)), (int)(round(Position.y)), (int)(round(Position.z)));
  Position += Velocity;

  // Collision resolution
  for (float i = -2.0f; i <= 2.0f; i++)
  {
    for (float j = -2.0f; j <= 2.0f; j++)
    {
      for (float k = -2.0f; k <= 2.0f; k++)
      {
        if (std::find(cubePositions.begin(), cubePositions.end(), glm::vec3(nPos.x - i, nPos.y - j, nPos.z - k)) == cubePositions.end())
          continue;

        glm::vec3 box = glm::vec3(nPos.x - i, nPos.y - j, nPos.z - k);

        if
        (((Position.x - 0.5f <= box.x + 0.5f) || (Position.x + 0.5f >= box.x - 0.5f)) &&
         ((Position.y - 2.0f <= box.y + 0.5f) || (Position.y + 0.5f >= box.y - 0.5f)) &&
         ((Position.z - 0.5f <= box.z + 0.5f) || (Position.z + 0.5f >= box.z - 0.5f)))
        {
          LOG("Collision check with box " << box.x << " " << box.y << " " << box.z);
          Position.y -= Velocity.y;
          LOG("Position.y:  " << Position.y);
        }
      }
    }
  }

  LOG("Position: " << Position.x << " " << Position.y << " " << Position.z);
  Velocity = glm::vec3(0.0f);
}

(LOG is just a macro that prints on the screen). At the moment, when a collision with a block is detected, it causes this type of nervous movement. Here is the output:

...
(LOG) Position: 2.10997 -12.1245 3.19591
(LOG) Position: 2.10997 -12.1899 3.19591
(LOG) Position: 2.10997 -12.2546 3.19591
(LOG) Position: 2.10997 -12.3261 3.19591
(LOG) Position: 2.10997 -12.3952 3.19591
(LOG) Position: 2.10997 -12.4618 3.19591
(LOG) Position: 2.10997 -12.5288 3.19591
(LOG) Collision check with box 4 -15 5
(LOG) Position.y:  -12.5288
(LOG) Collision check with box 4 -15 4
(LOG) Position.y:  -12.4595
(LOG) Collision check with box 4 -15 3
(LOG) Position.y:  -12.3903
(LOG) Collision check with box 4 -15 2
(LOG) Position.y:  -12.321
(LOG) Collision check with box 4 -15 1
(LOG) Position.y:  -12.2518
(LOG) Collision check with box 3 -15 5
(LOG) Position.y:  -12.1825
(LOG) Collision check with box 3 -15 4
(LOG) Position.y:  -12.1133
(LOG) Collision check with box 3 -15 3
(LOG) Position.y:  -12.044
(LOG) Collision check with box 3 -15 2
(LOG) Position.y:  -11.9748
(LOG) Collision check with box 3 -15 1
(LOG) Position.y:  -11.9055
(LOG) Collision check with box 2 -15 5
(LOG) Position.y:  -11.8363
(LOG) Collision check with box 2 -15 4
(LOG) Position.y:  -11.767
(LOG) Collision check with box 2 -15 3
(LOG) Position.y:  -11.6978
(LOG) Collision check with box 2 -15 2
(LOG) Position.y:  -11.6285
(LOG) Collision check with box 2 -15 1
(LOG) Position.y:  -11.5593
(LOG) Collision check with box 1 -15 5
(LOG) Position.y:  -11.49
(LOG) Collision check with box 1 -15 4
(LOG) Position.y:  -11.4208
(LOG) Collision check with box 1 -15 3
(LOG) Position.y:  -11.3515
(LOG) Collision check with box 1 -15 2
(LOG) Position.y:  -11.2823
(LOG) Collision check with box 1 -15 1
(LOG) Position.y:  -11.213
(LOG) Collision check with box 0 -15 5
(LOG) Position.y:  -11.1437
(LOG) Collision check with box 0 -15 4
(LOG) Position.y:  -11.0745
(LOG) Collision check with box 0 -15 3
(LOG) Position.y:  -11.0052
(LOG) Collision check with box 0 -15 2
(LOG) Position.y:  -10.936
(LOG) Collision check with box 0 -15 1
(LOG) Position.y:  -10.8667
(LOG) Position: 2.10997 -10.8667 3.19591
(LOG) Position: 2.10997 -10.9176 3.19591
...

(here, when I say with the box x y z, x y z refers to the coordinates of the box, which are only transformations applied to a defined set of vertices when each box is drawn)

I've been working on it for a while and I've been looking for a solution for a while, but I haven't found one. I appreciate any help 🙂

Edit: I changed the if condition since I discovered it, false. But the rebound movement still exists, but on a smaller scale.
The correct if condition:

if
        (((Position.x - 0.5f <= box.x + 0.5f) && (Position.x + 0.5f >= box.x - 0.5f)) &&
         ((Position.y - 2.0f <= box.y + 0.5f) && (Position.y + 0.5f >= box.y - 0.5f)) &&
         ((Position.z - 0.5f <= box.z + 0.5f) && (Position.z + 0.5f >= box.z - 0.5f)))

The result:

...
(LOG) Position: 5.43324 -12.5657 6.24592
(LOG) Collision check with box 6 -15 7
(LOG) Position.y:  -12.5657
(LOG) Collision check with box 6 -15 6
(LOG) Position.y:  -12.5014
(LOG) Collision check with box 5 -15 7
(LOG) Position.y:  -12.4371
(LOG) Position: 5.43324 -12.4371 6.24592
(LOG) Position: 5.43324 -12.5011 6.24592
(LOG) Collision check with box 6 -15 7
(LOG) Position.y:  -12.5011
(LOG) Collision check with box 6 -15 6
(LOG) Position.y:  -12.4362
(LOG) Position: 5.43324 -12.4362 6.24592
(LOG) Position: 5.43324 -12.5246 6.24592
(LOG) Collision check with box 6 -15 7
(LOG) Position.y:  -12.5246
(LOG) Collision check with box 6 -15 6
(LOG) Position.y:  -12.4312
(LOG) Position: 5.43324 -12.4312 6.24592
...

game maker – How to make a path without collisions regardless of the size of the enemy / grid?

I am making a game where I have a player and enemies who, depending on the distance, follow the player.

In order for enemies to follow the player, the map was marked with a grid. When the player approaches the enemy, the enemy creates a path to the player, ignoring the walls (obj_Block).

Code – Creation grid (obj_ADM):

global.grid=mp_grid_create(0,0,celHor,celVer,celLar,celAlt);

mp_grid_add_instances(global.grid,obj_Block,false);

Code – Creation path (obj_Enemy):

xPlayer=(obj_Player.x div obj_ADM.celLar)*obj_ADM.celLar+obj_ADM.celLar/2;
yPlayer=(obj_Player.y div obj_ADM.celAlt)*obj_ADM.celAlt+obj_ADM.celAlt/2;

if(mp_grid_path(global.grid,caminho,x,y,xPlayer,yPlayer,1)){
    path_start(caminho,velocidade,path_action_stop,false);
}

enter description of image here

So something similar to the image below occurs:

enter description of image here

  • Purple Square => enemy
  • Black squares => wall

The enemy ends up crossing part of the wall while chasing the player.

This is obviously due to the different size of the grid and the enemy. Because I did a test with the enemy with the size of 20×20 and it worked perfectly.

I changed the size of the grid (which creates the path) to 32×32, and it turned out that instead of crossing the wall, the enemy ends up being far from walls (in some places on the map):

enter description of image here

I would like to know how to do so that none of these situations occur. Whatever the size of the enemy.

Video that I used to make the code:

Raycast checks for collisions between XZ coords without Y / Unity C # rotation

I'm really new to Unity / C # (I have a bit of GML experience but far from being professional) and I'm building my first prototype.

Originally, I copied THIS script to get a cube that turns face to face along one of its bottom edges.

Currently, the state of play is the "rolling" cube on a 10×10 grid. The grid currently has a border of walls. I want the cube to fire a rayCast in the direction the cube is moving, check if there is a wall and decide if the cube can move in that direction.

Here's how I set it up previously:

Vector3 up = new Vector3(0, 0, 0.5f);
Vector3 right = new Vector3(.5f, 0, 0);
Vector3 down = new Vector3(0, 0, -0.5f);
Vector3 left = new Vector3(-.5f, 0, 0);
Vector3 currentDirection = Vector3.zero;

bool Valid()
{
    Ray myRay = new Ray(transform.position + currentDirection, transform.forward);
    RaycastHit hit;

    Debug.DrawRay(myRay.origin, myRay.direction, Color.red);
    if (Physics.Raycast(myRay, out hit, rayLength))
    {
        if (hit.collider.tag == "Wall")
        {
            return false;
        }
    }
    return true;
}

currentDirection is set to when the "WASD" motion keys are pressed. I know that one problem I run into is that transform.forward doesn't work because the Y rotation of my cube never changes.

GIF format is not supported, so here is a link presenting the problem:
Movement and clipping: https://i.imgur.com/XxlEx1G.gifv

Overall, I was wondering how to get the raycast to shoot in the proper direction based on the movement.

Sorry if the answer is incredibly easy and I just miss it.
Thanks for the help,
Kalfin

geometry – Generation of Tilemap collisions – Tracing of polygons with slopes

I use Godot for my game, but it has an unfortunate quirk with a tilemap collision where physical objects can bounce strangely near tile joints and kinematic bodies can often get stuck in seams as well. For the first alpha work, I was able to work around this by not using the tilemap collision and then drawing the contours by hand … could easily lead to incompatible collision data, I ; therefore decided that this process should be automated.

Tilemaps have different types of tiles – fully solid, diagonal slopes and 2: 1 slopes.

My first attempt was to match each of these types to a half-tile size, marking each vertex as solid or non-solid, then combining all the vertices (with their overlap) into a single grid of vertices. I could then use all of these together by walking along the perimeter and probing forward to detect the corners. It turns out that it works well for convex turns but presents serious problems in concave turns, moreover there is not enough data to correctly detect the slopes, it often results in pieces in additional slope or slightly sloping cuts.

From there, I decided to add additional information to the vertex grid, for example if a vertex is a slope edge and to do some smart things surrounding the properties of its overlap, but that explodes quickly in many specific cases.

I spent much of the day thinking about adding vertex normals to each tile definition, but I realized that this was not going to work without adding a bunch of different types of solidity of tile.

Are there better approaches than I think that don't involve fragile / lossy intermediate representations or ridiculous amounts of special cases?

unit – How to avoid collisions between instantiated prefabs

I am creating a virtual creature evolution system like here.
I want the crash checks performed at the unit to be as efficient as possible. I want to simulate a large amount of creatures at once (50-200).
I have a prefab of a creature. Each creature is made up of several nodes. The nodes of the same creature must collide with themselves but must not collide with nodes which are in other creatures. What is the most effective way to do it?

I thought about checking the root of the collision object, but it just prevents the collision and does not eliminate the unnecessary checks that are done. I have also looked at solutions involving the "layer collision matrix", but still haven't figured out a way to make it work.

Thanks in advance.