• Advertisement

Search the Community

Showing results for tags 'Algorithm'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Categories

  • Audio
    • Music and Sound FX
  • Business
    • Business and Law
    • Career Development
    • Production and Management
  • Game Design
    • Game Design and Theory
    • Writing for Games
    • UX for Games
  • Industry
    • Interviews
    • Event Coverage
  • Programming
    • Artificial Intelligence
    • General and Gameplay Programming
    • Graphics and GPU Programming
    • Engines and Middleware
    • Math and Physics
    • Networking and Multiplayer
  • Visual Arts
  • Archive

Categories

  • News

Categories

  • Audio
  • Visual Arts
  • Programming
  • Writing

Categories

  • GameDev Unboxed

Categories

  • Game Dev Loadout

Categories

  • Game Developers Conference
    • GDC 2017
    • GDC 2018
  • Power-Up Digital Games Conference
    • PDGC I: Words of Wisdom
    • PDGC II: The Devs Strike Back
    • PDGC III: Syntax Error

Forums

  • Audio
    • Music and Sound FX
  • Business
    • Games Career Development
    • Production and Management
    • Games Business and Law
  • Game Design
    • Game Design and Theory
    • Writing for Games
  • Programming
    • Artificial Intelligence
    • Engines and Middleware
    • General and Gameplay Programming
    • Graphics and GPU Programming
    • Math and Physics
    • Networking and Multiplayer
  • Visual Arts
    • 2D and 3D Art
    • Critique and Feedback
  • Topical
    • Virtual and Augmented Reality
    • News
  • Community
    • For Beginners
    • GameDev Challenges
    • GDNet+ Member Forum
    • GDNet Lounge
    • GDNet Comments, Suggestions, and Ideas
    • Coding Horrors
    • Your Announcements
    • Hobby Project Classifieds
    • Indie Showcase
    • Article Writing
  • Affiliates
    • NeHe Productions
    • AngelCode
  • Workshops
    • C# Workshop
    • CPP Workshop
    • Freehand Drawing Workshop
    • Hands-On Interactive Game Development
    • SICP Workshop
    • XNA 4.0 Workshop
  • Archive
    • Topical
    • Affiliates
    • Contests
    • Technical
  • GameDev Challenges's Topics

Calendars

  • Community Calendar
  • Games Industry Events
  • Game Jams
  • GameDev Challenges's Schedule

Blogs

There are no results to display.

There are no results to display.

Developers

Developers


Group


About Me


Website


Industry Role


Twitter


Github


Twitch


Steam

