• 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 118 results

  1. Last month, I made a pretty simple dungeon generator algorithm. It's an organic brute force algorithm, in the sense that the rooms and corridors aren't carved into a grid and that it stops when an area doesn't fit in the graph. Here's the algorithm : Start from the center (0, 0) in 2D Generate a room Choose a side to extend to Attach a corridor to that side If it doesn't fit, stop the generation Attach a room at the end of the corridor If it doesn't fit, stop the generation Repeat from steps 3 to 7 until enough rooms are generated It allowed us to test out our pathfinding algorithm (A* & String pulling). Here are some pictures of the output in 2D and 3D :
  2. Hey I'm dealing with ribbons following the shape of multiple spline segments. It's straightforward to compute the direction at any point along the spline. However the ribbon also got a flat shape and I'm struggling with finding a way to compute the angle of the ribbon in the plane perpendicular to the direction. To illustrate what I mean here's a piece of code that almost worked: float3x3 rotMtxFromSpline; rotMtxFromSpline[1] = normalize(splineDir); rotMtxFromSpline[0] = normalize(cross(float3(1, 0, 0), rotMtxFromSpline[1])); rotMtxFromSpline[2] = cross(rotMtxFromSpline[0], rotMtxFromSpline[1]); // Rotate rotMtxFromSpline[0] in the rotMtxFromSpline[0]-rotMtxFromSpline[2]-plane to align with float3(0, 0, 1) dir rotMtxFromSpline[0] = normalize(dot(rotMtxFromSpline[0], float3(0, 0, 1)) * rotMtxFromSpline[0] + dot(rotMtxFromSpline[2], float3(0, 0, 1)) * rotMtxFromSpline[2]); rotMtxFromSpline[2] = cross(rotMtxFromSpline[0], rotMtxFromSpline[1]); The problem with this code is when the spline segment becomes perpendicular to (0,0,1)-dir as the orientation switch from one side to the other very easily. The approach above is kind of a global approach and I'm thinking if there's a way to append some info to each spline segment to remedy the issue. Anyhow I wanted to post this question in case anyone had a similar problem that they solved or maybe anyone know some web resource dealing with this issue? Thanks!
  3. I'm working on an endless wave-based arkanoid/space invaders style hybrid. Bricks spawn above the screen and move down line by line. You must destroy all bricks before they hit the bottom of the screen. There will be multiple types of bricks and random power-up spawns. Currently I am just using a simple Log function that takes in the current wave as a parameter. This works to increase the number of bricks spawned each wave, but I want to find a way to make this much more complicated. Here is a list of everything that should be effected by the increase in difficulty: 1. Number of bricks 2. Types of bricks (1 hit bricks, 2 hit bricks, 3 hit bricks, etc.) 3. Speed that the bricks move down the screen 4. How often power-ups spawn The biggest problem here is that I can't just increase all of these with each new wave. If I did that, it would quickly become far to difficult. What I would like is an algorithm that gives some amount of variance in the increase between all 4 of these. Say one wave we put 60% of the increase to number of bricks, 20% increase to power-up spawns, 10% to types of bricks and 10% to speed of bricks. But on the next wave those percentages are all moved around and we now have say 105% to work with so the overall difficulty has increased as well. The different types of bricks need to also change to the point where if someone has made it to a certain wave, such as wave 50 for example, there are no longer any 1 hit bricks. We now would have just 2-4 hit bricks, and if they are crazy good and make it all the way to round 100, Now it's just 3-5 hit bricks, etc. If anybody has any good ideas or suggestions on this, I'd appreciate anything you've got! Thanks!
  4. circle drawing method comparison

    Hello, I am trying to make a GeometryUtil class that has methods to draw point,line ,polygon etc. I am trying to make a method to draw circle. There are many ways to draw a circle. I have found two ways, The one way: public static void drawBresenhamCircle(PolygonSpriteBatch batch, int centerX, int centerY, int radius, ColorRGBA color) { int x = 0, y = radius; int d = 3 - 2 * radius; while (y >= x) { drawCirclePoints(batch, centerX, centerY, x, y, color); if (d <= 0) { d = d + 4 * x + 6; } else { y--; d = d + 4 * (x - y) + 10; } x++; //drawCirclePoints(batch,centerX,centerY,x,y,color); } } private static void drawCirclePoints(PolygonSpriteBatch batch, int centerX, int centerY, int x, int y, ColorRGBA color) { drawPoint(batch, centerX + x, centerY + y, color); drawPoint(batch, centerX - x, centerY + y, color); drawPoint(batch, centerX + x, centerY - y, color); drawPoint(batch, centerX - x, centerY - y, color); drawPoint(batch, centerX + y, centerY + x, color); drawPoint(batch, centerX - y, centerY + x, color); drawPoint(batch, centerX + y, centerY - x, color); drawPoint(batch, centerX - y, centerY - x, color); } The other way: public static void drawCircle(PolygonSpriteBatch target, Vector2 center, float radius, int lineWidth, int segments, int tintColorR, int tintColorG, int tintColorB, int tintColorA) { Vector2[] vertices = new Vector2[segments]; double increment = Math.PI * 2.0 / segments; double theta = 0.0; for (int i = 0; i < segments; i++) { vertices[i] = new Vector2((float) Math.cos(theta) * radius + center.x, (float) Math.sin(theta) * radius + center.y); theta += increment; } drawPolygon(target, vertices, lineWidth, segments, tintColorR, tintColorG, tintColorB, tintColorA); } In the render loop: polygonSpriteBatch.begin(); Bitmap.drawBresenhamCircle(polygonSpriteBatch,500,300,200,ColorRGBA.Blue); Bitmap.drawCircle(polygonSpriteBatch,new Vector2(500,300),200,5,50,255,0,0,255); polygonSpriteBatch.end(); I am trying to choose one of them. So I thought that I should go with the one that does not involve heavy calculations and is efficient and faster. It is said that the use of floating point numbers , trigonometric operations etc. slows down things a bit. What do you think would be the best method to use? When I compared the code by observing the time taken by the flow from start of the method to the end, it shows that the second one is faster. (I think I am doing something wrong here ). Please help! Thank you.
  5. 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.
  6. 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
  7. 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.
  8. 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]
  9. 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.
  10. 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
  11. 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)?
  12. 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
  13. 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.
  14. 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.
  15. 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
  16. 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.
  17. 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.
  18. 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.
  19. 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!!
  20. 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?
  21. 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
  22. 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.
  23. 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!
  24. 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?
  25. 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...
  • Advertisement