Found 114 results

  1. Hi, guys! I have a rather abstract question, because I don't know which side to approach to its solution. So, I would appreciate any information. I have a task to create a simple game that generates floor plans and I following by this perfect algorithm (https://www.hindawi.com/journals/ijcgt/2010/624817/). At the moment I use squarified treemaps (http://www.win.tue.nl/~vanwijk/stm.pdf) and here no problems. I create nested array in which elements are rooms with size. Problems starts when I trying to represent generated "rooms" as edges and vertexes (a, b, c, d steps in attached picture) That representation can give me access to this elements as special "entities" in future game versions. I don't have skills in graphs (and do I need graphs?) and at the moment totally stucked at this step. How can I represent room walls as trees (or graphs?) at this step? Calculate size of squares (rooms) and convert sides to a vectors? Then in loop find shared vectors (same position by "x" or "y") and determine them as shared walls? The instinct tells me that there exist more elegant and efficient ways. Anyway, thanks for any information about this.
  2. Hey guys!, So, I'm basically working on an explorer right now. It should, as the name suggests, explore the entire thing, the most efficient way possible. Your character has vision around you, of, 10x10. The map is much bigger, 100x100. However, it can't just go straight from a corner to another, because: The tiles can be an occupied, or un-occupied one. You can add weights to the tiles, so feel free to use this in your advantage (let's say, adding an extra weight to a visited tile so you can compare visited against non-visited ones). You can use the Pathfinder I'm using, based on the A* algorithm. So, I could be wrong, but by basic logic, I assumed that the "fastest way" to explore the entire thing, is answering the question "What is the nearest tile that I can walk in, that is not occupied and that can reveal as much fog-of-war (unvisited tile) as possible?"... My questions are: 1) Is my question correct? is that really the best way to explore the entire map? 2) If so, what's the best way to know "which is the tile that could reveal the most fog of war"? Once I get the tile that reveals the most fog of war possible, then I just throw the pathfinder to it. But I'm having problems doing a good way to achieve that :'( I hope you guys can help me on this one! Thank you
  3. So what is up? What did I miss? I finally get my PC working and am bombarded with emails asking about marching cubes. Get on Gamedev.net and it's even here people are researching marching cubes. All of the gaming forums is a buzz with players theories on how marching cubes work, developers looking for teams to build a marching cube games. So why the spike? Reminds me of when Minecraft released.
  4. Hi Gamedev team, I am trying to re-implement the fluid simulation from the following paper . http://movement.stanford.edu/courses/cs448-01-spring/papers/foster.pdf. However, I am stuck with the level set method as it generates very strange resultt. The water should move much faster than the level set actually propagates, so I think there is a bug in my levelSetPropagation. However, I tried now for several months, but I just can't get it right. In the lower image you can see the problem. The scene is a breaking dam. While the inserted particles move quite fast , my level set seems to stick to the wall and does not propagate correctly. As the particles are moving correctly, I assume the error lies in my level set propagation. The level set sticks to the wall very long which looks really strange and not correct. I also inserted my level set propagation code below. If anybody could give me a hint on what I am doing wrong please let me know. If you require more information just let me know and I will reply as soon as possible. thank you for your support! void solverFedkiw::levelSetExtensionVelocity(){ int xSize = 1+newgrid->getXSize(),ySize = 1+newgrid->getYSize(),zSize = 1+newgrid->getZSize(); int i, j, k; enum{CLOSE, FAR, ACCEPTED}; std::multimap<float, Index> distances; //! distances of close cells, sorted due to multimap //! Algorithm taken from "The Fast construction of extension velocities in level set methods" //! by adalsteinsson and Sethian for(int direction=0;direction<3;direction++) { int dx=0,dy=0,dz=0; if(direction==0) dx=1; else if(direction==1) dy=1; else if(direction==2) dz=1; //! Initialize all values to FAR. These will become "all other points" -> page 8 for(i=0;i<xSize;i++){ for(j=0;j<ySize;j++){ for(k=0;k<zSize;k++) sets[j][k] = FAR; } } //! Build narrow band for(i=1;i<xSize-1;i++) { for(j=1;j<ySize-1;j++) { for(k=1;k<zSize-1;k++){ if((newgrid->getCellType(i, j, k) == grid::WALL) || (newgrid->getCellType(i, j, k) == grid::HOLDER)) continue; //! Test whether left neighbour is different (i.e. change of cell type) if(newgrid->getCellType(i, j, k) != newgrid->getCellType(i-dx, j-dy, k-dz)) { sets[j][k] = ACCEPTED; newgrid->setDistance(i, j, k, 0); //! All neighbours of the onsurface cells are set to CLOSE if(sets[i+1][j][k] == FAR) sets[i+1][j][k] = CLOSE; if(sets[i-1][j][k] == FAR) sets[i-1][j][k] = CLOSE; if(sets[j+1][k] == FAR) sets[j+1][k] = CLOSE; if(sets[j-1][k] == FAR) sets[j-1][k] = CLOSE; if(sets[j][k+1] == FAR) sets[j][k+1] = CLOSE; if(sets[j][k-1] == FAR) sets[j][k-1] = CLOSE; } } } } //! put the close ones in the map for(i=1;i<xSize-1;++i) { for(j=1;j<ySize-1;++j) { for(k=1;k<zSize-1;++k) { if(sets[j][k] == CLOSE){ distances.insert(std::pair<float, Index>(1, Index(i, j, k))); newgrid->setDistance(i, j, k, 1); } } } } //! Perform marching algorithm according to page 8 while(!distances.empty()){ //! Begin gives back iterator. The second element is the direction (the first one contains a float containing the distance) Index idx = (distances.begin())->second; //! Move the point into accepted and remove it from distances sets[idx.i][idx.j][idx.k] = ACCEPTED; distances.erase(distances.begin()); if(newgrid->getCellType(idx.i, idx.j, idx.k) != grid::AIR) continue; //! Recompute the velocities according to page 13 float totalDistance=0, weightedSpeed=0, distance; //! Test whether neighbour is inside the fluid if(sets[idx.i+1][idx.j][idx.k] == ACCEPTED){ distance = fabs(newgrid->getDistance(idx.i+1, idx.j, idx.k) - newgrid->getDistance(idx.i, idx.j, idx.k)); if(direction==0) weightedSpeed += newgrid->getU(idx.i+1, idx.j, idx.k) * distance; else if(direction==1) weightedSpeed += newgrid->getV(idx.i+1, idx.j, idx.k) * distance; else if(direction==2) weightedSpeed += newgrid->getW(idx.i+1, idx.j, idx.k) * distance; totalDistance += distance; } if(sets[idx.i-1][idx.j][idx.k] == ACCEPTED){ distance = fabs(newgrid->getDistance(idx.i-1, idx.j, idx.k) - newgrid->getDistance(idx.i, idx.j, idx.k)); if(direction==0) weightedSpeed += newgrid->getU(idx.i-1, idx.j, idx.k) * distance; else if(direction==1) weightedSpeed += newgrid->getV(idx.i-1, idx.j, idx.k) * distance; else if(direction==2) weightedSpeed += newgrid->getW(idx.i-1, idx.j, idx.k) * distance; totalDistance += distance; } if(sets[idx.i][idx.j+1][idx.k] == ACCEPTED){ distance = fabs(newgrid->getDistance(idx.i, idx.j+1, idx.k) - newgrid->getDistance(idx.i, idx.j, idx.k)); if(direction==0) weightedSpeed += newgrid->getU(idx.i, idx.j+1, idx.k) * distance; else if(direction==1) weightedSpeed += newgrid->getV(idx.i, idx.j+1, idx.k) * distance; else if(direction==2) weightedSpeed += newgrid->getW(idx.i, idx.j+1, idx.k) * distance; totalDistance += distance; } if(sets[idx.i][idx.j-1][idx.k] == ACCEPTED){ distance = fabs(newgrid->getDistance(idx.i, idx.j-1, idx.k) - newgrid->getDistance(idx.i, idx.j, idx.k)); if(direction==0) weightedSpeed += newgrid->getU(idx.i, idx.j-1, idx.k) * distance; else if(direction==1) weightedSpeed += newgrid->getV(idx.i, idx.j-1, idx.k) * distance; else if(direction==2) weightedSpeed += newgrid->getW(idx.i, idx.j-1, idx.k) * distance; totalDistance += distance; } if(sets[idx.i][idx.j][idx.k+1] == ACCEPTED){ distance = fabs(newgrid->getDistance(idx.i, idx.j, idx.k+1) - newgrid->getDistance(idx.i, idx.j, idx.k)); if(direction==0) weightedSpeed += newgrid->getU(idx.i, idx.j, idx.k+1) * distance; else if(direction==1) weightedSpeed += newgrid->getV(idx.i, idx.j, idx.k+1) * distance; else if(direction==2) weightedSpeed += newgrid->getW(idx.i, idx.j, idx.k+1) * distance; totalDistance += distance; } if(sets[idx.i][idx.j][idx.k-1] == ACCEPTED){ distance = fabs(newgrid->getDistance(idx.i, idx.j, idx.k-1) - newgrid->getDistance(idx.i, idx.j, idx.k)); if(direction==0) weightedSpeed += newgrid->getU(idx.i, idx.j, idx.k-1) * distance; else if(direction==1) weightedSpeed += newgrid->getV(idx.i, idx.j, idx.k-1) * distance; else if(direction==2) weightedSpeed += newgrid->getW(idx.i, idx.j, idx.k-1) * distance; totalDistance += distance; } if(direction==0) newgrid->setU(idx.i, idx.j, idx.k,weightedSpeed/totalDistance); else if(direction==1) newgrid->setV(idx.i, idx.j, idx.k,weightedSpeed/totalDistance); else if(direction==2) newgrid->setW(idx.i, idx.j, idx.k,weightedSpeed/totalDistance); //! Move all neighbouring points of trial that are in Far to Close float dist = newgrid->getDistance(idx.i, idx.j, idx.k); if(newgrid->getCellType(idx.i+1, idx.j, idx.k)!=grid::WALL && newgrid->getCellType(idx.i+1, idx.j, idx.k)!=grid::HOLDER && sets[idx.i+1][idx.j][idx.k] == FAR) { newgrid->setDistance(idx.i+1, idx.j, idx.k, dist+1); sets[idx.i+1][idx.j][idx.k] = CLOSE; distances.insert(std::pair<float, Index>(dist+1, Index(idx.i+1, idx.j, idx.k))); } if(newgrid->getCellType(idx.i-1, idx.j, idx.k)!=grid::WALL && newgrid->getCellType(idx.i-1, idx.j, idx.k)!=grid::HOLDER && sets[idx.i-1][idx.j][idx.k] == FAR) { newgrid->setDistance(idx.i-1, idx.j, idx.k, dist+1); sets[idx.i-1][idx.j][idx.k] = CLOSE; distances.insert(std::pair<float, Index>(dist+1, Index(idx.i-1, idx.j, idx.k))); } if(newgrid->getCellType(idx.i, idx.j+1, idx.k)!=grid::WALL && newgrid->getCellType(idx.i, idx.j+1, idx.k)!=grid::HOLDER && sets[idx.i][idx.j+1][idx.k] == FAR) { newgrid->setDistance(idx.i, idx.j+1, idx.k, dist+1); sets[idx.i][idx.j+1][idx.k] = CLOSE; distances.insert(std::pair<float, Index>(dist+1, Index(idx.i, idx.j+1, idx.k))); } if(newgrid->getCellType(idx.i, idx.j-1, idx.k)!=grid::WALL && newgrid->getCellType(idx.i, idx.j-1, idx.k)!=grid::HOLDER && sets[idx.i][idx.j-1][idx.k] == FAR) { newgrid->setDistance(idx.i, idx.j-1, idx.k, dist+1); sets[idx.i][idx.j-1][idx.k] = CLOSE; distances.insert(std::pair<float, Index>(dist+1, Index(idx.i, idx.j-1, idx.k))); } if(newgrid->getCellType(idx.i, idx.j, idx.k+1)!=grid::WALL && newgrid->getCellType(idx.i, idx.j, idx.k+1)!=grid::HOLDER && sets[idx.i][idx.j][idx.k+1] == FAR) { newgrid->setDistance(idx.i, idx.j, idx.k+1, dist+1); sets[idx.i][idx.j][idx.k+1] = CLOSE; distances.insert(std::pair<float, Index>(dist+1, Index(idx.i, idx.j, idx.k+1))); } if(newgrid->getCellType(idx.i, idx.j, idx.k-1)!=grid::WALL && newgrid->getCellType(idx.i, idx.j, idx.k-1)!=grid::HOLDER && sets[idx.i][idx.j][idx.k-1] == FAR) { newgrid->setDistance(idx.i, idx.j, idx.k-1, dist+1); sets[idx.i][idx.j][idx.k-1] = CLOSE; distances.insert(std::pair<float, Index>(dist+1, Index(idx.i, idx.j, idx.k-1))); } } } } [/CODE]
  5. Contact Area triangle sphere

    Hello, It is a complicated subject I think, but how would you compute the contact area between a sphere and a triangle? I thought to use the GJK algorithm combined with the EPA algorithm, but it could be the wrong way.
  6. For a RPG with online components like player(s) vs. player(s). And client–server for arenas. Any links, articles, posts, books, tips, best practices, and resources? Thank you Edit: multi-platform: win, OS10, and Linux Edit2: links https://www.reddit.com/r/PUBATTLEGROUNDS/comments/7p0n18/the_truth_of_online_game_cheating/ https://stackoverflow.com/questions/960499/how-to-prevent-cheating-in-our-multiplayer-games https://stackoverflow.com/questions/13826786/how-to-secure-client-side-anti-cheat?noredirect=1&lq=1 https://stackoverflow.com/questions/15760077/android-board-like-networked-multiplayer-game-anti-cheating?noredirect=1&lq=1 https://stackoverflow.com/questions/143231/protection-against-automation/143241#143241 https://en.wikipedia.org/wiki/PunkBuster https://en.wikipedia.org/wiki/NProtect_GameGuard https://en.wikipedia.org/wiki/Valve_Anti-Cheat https://en.wikipedia.org/wiki/Cheating_in_online_games#Anti-cheating_methods_and_limitations https://en.wikipedia.org/wiki/Executable_compression https://en.wikipedia.org/wiki/Blizzard_Entertainment#Technology https://esports.easyanticheat.net/features/ https://nakedsecurity.sophos.com/2017/03/10/how-online-gamers-use-malware-to-cheat/ https://www.google.ca/search?q=Anti-cheating+techniques+for+games&client=firefox-b&dcr=0&ei=faDGWqe7IpC6tQXqlKu4Dw&start=0&sa=N&biw=946&bih=885
  7. This is in reference to "Stable Constrained Dynamics": https://hal.inria.fr/hal-01157835/document Equation (18) / (21) I'm having trouble understanding how to build this K "geometric stiffness" term. K = (∂J^T / ∂x) λ Where J is the constraints jacobian and λ is the constraint force magnitudes. What I do know - based on its usage in (21), K should be a (3n x 3n) matrix in 3D where n is the number of particles lets say. What I'm confused about - the jacobian J is a (C x 3n) matrix where C is the number of constraints. λ is (C x 1). This doesn't seem to work out in terms of the matrix dimensions... What am I missing here? If I consider only a single constraint, then it does appear to work out in terms of the dimensions - I end up with λ being a scalar and K ultimately being (3n x 3n). However, that leads to the question of how to then build K such that it contains all of the individual constraint K's (one K for each constraint I guess)?
  8. Intention This article is intended to give a brief look into the logistics of machine learning. Do not expect to become an expert on the field just by reading this. However, I hope that the article goes into just enough detail so that it sparks your interest in learning more about AI and how it can be applied to various fields such as games. Once you finish reading the article, I recommend looking at the resources posted below. If you have any questions, feel free to message me on Twitter @adityaXharsh. How Neural Networks Work Neural networks work by using a system of receiving inputs, sending outputs, and performing self-corrections based on the difference between the output and expected output, also known as the cost. Neural networks are composed of neurons, which in turn compose layers, or collections of neurons. For example, there is an input layer and an output layer. In between the these two layers, there are layers known as hidden layers. These layers allow for more complex and nuanced behavior by the neural network. A neural network can be thought of as a multi-tier cake: the first tier of the cake represents the input, the tiers in between, or lack thereof, represent the hidden layers, and the last tier represents the output. The two mechanisms of learning are Forward Propagation and Backward Propagation. Forward Propagation uses linear algebra for calculating what the activation of each neuron of the next layer should be, and then pushing, or propagating, those values forward. Backward Propagation uses calculus to determine what values in the network need to be changed in order to bring the output closer to the expected output. Forward Propagation As can be seen from the gif above, each layer is composed of multiple neurons, and each neuron is connected to every other neuron of the following and previous layer, save for the input and output layers since they are not surrounding by layers from both sides. To put it simply, a neural network represents a collection of activations, weights, and biases. They can be defined as: Activation: A value representing how strongly a neuron is firing. Weight: How strong the connection is between two neurons. Affects how much of the activation is propagated onto the next layer. Bias: A minimum threshold for whether or not the current neuron's activation and weight should affect the next neuron's activation. Each neuron has an activation and a bias. Every connection to every neuron is represented as a weight. The activations, weights, biases, and connections can be represented using matrices. Activations are calculated using this formula: After the inner portion of the function has been computed, the resulting matrix gets pumped into a special function known as the Sigmoid Function. The sigmoid is defined as: The sigmoid function is handy since its output is locked between a range of zero and one. This process is repeated until the activations of the output neurons have been calculated. Backward Propagation The process of a neural network performing self-correction is referred to as Backward Propagation or backprop. This article will not go into detail about backprop since it can be a confusing topic. To summarize, the algorithm uses a technique in calculus known as Gradient Descent. Given a plane in an infinite number of dimensions, the direction of change that minimizes the error must be found. The goal of using gradient descent is to modify the weights and biases such that the error in the network approaches zero. Furthermore, you can find the cost, or error, of a network using this formula: Unlike forward propagation, which is done from input to output, backward propagation goes from output to input. For every activation, find the error in that neuron, how much of a role it played in the error of the output, and adjust accordingly. This technique uses concepts such as the chain rule, partial derivatives, and multi-variate calculus; therefore, it's a good idea to brush up on one's calculus skills. High Level Algorithm Initialize matrices for weights and biases for all layers to a random decimal number between -1 and 1. Propagate input through the network. Compare output with the expected output. Backwards propagate the correction back into the network. Repeat this for N number of training samples. Source Code If you're interested in looking into the guts of a neural network, check out AI Chan! It's a simple to integrate library for machine learning I wrote in C++. Feel free to learn from it and use it in your own projects. https://bitbucket.org/mrsaturnsan/aichan/ Resources http://neuralnetworksanddeeplearning.com/ https://www.youtube.com/channel/UCWN3xxRkmTPmbKwht9FuE5A
  9. I am working on a game developed using Scenekit (iOS). I am facing some strange issues with collision physics. I have added one 3D table (with a hole at its center) to the scene. I am setting physics shape of this 3D model using following code: SCNBox* tableBody = [SCNBox boxWithWidth:(5*golf.scale.x) height:(0.5*golf.scale.x) length:(9*golf.scale.x) chamferRadius:0]; table.geometry = tableBody; //table geometry //physics shape scale NSValue *shapeScale = [NSValue valueWithSCNVector3:SCNVector3Make(table.scale.x, table.scale.y, table.scale.z)]; //physics shape options NSDictionary *shapeOptions = [NSDictionary dictionaryWithObjectsAndKeys:shapeScale,SCNPhysicsShapeScaleKey,SCNPhysicsShapeTypeConcavePolyhedron,SCNPhysicsShapeTypeKey, nil]; //physics body table.physicsBody = [SCNPhysicsBody bodyWithType:SCNPhysicsBodyTypeStatic shape: [SCNPhysicsShape shapeWithNode:table options:shapeOptions]]; I am adding one 3D ball on top of this table. Issue: The Ball collides with 3D table mesh triangles and changes directions I have following questions: How can I stop collision of ball with these lines? Are there any modification to the physics can be done? I want the hole to be part of the physics shape so that the ball can fall into the hole. I would appreciate any suggestions and thoughts on this topic. Thank you.
  10. I am working on an ant simulation for my major project and I have encountered a problem. How would I implement a solution for helping a single agent find its neighbouring agents? (e.g. If my agent is standing at (x,y), find all neighbouring agents within 1 unit of distance from my agents origin). I would like an algorithmic approach so that I could apply the concept in any language. Please note that my current solution uses a list which contains all the agents in my world. For the concerned agent, I iterate through this list and determine out of all the agents, which ones are within the distance threshold. This however, is not very effective when the number of agents increases to extreme levels and I am convinced it is not very good practice to use this method. I am simply looking for ideas and advice, if anyone can offer.
  11. Hi, I'm trying to implement the radioisity normal mapping algorithm from the valve paper. I've made a shader, baked some light maps, and got the effect to work more or less. It showed some surfaces both lightmapped and normal mapped, and it looked kinda nice. This old demo is currently offline but you can see the results: I wanted to revisit the tangent stuff that made the sphere render janky, when i noticed that this never quite worked as expected. It's noticeable here when i have the flat (128,128,255) normal map and the lights seem to "diverge". I tried to visualize the math by mocking the light maps with 3 dot products between a directional light and the basis vectors. The n dot l on the yellow normal never seems to be the same as the result of sampling and weighting from the basis directions. The first image where the light is completely grazing the surface seems to illustrate well where it fails. The other two basis (green and blue) are getting a clamped 0, but 1/3 of the contribution comes from the red dir where there is some value. Baking a regular light map, this surface would be black. This cyan distribution plot looks just like the banding shape i get if i have a light close to a surface. A light cylinder intersecting a wall for example, wouldn't shine uniformly in all directions, but these dominant three. The results from the screenshots in the papers look much better. Either the weighting math needs to be adjusted somehow (i was thinking maybe scaling the normal somehow), or the lights need to have negative values or something... would be my wild guesses. Is there a way to render a regular light map and non-normal mapped geometry the same way as a radioisity normal map, with a flat (128,128,255) normal map? ^actually this plot is without the clamp for the basis/normal dot products
  12. For my simple pathtracer written in C I need a function which calculates a random, diffuse reflection vector (for diffuse / lambert material). This is my function header: struct Ray diffuse(const struct Sphere s, const struct Point hitPoint) where s is the intersected Sphere and hitPoint is the point a ray intersected the sphere. Of course there are several projectes and their source code available on GitHub but most of the time they are doing way more things than I can understand at once. I don't want to just copy their code (I want to understand it myself) and I did not get any usefull results from google. I don't know where to start.
  13. Hey guys, I'm starting to get really interested in A.I and especially machine learning. However I can't find a good place to start. I have looked on the internet for tutorials but they are all useless to begginers because they all end up thinking that you have a lot of knowledge about machine learning already and that you know what you are doing. But for me (an absolute beginner) I find it hard to understand what they are saying in the tutorials. I have tried to make my own A.I by just playing around with some maths and the basics of machine learning that I already know like neurons and weights and baias. For the most part my little mini projects work but they are not proper A.I. Could anyone please recommend me some tutorials that I could watch for begginers. My main programming language is python however I am starting to learn java and c#. I have already looked at bigNeuralNetwork's tutorial, at the beginning it was great and I understood everything but then halfway through I didn't know what was going on.
  14. Hello, me and few friends are developing simple city building game with unity for a school project, think something like Banished but much simpler. I was tasked to create the path-finding for the game so I mostly followed this tutorial series up to episode 5. Then we created simple working system for cutting trees. The problem is that the path-finding is working like 90% of the time, then it get stuck randomly then there's clearly a way to the objective (tree). I tried looking for some pattern when it happens but can't find anything. So basically I need any tips for how I should approach this problem. Use this image to visualize the problem.
  15. Hi there!I am trying to implement a basic AI for a Turrets game in SFML and C++ and I have some problems.This AI follows some waypoints stablished in a Bezier Courve. In first place, this path was followed only by one enemy. For this purpose, the enemy has to calculate his distance between his actual positionto the next waypoint he has to pick.If the distance is less than a specific value we stablish, then, we get to the next point. This will repeat until the final destination is reached. (in the submitting code, forget about the var m_go)Okay, our problem gets when we spawn several enemies and all have to follow the same path, because it produces a bad visual effect (everyone gets upside another).In order to solve this visual problem, we have decided to use a repulsion vector. The calculus gets like this: As you can see, we calculate the repulsion vector with the inverse of the distance between the enemy and his nearest neighbor.Then, we get it applying this to the "theorical" direction, by adding it, and we get a resultant, which is the direction thatour enemy has to follow to not "collide" with it's neighbors. But, our issue comes here: The enemys get sepparated in the middle of the curve and, as we spawn more enemys, the speed of all of them increases dramatically (including the enemies that don't calculate the repuslion vector).1 - Is it usual that this sepparation occours in the middle of the trajectory?2 - Is it there a way to control this direction without the speed getting affected?3 - Is it there any alternative to this theory?I submit the code below (There is a variable in Spanish [resultante] which it means resultant in English): if (!m_pathCompleted) { if (m_currentWP == 14 && m_cambio == true) { m_currentWP = 0; m_path = m_pathA; m_cambio = false; } if (m_neighbors.size() > 1) { for (int i = 0; i < m_neighbors.size(); i++) { if (m_enemyId != m_neighbors[i]->GetId()) { float l_nvx = m_neighbors[i]->GetSprite().getPosition().x - m_enemySprite.getPosition().x; float l_nvy = m_neighbors[i]->GetSprite().getPosition().y - m_enemySprite.getPosition().y; float distance = std::sqrt(l_nvx * l_nvx + l_nvy * l_nvy); if (distance < MINIMUM_NEIGHBOR_DISTANCE) { l_nvx *= -1; l_nvy *= -1; float l_vx = m_path[m_currentWP].x - m_enemySprite.getPosition().x; float l_vy = m_path[m_currentWP].y - m_enemySprite.getPosition().y; float l_resultanteX = l_nvx + l_vx; float l_resultanteY = l_nvy + l_vy; float l_waypointDistance = std::sqrt(l_resultanteX * l_resultanteX + l_resultanteY * l_resultanteY); if (l_waypointDistance < MINIMUM_WAYPOINT_DISTANCE) { if (m_currentWP == m_path.size() - 1) { std::cout << "\n"; std::cout << "[GAME OVER]" << std::endl; m_go = false; m_pathCompleted = true; } else { m_currentWP++; } } if (l_waypointDistance > MINIMUM_WAYPOINT_DISTANCE) { l_resultanteX = l_resultanteX / l_waypointDistance; l_resultanteY = l_resultanteY / l_waypointDistance; m_enemySprite.move(ENEMY_SPEED * l_resultanteX * dt, ENEMY_SPEED * l_resultanteY * dt); } } else { float vx = m_path[m_currentWP].x - m_enemySprite.getPosition().x; float vy = m_path[m_currentWP].y - m_enemySprite.getPosition().y; float len = std::sqrt(vx * vx + vy * vy); if (len < MINIMUM_WAYPOINT_DISTANCE) { if (m_currentWP == m_path.size() - 1) { std::cout << "\n"; std::cout << "[GAME OVER]" << std::endl; m_go = false; m_pathCompleted = true; } else { m_currentWP++; } } if (len > MINIMUM_WAYPOINT_DISTANCE) { vx = vx / len; vy = vy / len; m_enemySprite.move(ENEMY_SPEED * vx * dt, ENEMY_SPEED * vy * dt); } } } } } else { float vx = m_path[m_currentWP].x - m_enemySprite.getPosition().x; float vy = m_path[m_currentWP].y - m_enemySprite.getPosition().y; float len = std::sqrt(vx * vx + vy * vy); if (len < MINIMUM_WAYPOINT_DISTANCE) { if (m_currentWP == m_path.size() - 1) { std::cout << "\n"; std::cout << "[GAME OVER]" << std::endl; m_go = false; m_pathCompleted = true; } else { m_currentWP++; } } if (len > MINIMUM_WAYPOINT_DISTANCE) { vx = vx / len; vy = vy / len; m_enemySprite.move(ENEMY_SPEED * vx * dt, ENEMY_SPEED * vy * dt); } } } ¡¡Thank you very much in advance!!
  16. Hello, I am not sure if I phrased the title properly. What I am trying to achieve is the following: Winning chances: Red card: 10% Blue card: 20% Green card: 15% Nothing card: 10% Now a player has the chances above to win those cards but how would that look like in code?
  17. I'm stuck trying to make a simple ray sphere intersection test. I'm using this tutorial as my guide and taking code from there. As of now, I'm pretty sure I have the ray sorted out correctly. The way I'm testing my ray is by using the direction of the ray as the position of a cube, just to make sure it's in front of me. cube.transform.position.x = Camera.main.ray.origin.x + Camera.main.ray.direction.x * 4; cube.transform.position.y = Camera.main.ray.origin.y + Camera.main.ray.direction.y * 4; cube.transform.position.z = Camera.main.ray.origin.z + Camera.main.ray.direction.z * 4; So if I rotate the camera, the cube follows. So it's looking good. The problem occurs with the actual intersection algorithm. Here are the steps I'm taking, I'll be very brief: 1) I subtract the sphere center with the ray origin: L.x = entity.rigidbody.collider.center.x - ray.origin.x; L.y = entity.rigidbody.collider.center.y - ray.origin.y; L.z = entity.rigidbody.collider.center.z - ray.origin.z; L.normalize(); 2) I get the dot product of L and the ray direction: const b = Mathf.dot(L, ray.direction); 3) And also the dot product of L with itself (I'm not sure if I'm doing this step right): const c = Mathf.dot(L, L); 4) So now I can check if B is less than 0, which means it's behind the object. That's working very nicely. L.x = entity.rigidbody.collider.center.x - ray.origin.x; L.y = entity.rigidbody.collider.center.y - ray.origin.y; L.z = entity.rigidbody.collider.center.z - ray.origin.z; const b = Mathf.dot(L, ray.direction); const c = Mathf.dot(L, L); if (b < 0) return false; Problem starts here 5) I now do this: let d2 = (c * c) - (b * b); 6) ...and check if d2 > (entity.radius * entity.radius) and if it's greater: stop there by returning false. But it always passes, unless I don't normalize L and d2 ends up being a larger number and then it return false: const radius2 = entity.rigidbody.collider.radius * entity.rigidbody.collider.radius; if (d2 > radius2) return false; but again, since I'm normalizing, it NEVER stops in that step. Which worries me. 7) I then do this: let t1c = Math.sqrt(radius2 - d2); ...but it always returns a number in the range of 0.98, 0.97, if I'm standing still. But if I strafe left and right, the number lowers. If I rotate the camera, it makes no difference. Only if I strafe. So I'm clearly doing something wrong and stopped there. Hopefully I made sense
  18. DX11 Light Shafts

    I decided to implement light shafts using http://sirkan.iit.bme.hu/~szirmay/lightshaft_link.htm So far I've only managed to implement the shadow map. Can anyone help me to implement this in D3D11? (I mean steps, I can do the rest). I'm new to all these shadow maps and etc.
  19. Hi there! I'm currently developing a Turret Defense videogame with C++ and SFML and I'm having some trouble thinking about a feature. In this kind of games, it's commonly seen that turrets keep aiming and attacking to enemies that are into a certain range. I'm struggling to figure out how to program it. Firstly, I came across to use some basic Trigonometry figuring out (thanks to the coordinates of the enemy sprite and our turret), the angle that is needed to be aiming to the bad guy (using the sine arc). Then, I'l substract this result to the initial angle that the turret's sprite has and I think I would obtain a displacement, which I will apply to the rotate() function that SFML provides to their sprites. Anyway, I don't really know if I am right with this hypothesis or if it exists any better option to make this calculus. I tried to look up at some other videogames and I didn't find anything clear. So, I would appreciate a lot if anyone knows any better option or how to refine this first hypothesis. Thank you in advanced!
  20. Hi, I want to know what are the basics of mathematics that I should know in depth to have a good level to start programming games of better quality. Which books could you recommend me?
  21. position along a circle

    Hello all, So i want to place objects along a (half) circular line with the formula (x-a)^2 + (y-b)^2 = r^2 object pixel size are 36px. so if i have 10 objects then r would become (10.36):2 = 180. finding Y for X =0 (0 degrees)becomes sqrt(r^2 - 0^2) Y becomes 180 finding Y for X =5 (90 degrees) becomes sqrt(r^2 - (5*36)^2) Y becomes 0 this makes perfect sense... but if i do this in a for loop then the sequence for x will be (0,36,72,108,144,180) this means that the 6th object gets the 90 degrees Y value....and not the 5th. (for i= 0 etc) x = i*36... I know its probably very 'dumb'question but i just don't see it anymore Thx in advance...
  22. Divide and conquer broadphase

    Hello everyone, I just wanted to share a, what I believe to be novel, broadphase collision detection technique that I stumbled over while working on my physics engine. If anyone knows of related work, please refer me! The code will be at the end of this post, but first some discussion. Briefly, the goal of a broadphase is to determine potentially colliding pairs of objects. There exist many well known techniques such as: uniform / hierarchical grids, bounding volume hierarchies, sweep and prune, or quadtrees. They all have their respective pros and cons, which I won't go into here. One thing they all have in common however, is that they require maintaining and building a data structure which facilitates the process of finding pairs. Divide and conquer broadphase is based on the relatively new "Divide and conquer ray-tracing" technique. The idea is to recursively subdivide space, partitioning objects into these spaces, until there are sufficiently few objects in a space. When there are few enough objects, use a brute force method to find the potential pairs. The great thing about this technique is, it requires no data structures to be built and it uses a fixed amount of additional memory. In addition, the code is surprisingly simple. The code shown works in 2D. It is trivially extended to 3D or beyond by changing only the partitioning method to consider the additional dimensions. Performance analysis: Subjectively speaking, I have tested this method against many others in my own physics engine on a variety of scenes. It performs very nicely, surpassing the dBVT in many cases (especially when many objects are in motion). It rivals the speed of my current best, the uniform grid. From an analytical point of view, the best case is O(n log n) when the objects are not overlapping, and the worst case O (n^2) when all objects occupy the same space. However, in typical physics simulation scenes, objects are nicely distributed and do not overlap much (assuming the constraint solver is doing its job). O(n log n) doesn't sound that great considering BVHs achieve the same on paper. But unlike BVHs, no structure needs to be maintained or updated, which causes it to perform better in practice. Memory usage, as you will see, is minimal. The algorithm is run from scratch at the beginning of a time step. Potential optimizations: There are a few avenues for optimization. The first and most obvious being, unroll the recursion into a loop with an explicit stack in order to reduce the overhead of the recursive calls. Another is to use a more intricate partitioning method, rather than the simple one shown here. Note that I use a set to track pairs, since this method can result in duplicate pairs. The set is actually rather slow. You can easily swap this for a vector, then sort and remove duplicates at the end for a nice performance boost. There exists a parallel version of "Divide and conquer ray-tracing". I'm sure the ideas presented there could be used to parallelize this technique as well, though I have not looked into it, Lastly, one could potentially cache the partition locations, and use those as a starting point for computing the partition locations in the next frame. This exploits the temporal coherence of physics simulations. This could theoretically divide the cost of the whole process by 2, since computing the partition location is half of the work in each call. Here is my implementation (feel free to use this however you wish): #include <vector> #include <set> #include <algorithm> // Divide and conquer broadphase void dac_bp(const vector<aabb>& bounds, const vector<int>::iterator start, const vector<int>::iterator end, set<pair>& pairs) { const int BRUTE_FORCE_THRESH = 32; if ((end - start) < BRUTE_FORCE_THRESH) { // Brute force check the remaining pairs in this interval for (auto i = start; i != end; i++) { for (auto j = i + 1; j != end; j++) { if (bounds[*i].intersects(bounds[*j])) { pairs.insert(pair(*i, *j)); } } } } else { // Compute bounds of all boxes in this interval float2 pmin(FLT_MAX, FLT_MAX), pmax(-FLT_MAX, -FLT_MAX); for (auto i = start; i != end; i++) { pmin = min(pmin, bounds[*i].min); pmax = max(pmax, bounds[*i].max); } // Choose the partition axis and partition location float2 size = pmax - pmin; int axis = (size[1] > size[0]); float split = (pmin[axis] + pmax[axis]) * 0.5f; // Partition boxes left and recurse auto mid_left = partition(start, end, [split, axis, bounds](int i) { return bounds[i].min[axis] <= split; }); dac_bp(bounds, start, mid_left, pairs); // Partition boxes right and recurse auto mid_right = partition(start, end, [split, axis, bounds](int i) { return bounds[i].max[axis] >= split; }); dac_bp(bounds, start, mid_right, pairs); } } // USAGE // Build a vector containing bounds of all objects vector<aabb> bounds = { /* fill with bounds of objects */ }; // Initialize indices vector<int> indices; for (size_t i = 0; i < bounds.size(); i++) indices.push_back(i); // Get all colliding pairs! set<pair> pairs; dac_bp(bounds, indices.start(), indices.end(), pairs); Thanks for reading, and I hope someone finds this of use! If you have any further ideas for extending this, please share!
  23. algorithm challenge

    Hi, little challenge I was thinking... you have a lotto grid of N numbers. you have to pick K different numbers. order doesn't matter. my challenge : write an algorithm that generates 1 random pick combination. example with N=6 and K=3 , 1 pick would be (1,3,6) constraints : - you can call Random function only 1 time. ( this Random function can manage numbers of any size you want ) - N and K are very big - I mean, you can't iterate all the possibilities - all pick combinations must have the same chance to be generated on my side, I think I have an idea of solution, but I'm not happy with it, because it would imply some complex looping. I assume the start is to generate a random number between 1 and binomial(N,K)...
  24. So I wrote a programming language called C-Lesh to program games for my game maker Platformisis. It is a scripting language which tiles into the JavaScript game engine via a memory mapper using memory mapped I/O. Currently, I am porting the language as a standalone interpreter to be able to run on the PC and possibly other devices excluding the phone. The interpreter is being written in C++ so for those of you who are C++ fans you can see the different components implemented. Some background of the language and how to program in C-Lesh can be found here: http://www.codeloader.net/readme.html As I program this thing I will post code from different components and explain.
  25. I'm trying to duplicate vertices using std::map to be used in a vertex buffer. I don't get the correct index buffer(myInds) or vertex buffer(myVerts). I can get the index array from FBX but it differs from what I get in the following std::map code. Any help is much appreciated. struct FBXVTX { XMFLOAT3 Position; XMFLOAT2 TextureCoord; XMFLOAT3 Normal; }; std::map< FBXVTX, int > myVertsMap; std::vector<FBXVTX> myVerts; std::vector<int> myInds; HRESULT FBXLoader::Open(HWND hWnd, char* Filename, bool UsePositionOnly) { HRESULT hr = S_OK; if (FBXM) { FBXIOS = FbxIOSettings::Create(FBXM, IOSROOT); FBXM->SetIOSettings(FBXIOS); FBXI = FbxImporter::Create(FBXM, ""); if (!(FBXI->Initialize(Filename, -1, FBXIOS))) { hr = E_FAIL; MessageBox(hWnd, (wchar_t*)FBXI->GetStatus().GetErrorString(), TEXT("ALM"), MB_OK); } FBXS = FbxScene::Create(FBXM, "REALMS"); if (!FBXS) { hr = E_FAIL; MessageBox(hWnd, TEXT("Failed to create the scene"), TEXT("ALM"), MB_OK); } if (!(FBXI->Import(FBXS))) { hr = E_FAIL; MessageBox(hWnd, TEXT("Failed to import fbx file content into the scene"), TEXT("ALM"), MB_OK); } FbxAxisSystem OurAxisSystem = FbxAxisSystem::DirectX; FbxAxisSystem SceneAxisSystem = FBXS->GetGlobalSettings().GetAxisSystem(); if(SceneAxisSystem != OurAxisSystem) { FbxAxisSystem::DirectX.ConvertScene(FBXS); } FbxSystemUnit SceneSystemUnit = FBXS->GetGlobalSettings().GetSystemUnit(); if( SceneSystemUnit.GetScaleFactor() != 1.0 ) { FbxSystemUnit::cm.ConvertScene( FBXS ); } if (FBXI) FBXI->Destroy(); FbxNode* MainNode = FBXS->GetRootNode(); int NumKids = MainNode->GetChildCount(); FbxNode* ChildNode = NULL; for (int i=0; i<NumKids; i++) { ChildNode = MainNode->GetChild(i); FbxNodeAttribute* NodeAttribute = ChildNode->GetNodeAttribute(); if (NodeAttribute->GetAttributeType() == FbxNodeAttribute::eMesh) { FbxMesh* Mesh = ChildNode->GetMesh(); if (UsePositionOnly) { NumVertices = Mesh->GetControlPointsCount();//number of vertices MyV = new XMFLOAT3[NumVertices]; for (DWORD j = 0; j < NumVertices; j++) { FbxVector4 Vertex = Mesh->GetControlPointAt(j);//Gets the control point at the specified index. MyV[j] = XMFLOAT3((float)Vertex.mData[0], (float)Vertex.mData[1], (float)Vertex.mData[2]); } NumIndices = Mesh->GetPolygonVertexCount();//number of indices MyI = (DWORD*)Mesh->GetPolygonVertices();//index array } else { FbxLayerElementArrayTemplate<FbxVector2>* uvVertices = NULL; Mesh->GetTextureUV(&uvVertices); int idx = 0; for (int i = 0; i < Mesh->GetPolygonCount(); i++)//polygon(=mostly triangle) count { for (int j = 0; j < Mesh->GetPolygonSize(i); j++)//retrieves number of vertices in a polygon { FBXVTX myVert; int p_index = 3*i+j; int t_index = Mesh->GetTextureUVIndex(i, j); FbxVector4 Vertex = Mesh->GetControlPointAt(p_index);//Gets the control point at the specified index. myVert.Position = XMFLOAT3((float)Vertex.mData[0], (float)Vertex.mData[1], (float)Vertex.mData[2]); FbxVector4 Normal; Mesh->GetPolygonVertexNormal(i, j, Normal); myVert.Normal = XMFLOAT3((float)Normal.mData[0], (float)Normal.mData[1], (float)Normal.mData[2]); FbxVector2 uv = uvVertices->GetAt(t_index); myVert.TextureCoord = XMFLOAT2((float)uv.mData[0], (float)uv.mData[1]); if ( myVertsMap.find( myVert ) != myVertsMap.end() ) myInds.push_back( myVertsMap[ myVert ]); else { myVertsMap.insert( std::pair<FBXVTX, int> (myVert, idx ) ); myVerts.push_back(myVert); myInds.push_back(idx); idx++; } } } } } } } else { hr = E_FAIL; MessageBox(hWnd, TEXT("Failed to create the FBX Manager"), TEXT("ALM"), MB_OK); } return hr; } bool operator < ( const FBXVTX &lValue, const FBXVTX &rValue) { if (lValue.Position.x != rValue.Position.x) return(lValue.Position.x < rValue.Position.x); if (lValue.Position.y != rValue.Position.y) return(lValue.Position.y < rValue.Position.y); if (lValue.Position.z != rValue.Position.z) return(lValue.Position.z < rValue.Position.z); if (lValue.TextureCoord.x != rValue.TextureCoord.x) return(lValue.TextureCoord.x < rValue.TextureCoord.x); if (lValue.TextureCoord.y != rValue.TextureCoord.y) return(lValue.TextureCoord.y < rValue.TextureCoord.y); if (lValue.Normal.x != rValue.Normal.x) return(lValue.Normal.x < rValue.Normal.x); if (lValue.Normal.y != rValue.Normal.y) return(lValue.Normal.y < rValue.Normal.y); return(lValue.Normal.z < rValue.Normal.z); }
  • Advertisement