Authenticating users without a username or password I'm curious about what the process is for anonymously authenticating users when it comes to mobile games. There are quite a few examples out there, but the ones that immediately come to mind are Lords Mobile, Family Guy Quest for Stuff, and Clash of Clans. When you first open the game, you're assigned an account id and that id is tied to your device until you choose to register an account with a password or sign in through some SSO service. In that initial step where you're not creating a password or using SSO, how are these games making sure the requests are from both the user device that they come from? Or is it that they actually don't? I can imagine a simple setup where you're providing a key that needs to be refreshed every now and then just like you would with something like OAuth, but other than that you don't care that the user is who they say they are. After all, you're dealing with a request that already has to be validated for legality within the game rules.


Basic Connections Through Socket Server I'm designing a simple 2 player RTS with Stencyl, a program that uses blocks for coding. The current code updates lists whenever an actor moves (new X and Y), and I'd want the server to update the game state with each change to the list. However, to start off I don't even know how to set up a socket server. Stencyl has taught me the basics of logic, but I've yet to learn any programming languages. I've downloaded a Smartfox 2X socket server that I'm intending to use. Right now I'm only looking to make baby steps I want to do something to this effect "When someone connects to the server, open insert file here". How can I do this? My intention is to have this file be the game client. Is this "open file when connected" method the best way to go about this? When answering assume that I know nothing, because really, though I have done research (I know that UDP TCP for real time), implementation wise I know nothing.


reading input from multiple mice in QB64 in Windows 10? I am looking to write a non network multiplayer game for Windows 10 with QB64 that accepts input from 2 or more USB mice plugged into the system. Like a simple Pong game where additional players plug mice into a USB hub to use as game controllers. I have been googling this and found some older threads Is it possible to detect two different mice at the same time, and have their movements recorded seperately? Asked 8 years, 9 months ago How do I read input from multiple keyboards mice on one computer? Asked 7 years, 6 months ago however these are pretty old threads from before Windows 10, also they seem to be more oriented towards C or .NET. Can anyone provide some example how it might be done with QB64 under Windows 10? Thanks


How do I allow a player to build a dedicated server, but prevent them from cheating? Instead of maintaining a central server, many games allow players to build their own server, like Minecraft. But if you give them the server side program, how could you prevent them from cheating? I thought it's impossible, but Team Fortress 2 seems doing that. Usual TF2 servers are built by players. But Valve sells the items in TF2, so they must have a way to prevent server owner generating these items.


Is this specific server architecture okay for a multiplayer game? So I am making a game in Node.js HTML5. And I am really struggling to determine what an effective server architecture looks like? Right now I have a server for a multiplayer game ( I plan on making servers instanced, so up to 80 people per instance). So everybody in the instances location and health are shared. And when an attack happens, i.e. a meteor is dropped from the sky, the x value is the only data passed to the rest in the instance ( they all do the computations on their own computer locally). When you are hit, you tell the server you were hit. (can't tell the server to hit other people, only yourself, becuase otherwise it's exploitable). That's the kind of architecture I was going for, you can only tell the server about events that damage yourself. ( I don't believe these events are overridable but I will try to determine that). Do I have the right idea about how to go ahead with this server? Do you have any tips or resources? NOTE It's under MMO but servers will hopefully top off at about 80. MMO in the same sense as Realm of the Mad God. )


Revenue model for an open source multiplayer game I've had an idea for a multiplayer game, and ideally, I'd absolutely love for it to be open source. However, I also want to make a profit from it so I can make more games and maybe even have a dev team. Is it possible to keep it open source and generate revenue? One idea I've had is to charge for online multiplayer services, but then users could easily circumvent that by patching in their own servers. Is there a revenue model that can work for this kind of game project?


Simple mobile multiplayer game. TCP UDP? I'm tying to dive into multiplayer game programming. The game is quite simple, it's a 2D scroller mobile game, the player need to touch the screen in order to move 1 step and it could contain up to 4 players at max. 1 of the player could create a room for other players to join. I was thinking that I would use TCP for this and will only send packets when 1 of the player trigger an event like moving or exiting the game. Is my approach is correct? Since from what I've read, many games are created in UDP instead of TCP. In case of UDP, what is sent between the clients and the server? The position of each entity in the game at a fix time interval? I'm really new multiplayer programming. I'd appreciate if someone would share their story. Thank you.


lag compensation for slow bullets (opposing players perspective) I have figured out how the server is suppose to "rewind" for bullet collisions so that when you hit a player on your screen, the server will also say you hit them. However, when you press a key to shoot on your computer, it will take x ms until the opponent sees that you shot. by then, the moving opponent will be past the position that you fired while the sever says that they were still hit anyway. What you will see You aim and shoot at them, the bullet hits them and they take damage (this works out perfectly so far) What they will see They are moving and you shoot at them. the bullet trails behind them and misses, flying off into the distance. Yet they still take damage. How can this be fixed?


Single player game into Multiplayer game I developed a Single player game in Flash (Tic Tac Toe) and in the Multiplayer mode i will be able to do both player playing on the same system with out network. I would like to extend it and make it enable to play the Multiplayer game for two player playing it online. How i can be made give me some ideas , How test the Multiplayer game playing along with different computers(I do not have internet connection in home). How I able to change the single player game into Multiplayer game , any minor changes required or I have to change the code base completely. In which way i can make it possible.


Anti cheat How secure is the client? Let's say, theoretically, that I'm developing a first person shooter with, of course, a map with things like walls. In the client code, the player is obviously halted upon collision with these wall objects. The server, however, only receives the player's location coordinates. Without some sort of data encoding in the client, the player could easily read the network communication to the server and send false coordinates to the server, allowing them to go wherever they wanted. My question is, is there a way to encode this location message to the server before it exits the client binary such that it would be extremely difficult for someone to read? Even by someone who disassembles the code to try and break the encoding? Or do all player collisions have to be detected by the server?


How to sync a LineRenderer in a multiplayer game? After a lot of searching online, I have come here as a last resort for my problem. The question says it all. How to sync a LineRenderer? One answer I found was to use a ClientRpc. I tried it with no effect. Below is the snippet of my code, IEnumerator laserBeam() This is called through another method on the click of a button Beam GetComponent lt LineRenderer gt () Beam.SetVertexCount (2) Beam.material BeamMaterial Beam.SetWidth (0.07f, 0.07f) Beam.enabled true Beam.SetPosition (0, gameObject.transform.position) Beam.SetPosition (1, target.position) RpcDrawLines (gameObject, target.position, true) yield return new WaitForSeconds (1.0f) Beam.enabled false RpcDrawLines (gameObject, target.position, false) ClientRpc public void RpcDrawLines(GameObject start, Vector3 end, bool isOn) LineRenderer beam start.GetComponent lt LineRenderer gt () if (isOn) beam.SetVertexCount (2) beam.material BeamMaterial beam.SetWidth (0.07f, 0.07f) beam.enabled true beam.SetPosition (0, start.transform.position) beam.SetPosition (1, end) else beam.enabled false So, this is the code. Works fine on the Server but no effect in the client. I know I am doing something wrong in the client rpc. But I have no idea what it is. Any way of help would be appreciated. Thanks Note I am using UNET


How to solve "server lag" problems that break the game How do real time multiplayer games deal with latency problems (or server lag )? Imagine an online fighting game where 2 players battle head to head in real time. When a player performs an action, there'll be a short delay until that player's action appears on the opponent's computer screen. This delay causes many game breaking problems. Let's say 2 hypothetical players, Player A and Player B, are fighting against each other right now in the game, and the latency is 1 second. Player A is moving toward Player B, but then Player B places a wall (or something of the like) that stops Player A from moving toward Player B. Player A doesn t see the wall appear on his her computer screen until 1 second later, but by then Player A has already moved past where the wall was placed. In a more game breaking situation, Player B is just about to kill Player A. Right before that happens, Player A uses a special attack that instantly kills Player B. But on Player B s computer, Player B kills Player A, because it takes 1 second before Player A s special attack happens on Player B s computer. This makes it so both players die even though only Player B was supposed to die. One solution to deal with the latency issue is to implement an artificial delay so that when there s a discrepancy, one player s game is momentarily paused to wait for the other player s game state to catch up. This is not a good solution because it makes the game feel extremely laggy and unresponsive, and it also renders some reactive actions useless (like dodging) because of the artificial delay. What can be done to fix these latency problems?


Cocos2D v3 and Physics simulation on server I'm trying to develop a real time multiplayer game using Cococs2d v3. The game is basically a side scrolling racing game. I wanted to develop the client using Cococs2d for iPhone, and the server side using Java. I've read about real time networking and the difficulties I can encounter, but also how can I overcome it. The most helpful articles I read was Valve's, Glenn Fiedler's game networking article and Gabriel Gambetta's article on fast paced multiplayer games. I can attach links to those articles if anyone is interested ) I have come to the conclusion that the physics should be implemented both on the client side and the server side. Using cocos2d v3 this could be done without any problems on the client side, but how can I use the same physics simulation in my server written in Java? For example how could the server know if there's a hill the client player is climbing, or if there's an obstacle it need to collide with? The physics engine the client use is written in Objective C.. Am I missing something over here? If my question is not clear enough, please tell me and I will explain it in more details. Thanks in advance )


file write restarts Corona app I am attempting to implement an auto save feature into a mobile game. I have the following code writing to the save file function saveFunc(input) local saveData input local file io.open( "saveFile.txt", "w" ) for i,val in ipairs(saveTable) do saveData saveData.." n"..val end file write( saveData ) io.close( file ) end This writes to the file correctly. The problem is that after the function finishes, the whole app restarts. Watching the output console, it re prints the "Copyright (C)..." as if I had Relaunched the app. I know it is this specific function because if I comment out the call for this function the game continues as normal. I also tried commenting out the io.close(file) but the program still restarted. How can I write to a file and not restart the app?


Roblox script Can't get "IntValue"? I am new to Roblox scripting (Lua apparently) and was fiddling with a function that is called when one Part (dubbed the "Sender") is touched by another Part, which is actually a tool with a Part called "Handle" inside of it, and a third Part nested inside that. I have also added an IntValue to the latter to be read upon touching. The object tree looks like this Apple (Tool) L Handle (Part) L TouchInterest L Value (IntValue) L Apple (Part) L Handle to Part Strong Joint The function is called alright, and the part with the name "Handle" is correctly identified, but I cannot for the world get a hold of the IntValue using the following code function onTouch(hit) print("Sender touched by "..hit.Name) local val hit FindFirstChild("IntValue", true) if val not nil then print("Found IntValue "..val.Name) if val.Name "Cash" then Get Money For Apple print("Players "..game.Players.LocalPlayer.Name) game.Players.LocalPlayer.leaderstats.Money.value game.Players.LocalPlayer.leaderstats.Money.value val.value end else print("IntValue Not Found!") end hit Destroy() end script.Parent.Touched connect(onTouch) In other words It keeps on logging "IntValue Not Found"! I have changed the name of the IntValue to "Value" and back to "IntValue" to no avail. I have been adding clones of it to several different layers of the composite object, but no results. Any help is greatly appreciated! BTW The object is a Tool, because the player is supposed to be able to pick it up and place it on the "Sender".


how to display current time as a static value in lua pico8 Pico8 has a function time() that when called displays the current time from start of program. i.e. print(time(),0,0,14) prints time at (0,0) with colour 14 However the function doesn't stop and keeps drawing the time each frame. I'm trying to figure out how I would draw the time without it increasing changing. So If I printed this 5 seconds from the start of the program I'd want it to display 5, but not change from that 5 value. https pico 8.fandom.com wiki Time I don't know how to store a static value of this time as a variable. Although according to the wiki, assigning var time() will cause time at 0 to be stored. Another way of phrasing this is...how would I display the time of 10 seconds when the following print is triggered? So after 10 seconds "time's up" is displayed. How would I display the current time 10, as well, as a static? Maybe I don't know what the time is when the event is triggered, so how can I count using time()? function init() last time() end function update() (empty update to use game loop) end function draw() cls() if (time() last) gt 10 then print("time's up!", 44, 60, 7) end end


NLua How to implement Roblox like function security? Roblox uses Normal Identities, basicly they assign a lua block object to a certain number. They use 2 for Scripts and LocalScripts, which can only use non secured functions, while the command bar can access everything that is LocalUserSecurity and RobloxPlaceSecurity. How can I implement this type of Lua Security into NLua?


Automatically triggering standard spaceship controls to stop its motion I have been working on a 2D top down space strategy shooting game. Right now it is only in the prototyping stage (I have gotten basic movement) but now I am trying to write a function that will stop the ship based on it's velocity. This is being written in Lua, using the Love2D engine. My code is as follows (note object.dx is the x velocity, object.dy is the y velocity, object.acc is the acceleration, and object.r is the rotation in radians) function stopMoving(object, dt) local targetr math.atan2(object.dy, object.dx) if targetr object.r math.pi then local currentspeed math.sqrt(object.dx object.dx object.dy object.dy) if currentspeed 0 then object.dx object.dx object.acc dt math.cos(object.r) object.dy object.dy object.acc dt math.sin(object.r) end else if (targetr object.r) gt math.pi then object.r object.r object.turnspeed dt else object.r object.r object.turnspeed dt end end end It is implemented in the update function as if love.keyboard.isDown("backspace") then stopMoving(player, dt) end The problem is that when I am holding down backspace, it spins the player clockwise (though I am trying to have it go the direction that would be the most efficient at getting to the angle it would have to be) and then it never starts to accelerate the player in the direction opposite to it's velocity. What should I change in this code to get that to work? EDIT I'm not trying to just stop the player in place, I'm trying to get it to use it's normal commands to neutralize it's existing velocity. I also changed math.atan to math.atan2, apparently it's better. I noticed no difference when running it, though.


Efficient tile maps in Corona SDK I need to create a tile map based level system for Corona SDK that loads files created with Tiled 1 . It also needs to support user touch scrolling and zooming. I've searched the Corona forums for possible solutions but the ones they talk about don't convince me. They basically have a matrix of Sprite objects which have an image loaded and a given position. That makes scrolling and zooming a bit hard. Any better ideas? 1 http www.mapeditor.org


Love2d Failed to load tileset map I'm reading the Love2D Development book, which i think i will stop reading because is outdated and very instable, sometimes i got a lot of troubles. Backing to the question, i made a tileset map with Tiled and saved in .tmx with Base64 ( uncompressed ) then i used Advanced Tiled Loader and used the code from the book This is the main.lua file local loader require ("Advanced Tiled Loader master Loader") the path to our .tmx files and sprites loader.path "map " local map loader.load("tilemap.tmx") function love.load() love.graphics.setBackgroundColor(255, 153, 0) load the level and bind the variable map loader.path "map " local map loader.load("tilemap.tmx") end function love.draw() map draw() end When i tested the game, the result was this http i.imgur.com JM8EYrv.png The result was suposted to be like this http i.imgur.com W26XFjE.png So what it could be?


Verb Noun Parsers and Old School Visual Novels Hi I'm working on a simple old school visual novel engine in Lua. Basically I have most of the code set up besides one important feature. The Text Parser. Lets get into how words are generally structured. In the screenshot I input the command "my wish is for you to die" How would a human understand this? my noun object wish verb is connective equator similar to for connective object (for all objects of ..) you noun object to connective action similar to do die verb the computer can then parse this and understand it like this (pseudo example) my user you get current label() you "Lost Coatl" wish user command user command for all objects of "Lost Coatl" do die() end execute user command() What other ways do videogames use text parsers, what would be the simplest way for a newbie coder such as myself?


update image properties Is there a way to update the location of an image? I'm currently calling my image dynamically using itemImage display.newImage(inventory t.ID 1 ) t. being my target ID. But in order for Storyboard to properly work, I need to change its location in my code to above my function, rendering its dynamic properties useless. Is there a way to update it like you can do with .text? something along the lines of itemImage.image(inventory t.ID 1 ) itemImage.imageUpdate(inventory t.ID 1 ) etc...


Is my Lua form scene loading setup efficient? At the moment, I'm working on a small game project using LUA and the love2d framework. Using this framework, I've made my own assets (i.e. button images, form images, etc), and using these assets I've been able to make a functional application, but not yet a game. In my project, I plan on having several scenes, and I'm not quite sure whether my method for scene management switching is efficient safe to use (safe, as in minimal bugs). So the process I'm using is as follows if scene selector.active scene "splash" then if sceneSplash.loaded false then sceneSplash.link.load() sceneSplash.link.update(dt) sceneSplash.link.draw() sceneSplash.loaded true else sceneSplash.link.update(dt) end elseif scene selector.active scene "menu" then if sceneMainmenu.loaded false then sceneMainmenu.link.load() sceneMainmenu.link.update(dt) sceneMainmenu.link.draw() sceneMainmenu.loaded true else sceneMainmenu.link.update(dt) end end where scene selector is a link to the follow file Misc Vars active scene "splash" version nil Resources cre nil xp nil End Vars Global Script Indicator calls calls.active scene active scene calls.version version return calls and sceneSplash sceneMainMenu are links to lua files which act as the scenes. Each file manages its own updates, which are passed through by the main.lua found by the love.update and love.draw functions which are passed through to the forms relevant load update draw functions. I'm aiming at using about 10 forms, 3 variable files and 2 misc function files (file management encryption IO operations logging etc). So the TL DR version is is it efficient safe (safe in terms of minimal bugs) to pass through draw and update functions from main.lua to other lua script files? So far, the process works without any bugs, even when I go back to a previously accessed 'scene', so I assume the process will work 'safely' when I'm using more scenes.


Game state management (Game, Menu, Titlescreen, etc) Basically, in every single game I've made so far, I always have a variable like "current state", which can be "game", "titlescreen", "gameoverscreen", etc. And then on my Update function I have a huge if current state "game" game stuf ... else if current state "titlescreen" ... However, I don't feel like this is a professional clean way of handling states. Any ideas on how to do this in a better way? Or is this the standard way?


How to make the character dash forward in Roblox? In my game I want to make a skill in a tool to dash forward for a specific range and if the character came in contact with a humanoid during the dash, it stops right on contact and stops the other humanoid from moving temporarly too and deal damage I don't know what functions should i do and where to look for them... i figured how to use onActivate and getting the mouse through Equipped Appritiate any help and guidance


Create a game start up menu screen with Lua love 2d I just got started programming games and decided to try out love2d since I'm learning lua. I was wondering if anyone knows how I can create just a simple 2 3 button menu when you start up the game. All I want to do is make a start up menu. I have 2 files and nothing else main.lua, in which I have the game code and the level design conf.lua, in which I have the title screen code and the icon of the game I couldn't find any wiki page to help me for coding for the first time a splash screen and a overall game screen !! now i have only one screen the game screen and i want to have 3 screens 1 splash screen in wich i want to draw a image background and 3 buttons PLAY,EXIT,TITLE with coding mousepress! 2 game screen! 3 game over screen with an other background image!


How can I link to callback functions in Lua such that the callbacks will be updated when the scripts are reloaded? I'm implementing Lua scripting in my game using LuaBind, and one of the things I'm not clear on is the logistics of reloading the scripts live ingame. Currently, using the LuaBind C class luabind object, I save references to Lua callbacks directly in the classes that use them. Then I can use luabind call function using that object in order to call the Lua code from the C code. I haven't tested this yet, but my assumption is that if I reload the scripts, then all the functions will be redefined, BUT the references to the OLD functions will still exist in the form of the luabind object held by the C code. I would like to be able to swap out the old for the new without manually having to manage this for every script hook in the game. How best to change this so the process works? My first thought is to not save a reference to the function directly, but maybe save the function name instead, and grab the function by name every time we want to call it. I'm looking for better ideas!


How to divide hex grid evenly among n players? I'm making a simple hex grid based game, and I want the map to be divided evenly among the players. The map is created randomly, and I want the players to have about equal amount of cells, with relatively small areas. For example, if there's four players and 80 cells in the map, each of the players would have about 20 cells (it doesn't have to be spot on accurate). Also, each player should have no more than four adjacent cells. That is to say, when the map is generated, the biggest "chunks" cannot be more than four cells each. I know this is not always possible for two or three players (as this resembles the "coloring the map" problem), and I'm OK with doing other solutions for those (like creating maps that solve the problem instead). But, for four to eight players, how could I approach this problem?


Algorithm for a dense crowd of people who avoid the player? I want to make a game like this. When player moves other humans will move too. And other humans will push people around. Are there any algorithm for this ? How can i solve this very efficient way ? I dont want to check all objects at scene with loop. And i dont want people overlap. Video https youtu.be V5ZMicq05LQ


How can I quantify a drawn line's straightness? I'm working on a game which requires players to draw a line from a point A(x1,y1) to the other point B(x2,y2) on the screen of an Android device. I want to find how well that drawing fits to a straight line. For instance, a result of 90 would mean the drawing almost perfectly fits the line. If players draw a curved line from A to B, it should get a low score. The end points are not known in advance. How can I do this?


Is there a known most efficient version of A search algorithm? Is there a known 'most efficient' version of the A search algorithm? I know some people write papers on the most efficient way to compute common operations, has this been done for A ?


How do you map a 3D scene to a stero image pair? I'm a novice. I'm working in XNA studio with simple models. How can I turn a 3D image into two images meant for the left and right eyes respectively? Note I'm not referring to "magic eye" I'm wondering how you calculate the left and right images starting from the 3D scene info.


Generating random values, keep trying till value within bounds are generated Sorry for the strange topic name, couldn t think of a good way to describe it. I m basically trying to achieve the following I'm placing items randomly on the screen, but these items shouldn't be placed near eachother at a given distance. This is the process I have in my head right now generate a random location check if this location is not near any other objects it is near start the process over to generate a new item (till it is not near anymore) I've run into this scenario multiple times but could never think of a way to efficiently do this, while I do feel that there is a simple way to do it. Here is the implementation I have right now. I feel like I should use a while loop but I can't get my around how to do it. The code is in AS3 but that shouldn't matter. public function generatePlanetsFromXML(xml XML) void planets new Array() for (var i int 0 i lt xml.projects.project.length() i ) var planet Planet new Planet() planet.data xml.projects.project i planet.radius (Math.random() 20) 20 addChild(planet) addObject(planet) planets.push(planet) calculatePlanetLocation(planet, i) private function calculatePlanetLocation(planet Planet, i int) void var randomX int (Math.random() (worldwidth planet.width)) 20 var randomY int (Math.random() (worldheight planet.height)) 20 get a location that isn't close to another planet keep looping till the distance is higher than minimum distance for (var j int 0 j lt planets.length j ) if (i ! j) var dx int planets j .x randomX var dy int planets j .y randomY var distance int Math.sqrt((dx dx) (dy dy)) if (distance lt minPlanetDistance) trace("retry getting location..") planet.alpha 0.3 calculatePlanetLocation(planet, i) else distance is fine, planet can be placed! planet.x randomX planet.y randomY else if (i 0) first planet should always be placed planet.x randomX planet.y randomY


How to track and find entities within radius in realtime game? What is best approach to implement tracking in real time for, say, 1000 npcs? Every frame update simple a square grid (remove or insert into linked list) and every time check in square radius? I tried kd tree but its really bad in real time updates even with 100 entities I can't reach 10 FPS.


Diamond Square Algorithm How to fix horrible diamond shaped artefacts and spikes? I was attempting to follow this article explaining the implementation of a wrapping version of the diamond square algorithm. I tried running it with dimensions of 128x128 and a "feature size" of 16, like in the article, but the resultant terrain is this monstrosity I read through past questions on this topic and am aware that there can be some issues with somewhat noticeable diamond or square shaped artifacts when using this algorithm, but this is definitely beyond that. Here is my code private float GetHeightAtPoint(int x, int z) if (x lt 0) x width x if (z lt 0) z height z return fractal (x (width 1)) (z (height 1)) width private void SetHeightAtPoint(int x, int z, float value) if (x lt 0) x width x if (z lt 0) z height z fractal (x (width 1)) (z (height 1)) width value private void SquareStep(int x, int z, int size, float value) int halfSize size 2 float a GetHeightAtPoint(x halfSize, z halfSize) float b GetHeightAtPoint(x halfSize, z halfSize) float c GetHeightAtPoint(x halfSize, z halfSize) float d GetHeightAtPoint(x halfSize, z halfSize) float meanHeight (a b c d) 4.0f float adjustedHeight meanHeight value SetHeightAtPoint(x, z, adjustedHeight) private void DiamondStep(int x, int z, int size, float value) int halfSize size 2 float a GetHeightAtPoint(x halfSize, z halfSize) float b GetHeightAtPoint(x halfSize, z halfSize) float c GetHeightAtPoint(x halfSize, z halfSize) float d GetHeightAtPoint(x halfSize, z halfSize) float meanHeight (a b c d) 4.0f float adjustedHeight meanHeight value SetHeightAtPoint(x, z, adjustedHeight) private void DiamondSquare(int stepSize, float scale) int halfStep stepSize 2 for (int z halfStep z lt height halfStep z stepSize) for (int x halfStep x lt width halfStep x stepSize) SquareStep(x, z, stepSize, Random.Range( 1.0f, 1.0f) scale) for (int z 0 z lt height z stepSize) for (int x 0 x lt width x stepSize) DiamondStep(x halfStep, z, stepSize, Random.Range( 1.0f, 1.0f) scale) DiamondStep(x, z halfStep, stepSize, Random.Range( 1.0f, 1.0f) scale) Generate a fractal map using diamond square algorithm and store in fractal private void GenerateFractal(int featureSize) fractal new float width height for (int z 0 z lt height z featureSize) for (int x 0 x lt height x featureSize) SetHeightAtPoint(x, z, Random.Range(0.0f, maxHeight)) int sampleSize featureSize float randomScale 1.0f while (sampleSize gt 1) DiamondSquare(sampleSize, randomScale) sampleSize sampleSize 2 randomScale randomScale 2.0f Could anyone give me any guidance here? One thing that was a bit suspect was that I had to make slightly different wrapping array access functions in order to make this run as I was getting negative values. You can see that my functions have the if statements checking for negatives, whereas the original implementation does not. Thanks in advance


How do I optimize searching for the nearest point? For a little project of mine I'm trying to implement a space colonization algorithm in order to grow trees. The current implementation of this algorithm works fine. But I have to optimize the whole thing in order to make it generate faster. I work with 1 to 300K of random attraction points to generate one tree, and it takes a lot of time to compute and compare distances between attraction points and tree node in order to keep only the closest treenode for an attraction point. So I was wondering if some solutions exist (I know they must exist) in order to avoid the time loss looping on each tree node for each attraction point to find the closest... and so on until the tree is finished.


How do you disable frame skips in a game, in SFML preferably by frame skip off i mean that the game should just slow down if the fps drops, just like in terraria, i got this code currently and want to implement it to it static class Globals static public Time dt new Time() static public Vector2f Friction get return new Vector2f(2 dt.AsSeconds(), 0) class Player private void StartMoving(int direction) moving true direction direction heldfor 1 Move(direction) public void Move(int direction) if(!moving) StartMoving( direction) return if(direction direction) if(heldfor lt heldforlimit) heldfor Velocity new Vector2f(((speed (heldfor 10f)) direction) Globals.dt.AsSeconds(), 0) else direction direction heldfor 2 Velocity new Vector2f(Velocity.X 1.5f, Velocity.Y) if (heldfor lt heldforlimit) heldfor Velocity new Vector2f(((speed (heldfor 10f)) direction) Globals.dt.AsSeconds(), 0) public void StopMoving() moving false heldfor 1 public void Update(Time dt) if(!moving) if(Math.Abs(Velocity.X) Globals.Friction.X lt 0) Velocity.X 0 else i really should make this direction independent and apply direction at end of the update Velocity.X Velocity.X gt 0 ? Velocity.X Globals.Friction.X Velocity.X Globals.Friction.X if (Math.Abs(Velocity.X) lt velocitySnapX) Velocity.X 0 if (Math.Abs(Velocity.Y) lt velocitySnapY) Velocity.Y 0 if (Math.Abs(Velocity.X) gt XMaxvel) Velocity.X XMaxvel direction if (Math.Abs(Velocity.Y) gt YMaxvel) Velocity.Y YMaxvel direction Position Velocity class Program Player player new Player() while(game.isrunning) this is made up as the genuine code is too messy if (Keyboard.IsKeyPressed(Keyboard.Key.Right)) player.Move(1) if (Keyboard.IsKeyPressed(Keyboard.Key.Left)) player.Move( 1) window.Clear(Color.White) window.Draw(player) player.Update(Globals.dt) window.DispatchEvents() window.Display() window.SetView(mainview) Globals.dt deltaclock.Restart()


Low CPU Memory Memory bandwith Pathfinding (maybe like in Warcraft 1) Dijkstra and A are all nice and popular but what kind of algorithm was used in Warcraft 1 for pathfinding? I remember that the enemy could get trapped in bowl like caverns which means there were (most probably) no full path calculations from "start to end". If I recall correctly, the algorithm could be something like this A) Move towards enemy until success or hitting a wall B) If blocked by a wall, follow the wall until you can move towards the enemy without being blocked and then do A) But I'd like to know, if someone knows ) edit As explained to Byte56, I'm searching for a low cpu mem mem bandwidth algo and wanted to know if Warcraft had some special secrets to deliver (never seen that kind of pathfinding elsewhere), I hope that that is more concordant with the stackexchange rules.


Tile pair matching algorithm I'm trying to make a tile matching game. User can select a pair of tiles from a square grid, and if they match, both are removed from the grid. Tiles are matched if they are of the same type (many types of tiles are in the grid) AND they can be connected in the grid (either adjacent, or has a clear path of empty spaces between them in the grid) I would like to scan the grid in advance and find the currently matching pairs (desirably with the path that connects them). Thus I can give hint to users if they're stuck in finding a pair detect a situation when no more pairs can be matched (so the tiles will be reordered) Ideally during the scan each tile pair of the same type should be taken and checked for matching. Is there any algorithm technique I can use in here to obtain an optimized approach in finding the connecting paths? Also, is there anything I should take care of while initializing the grid (currently just random assignment) so as to ensure at least some tiles are adjacent in the beginning (and that I won't have to reorder them too much during the game) ?


How to place objects entities randomly in JS? I'm making a game and I have a script (running it with Node) on the server that currently just randomly places things on the map... I'd like to change that. I saw something about Perlin noise but I'm not sure if that's the thing I want and I'm even less sure how to implement it... I want something like this, green dots represent trees, red ones represent enemies and grey ones represent rocks. Where can I get a simple JS algorithm to achieve this?


Calculating the illumination level of an object In my (UE4) scene I have an object and several (point) light sources. The object can move around, getting closer and away from all those light sources. Now I need to calculate for each light source how much it affects the object at its current position (i.e. distance from the light). Every light source has three important values Intensity How bright the light shines (integer vlaue 0..10000) Attenuation Radius around light, how far it visibly influences the scene Falloff exponent Radial falloff around light (inverse squared by default, or can be an integer between 2 and 8) Now, depending on how far the object is from a light source, it is more or less affected by the light. If the object is outside the attenuation radius, it is not affected at all by the light. I am not so much interested in the light intensity, but more in the distance between the object and a light. For each light I am interested in a value between 0 and 1. So the easy way would be to simply calc 1 distance attenuation. But I would like to take the falloff exponent into account. Any ideas how to accomplish that?


Creating the nodes for path finding during run time more like path making and more I'm making my 1st game. I'm using javascript as I currently want to learn to make games without needing to learn another language but this is more of a general game dev question. It's a 2d turn based tile grid game. You can check it here http www.patinterotest.tk it creates a movable area when you hover a player and it implements the A algorithm for moving the player. The Problem I want to make the 'dynamic movable area creation' already implement a limited number of steps for a player. The Questions What is a good way to do this? Is there another algorithm to use for this? The A algorithm needs a start and destination, with what I want to do I don't have a destination Or should I just limit the iteration of the A algorithm to the steps variable?


What's the best way of transforming a 2D vector into the closest 8 way compass direction? If you have a 2D vector expressed as x and y, what's a good way of transforming that into the closest compass direction? e.g. x 1, y 1 gt NE x 0, y 3 gt N x 10, y 2 gt E closest compass direction


How can I fill the interior of a closed loop on a tile map? In my game the player can dynamically modify terrain. The map is stored within a 2D array of prefabricated 3D objects. This is working well for now. The player modifies terrain by selecting what sort of tile they'd like to create (like cliff going up or down), and then clicking individual tiles, or "painting" over multiple by holding down mouse button and scrolling. I don't want the player to have to manually click every tile they want to rise or fall in elevation. The most elegant solution I can conceive, is for the player to "paint" a loop of cliff tiles, which is then filled in automatically when the loop closes. Imagine, perhaps, someone drawing a line using MS Paint or Photoshop, until that line closes into a shape which then autofills. Let's say the player wants a plateau, and so they select cliff going up, and then click and drag the desired shape. Upon closing the loop, when the last cliff tile is created beside the first cliff tile, witchcraft is invoked which fills the inside. I have no idea how this can be done, never mind elegantly or optimally. There are obvious possible solutions (find the average vector of all tiles in the loop, and then dijkstra algorithm from the average until the space is filled with the correct elevation), but these assume the shape generated is blobby or boxy. An irregular shape where the mid point falls outside of the shape is possible and would probably ruin that solution! How can I fill the inside of a closed loop? I'd like a theoretical solution I can go away and implement in C . At this point it seems like there is probably conceptual overlap between raster graphics and procedural maps!


Reduce the number of edges of a graph, keeping it connected I'm designing a game with random generated dungeons. I'd like to view this as a connected, undirected graph in which nodes are rooms and edges are doors or corridors. Then I choose a "side" node as the dungeon entrance, I calculate the distance between this entrance and all other nodes, and decide that one of the farthest nodes is the "goal" of the dungeon (the location of the treasure, boss, princess, etc.). I saw 2 ways to generate the final dungeon topography Generate first a random graph, then try to fill the 2d world with rooms at random locations, respecting the edge connections. I figured this would be sometimes difficult because the room generation could be "locked" trying to fit rooms in impossible places. Generate first rooms, placing them randomly where they fit, then map the result to nodes and edges. I decided to try this. My idea consists in First generate a big room that would contain the whole dungeon. Put a wall inside the big room, at a random location, dividing the big room into 2 smaller rooms of different area. Then I continue to divide each room into 2, until they are too small, or the total number of room reach a maximum (or any other condition). Each new room is a node. Once finished, I check each room and find all adjacent other rooms, marking the 2 nodes as connected by an edge. That way I ensure that all rooms have a possible location in the 2D world, and are correctly mapped by a connected graph. My problem is that there are too many doors and corridors connecting the rooms. So I'd like an algorithm that reduces the number of edges of a connected undirected graph, but keeping it connected (all nodes stay reachable) in the end.


Algorithm for generating levels for shooting game I have a shooting game made in Java. It's based on time, i.e you have to shoot the objects before the time runs out. Everything is working fine, except that I'm trying to implement an algorithm to generate levels. I implemented one that increases the number of game objects and increase their speed, but I don't know how to give the player an appropriate time based on these factors to provide an appropriate challenge for the player.


Stepping from Point out on Archimedes Spiral for Length along Arc I wasn t sure whether to put this question in mathematics or programming? My question has two parts with the second part dependent on the first. I m looking to use Archimedes spirals in some game code I m writing. I figured that there is possibly a unary Archimedes spiral from which all other achimedes spirals can be derived. (Hopefully the use of unary is correct here?) That is a unary Archimedes spiral is one where the spiral spirals one radian outwards for every radian of angle starting at centre. So my first question is Is that true? Can every Archimedes spiral be derived from a unary Archimedes spiral like I ve described? By derived I mean by the use of simple multiplication and division to transform from the unary Archimedes spiral to any Achimedes spiral with a different rate of out spiral. eg. spiral20RadiansOutPerRadian unaryspiral 20 If that is the case then could someone possibly help me also with this second question? I m looking to step a measured arc length outwards (and inwards) from a point that is out on a measured Archimedes spiral. So not from the zero or centre point but from somewhere out on the spiral. The begin point out on the spiral is represented by a measured radius from zero (or centre). I m looking to find r' f(r , arclen) where r is the initial radius, arclen is the length stepping outwards along the arc (negative to step inwards) and the resultant r' is the new radius at that stepped to point. My process for deriving from the unit spiral would hopefully then be Programmer sets a value for delta radius which is per radian of angle. Programmer sets a value for start radius. Programmer sets a value for step length which is the length to step around arc. The unary step length is worked out by dividing step length by delta radius. The unary start radius is worked out by dividing start radius by delta radius. We call achimedes() function with the two unary values and it returns unary end radius. The actual end radius is worked out by multiplying unary end radius by delta radius. The delta angle is worked by subtracting unary end radius from the unary start radius. My second question is Could somebody please help me to write this achimedes() function (if the answer to question 1 is yes)? I m looking to have function be of the form unary end radius archimedes(unary start radius , unary step length) where the unary delta radius is understood to be 1 radian.


How to generate point based on a map I am making a multiplayer game in Unity, with a socket.io server in NodeJS. I am using a globe, with a texture to represent the world in Unity. Let's say something similar do this. Now, there I am stuck with some algorithm. I would like to generate equally distant point, on the lands, where user can build stuff. Something similar to this I saw this post here post and I would like to generate the map in the server, create from the generate map a mongoDB collection of point. When a user connect, he get back a list of point (that are already generated and can interact with those). I get stuck on the generation. How do I make the server generate point based on a map that I will show to client, but that the server do not have idea of ? How would I store the coordinate position, so that the server generate them, and the client no matter the scale of the map would be able to display them at the good point ? Basically, I don't know where to start to make this algorithm. I just would like some idea on how you would achieve this, so I can inspire myself to find my solution.


best way to compute vertex normals from a Triangle's list hi i'm a complete newbie in computergraphics so sorry if it's a stupid answer. i'm trying to make a simple 3d engine from scratch, more for educational purpose than for real use. for now i compute only face normals. in this way i have a Surface object with inside a Triangle's list. i compute normals inside Triangle class, in this way triangle.computeFaceNormals() Vec3D u v1.sub(v3) Vec3D v v1.sub(v2) Vec3D normal Vec3D.cross(u,v) normal.normalized() this.n1 this.n2 this.n3 normal and when building surface t new Triangle(v1,v2,v3) t.computeFaceNormals() surface.addTriangle(t) and i think this is the best way to do that.. isn't it? now.. this works, ok. but light it's not smoothed. i'm trying to compute also vertex normals. (i'm testing my engine with tubolar surfaces so i have almost all vertex shared with more then one triangles) i've found this simple algorithm flipcode vertex normal but.. hei this algorithm has.. exponential complexity? (if my memory doesn't fail my computer science background..) (bytheway.. it has 3 nested loops.. i don't think it's the best way to do it..) any suggestion?


Can you use A to make a unit move nonspecifically? A is typically used to calculate the best way to move towards something, and it's quite flexible when it comes to threats, extra movement costs, and 'refuelling' on the way to something. However, if you designate only threats, perhaps with a main threat first and foremost, can you use it for "finding somewhere to go"? What about adding both threats, safety, resources and other such heuristic influencers to determine what a unit does when idle?


Flowfield density conversion I'm trying to implement flowfield navigation, as described in http grail.cs.washington.edu projects crowd flows but I can't understand how the Density Function in Figure 4 of the paper is supposed to handle unit radius. Has anyone ever implemented that and can provide more information? This is the part in question Their algorithm seems to be using only 4 cells, pointing to the lower left of the unit, so is this some kind of kernel that needs to be applied multiple times? Thanks.


Pathfinding Search for Path of Specific Length I am creating a roguelike. This question applies to random map generation. First, I generate areas using a BSP algorithm, where I randomly divide the map into areas. Then, I generate a graph of the areas so that I can use search algorithms to generate paths through the map. It is easy to find the shortest path between two areas, but I would like to find a path with a specific number of steps(or path cost). So, my question is What is an algorithm that I can use to find a path that has a specific cost or cost range? An Example of why I think this is useful Say that I randomly choose two areas(start and end for example). These area might be next to each other, they might be on the opposite sides of the map. I want to force the player to travel through a minimum number of areas before reaching the end, let's say 5. I should be able to be like path startArea.findPathMinimumCost(endArea,5) And it will return a path of cost 5, or the shortest path, whichever has the greater cost. Thank you.


Pathfinding Algorithms I am new to game programming I currently am using unity's 2D power to remake an 2D game for sake of practice. So I am just little confuse about one thing, so far every enemy in my game was dumb(they move on predefined paths) but this enemy, alien copter, flies and follow the player wherever the player goes. My question is should I implement any pathfinding algorithm? I had studied A but I trying to figure out if A is gonna be helpful in my envoirnment because player will be moving and the enemy have to keep on looking for shortest path. I tried to write code for this AI my code was working perfect when there were no obstacles but my game has obstacles so I want something efficient so what do you people think should I implement A or any other algorithm or not?


background animation algorithm for single screen I m writing simple strategy game (in xna), and would like to have an animated background. In my game all the actions happens inside one screen and thus standard parallax effect does not look appropriate. However, I found a video of a game with suitable background animation for my game http www.youtube.com watch?v Vcxdbjulf90 amp feature share amp list PLEEF9ABAB913946E6 (from 3 to 6s, while main character stays at the same place). What is the algorithm to do this stuff? It would be nice if someone can provide a reference for a similar example (language is not important).


Multiplayer Network Game Interpolation and Frame Rate Consider the following scenario Let's say, for sake of example and simplicity, that you have an authoritative game server that sends state to its clients every 45ms. The clients are interpolating state with an interpolation delay of 100 ms. Finally, the clients are rendering a new frame every 15ms. When state is updated on the client, the client time is set from the incoming state update. Each time a frame renders, we take the render time (client time interpolation delay) and identify a previous and target state to interpolate from. To calculate the interpolation amount factor, we take the difference of the render time and previous state time and divide by the difference of the target state and previous state times var factor ((renderTime previousStateTime) (targetStateTime previousStateTime)) Problem In the example above, we are effectively displaying the same interpolated state for 3 frames before we collected the next server update and a new client (render) time is set. The rendering is mostly smooth, but there is a dash of jaggedness to it. Question Given the example above, I'd like to think that the interpolation amount factor should increase with each frame render to smooth out the movement. Should this be considered and, if so, what is the best way to achieve this given the information from above?


Implementing a color picker I'm making a paint program using applets in Java, and I want to create some sort of color palette where the colors blend into each other, similar to this However, I'm having trouble understanding the correlation between the R, G, B, values and the X, Y coordinates for both the outer circular color palette, and the inner hue selecting palette. Representation


How do I know when a player has crossed a point threshold? I m needing help figuring out logic when adding a time bonus to my game. I only want to reward the player with extra time if they level up. Currently when the player s score is less than 100 no bonus is given. If the player s score reaches 200 I want to reward the player with some bonus time. My issue is if the score is 190 and then jumps to 210, the 200 level mark is passed and the player isn't rewarded. If I turn on the logic to say if the score is between 190 and 210, it could reward the player at the 190, 200, 210 mark or skip from 180 to 220, bypassing the reward altogether. I have tinkered with the idea of setting a bool BonusFlag, but the same issue arises, when I set the flag. Can anyone help provide some logic on how to overcome this obstacle?


AI algorithm for avoiding bullets in a shoot em up game I am working on a shoot up game in XNA, it is going to be my final project in school. I was thinking of utilizing the minimax algorithm for AI agents for making tactics. However, I realized that the most important issue in such a game is to avoid bullets(fired by the player). An AI agent making tactics but no good at avoiding bullets would be useless in a shoot em up game I guess. So, I need your help about what algorithm to utilize. It's not going to be a bullet storm like game, but it's fast(thanks to XNA). I have read about using threat maps and also pathfinding algorithms but couldn't figure out which one is ideal in such a game. I mean it needs to be simple enough for a fast paced gameplay, but it should also help AI agents act intelligently.


How does A pathfinding work? I would like to understand on a fundamental level the way in which A pathfinding works. Any code or psuedo code implementations as well as visualizations would be helpful.


Best data structure to store large amount of data I am making a minecraft kind of game. In which I have 100s of objects and their crafting recipe. Now I want to store them inside the program, ie I cannot load external files. Everything must be inside class for now. In future I might be able to use databases, once the game gets more traction. All these objects will have addition properties like shootable,purchase cost,etc etc. Some also have array property like research1 unlocks object1 50 , object2 100 , research2 unlocks object1 50 . But all these objects will be constant with an exception of "locked" boolean. If I do a huge database I'll also have to search data using filters on they keys like we do on sql. Example "Give me all Researches that are unlocked and that unlocks object1" What will be the best datastructure to store them? Thanks.


How can I generate random levels like in "Square it!" game? In this game, you have a 2d field with some free squares and two colored squares which you can move but only together (they'll move only if the spot is still "free"). And you have to fill whole free space. Here is a video that demos how the game is played. How can I generate random game levels like in that game?


How can I generate Sudoku puzzles? I'm trying to make a Sudoku puzzle generator. It's a lot harder than I expected and the more I get into it, the harder it gets! My current approach is to split the problem into 2 steps Generate a complete (solved) Sudoku puzzle. Remove numbers until it's solveable and has only 1 solution. In step 1, since I'm using a brute force methods, I'm facing some run time issues. Is there an optimal way of filling in a complete Sudoku puzzle? In step 2, what kind of algorithm should I use to "puzzlize" a solved sudoku?


Control diamond square algorithm to generate islands pangea I generated a height map with the diamond square algorithm. The thing is i do not manage to create islands, this is, restrict the height other than water level range to a certain value in the center of the map. I manualy seeded a circle in the middle of the map but the rest of the map still receives heights over the water level. I dont fully understand the Perlin noise algorithm so i'd like to work with my current implementation of the diamond square algorithm which took me 3 days to interpret and code in PHP. P UPDATE I'm trying to get a gradient and its working (it's late and have to refine it, i'll try tomorrow). I tried to work with gradients but silly me, I had been clamping the affected values to a radius, giving me a circle when generating the map. The seeding option is NOT working. I may get some bigger landmass, but may be located in any sector in the map, not even close to the center. Please have in mind that the DSA generates the middle value averaging it's corners, so its not possible to seed the middle of a square. a b f c d f (a b c d) 4 random( value,value) Perhaps that's why seeding it's not working.


Matchmaking by user supplied parameters I'm looking for matchmaking algorithm for a 1 vs 1 online game. Players must not be matched by their skill level, but instead by some specific filters set by the players. Each player sends a request that specifies some set of parameters (generally, 2 4 parameters). If some parameter is specified, the player can be matched only with those who had sent this parameter with exactly the same value or those who haven't specified the parameter at all. I need this algorithm to be thread safe and preferably fast. It would be great if it worked with 3 4 or even more parameters, but even one is alright (in my case, it's a game bet). Also, I'd appreciate ideas on how to implement or improve this algorithm on my server platform ASP.NET. One more problem I'm facing is that match finding can't be executed right after the user sends request, because if another user sends a request before a previous matching is finished, they won't be matched even if they possibly could. So it seems that match finding should be started on schedule. I need help on how to optimize it and how to choose time interval for starting new match finding. P.S. I've also posted this question on stackoverflow


Algorithm for random flight of a fly I'm new to game development. What is a good algorithm to model the random flight of a fly? I've been looking at path finding algorithms, but they don't give any interesting random behaviour.


Fastest way to neutralize scale in the transform matrix? Let's assume we have 4x4 3D transformation matrix, that is the result of scale, rotation, and translation transforms. How to set its scale to (1,1,1) in the fastest way? Assume also that the matrix is represented by float 16 array. By fastest way I mean, the most performance accurate way, that will be low CPU cost.


Rectangular selection on isometric map Before we get started I checked the following questions Isometric Tile Selection with rectangular bounding boxes Isometric rendering and picking? Calculating the number of tiles shown on an isometric map lt this is exactly how I get my top left and bottom right tile, but I can't calculate what's between them I can pick tiles perfectly, I'm struggling with the automatic selection given two tiles (top left and bottom right in screen coordinates). I've attached a drawing to help you visualize As you can see it's a Diamond setup, not staggered isometric. I'm struggling with finding the orange tiles, I have the green tiles' coordinates. Btw, it's not true isometric, it's 2 1 "isometric".


What makes a path finding heuristic Monotonic vs. Non monotonic? I am currently working on an algorithm that solves a path through the maze. So far I have implemented a Manhattan and Pythagorean Heuristic. I was wondering what makes a heuristic monotonic and how would one go about making a heuristic non monotonic.


How does Half Life's covering work? Enemies in this game take cover. AFAIK HL uses some logical decisions for enemy to start searching for cover and to abandon cover, and I am able so far to find them but how does he find a cover place? I know HL has waypoints. I can only guess speculate how they find cover point. They might search for nearest waypoint which has certain properties I thought such node might have some "cover" tag but tutorials seem not to mention it so maybe it is a node which is not visible by player AND offers attack possibility (crate or edge of wall). Thank You. )


How do I avoid "too" lucky unlucky streaks in random number generation? I'm currently dealing with a multiplayer combat system where the damage dealt by the players is always multiplied by a random factor between 0.8 and 1.2. In theory, a truly random RNG may eventually yield the same number many times (see the Tetris dilemma). This could result in a match where player is always making very high damage while the other always makes very low damage. What can I do to make sure this doesn't happen? Are some RNGs better than others at avoiding repetition?


Best algorithm for different shapes maze Based off my previous question here Maze or puzzle algorithm for something similar to noodles are there specific algorithms that would be best suited to building a maze with only 1 solution for A grid made of squares. A grid made from hexagonal tiles Thanks


How could a NPC find items that appear randomly? My main question is basically What is the algorithm that CPU players use in smash bros to find items like the smash ball? I am trying to make a small ai character that will "look around" and once an item appears it will find it and walk to it. In all smash bros the cpu players are able to find items on the stage when they appear. How do they do this?


How can I tell if an object in a tile grid is surrounded? I'm making a game which uses a 10x20 matrix to store the position of the objects. I have a castle object, represented by a number in a matrix. It is randomly deployed in some cell of the matrix. I also have a wall object, represented by a different number, which the user will deploy into the matrix by clicking on cells. The idea is to surround the castle. Basically it'll look like this 0 0 0 0 0 0 0 0 1 1 1 1 1 0 0 1 0 0 2 1 0 0 1 1 0 0 1 0 0 0 1 0 0 1 0 0 1 1 1 1 1 0 0 0 0 0 0 0 0 (2 is the castle, and 1 is the wall.) How can I tell if the castle is surrounded by walls?


Best way to calculate city influence maps similar to civilisation? As the title says, imagine you want to generate the influence mask for a city, given that the map is a 2D grid rather than hex. An extra bit is that different points on the map might have different "influence absorpion" values. Some simple scenarios to make it less abstract Scenario 1 City centered at (5,2) has 10 influence All tiles have influence absorption 1 Tile at (6,2) has 9 influence, therefore within the influence of the city Tile at (7,2) has 8 influence, therefore within the influence of the city Tile at (14,2) has 1 influence, therefore within the influence of the city Tile at (15,2) has 0 influence, therefore out of the influence of the city Scenario 2 City centered at (5,2) has 10 influence All tiles have influence absorption 1, but tile at (6,2) has influence absorption 4 Tile at (6,2) has 9 influence, therefore within the influence of the city Tile at (7,2) has 5 influence, therefore within the influence of the city Tile at (11,2) has 1 influence, therefore within the influence of the city Tile at (12,2) has 0 influence, therefore out of the influence of the city It's like using dijkstra on a 2D grid with single source, multiple destinations. Any pointers for good fast algorithms are appreciated. Also, if this problem has a well known name, that'd be appreciated as well. I made the following algorithm (independently like Jon's, thanks btw, it's the intuitive solution I guess) p0 CITY COORDS Initialize all influences with 0 set CITY INFLUENCE as the new influence at p0 list p0 while list not empty p get point in list with highest influence rating pi get influence at point pa get absorption at point new i pi pa list is updated false for each valid neighbour nb nbi get neighbour's influence if new i gt nbi set new i as the new influence at nb add nb to list list is updated true if list is updated sort list with selection sort, very fast And I have the following results, which can also be helpful to understand what I'm after Influence absorption Influence mask Influence visualisation (city at the brightest spot)


algorithm for combining smaller tiles to balance the bigger ones I have a field of tiles basically each tile is a country that has some kind of sovereign. The tiles countries have different weight. For now I use some numerical value but in the future the weight will depend on tile size, produced resources and so on. So I want for those countries to make alliances if their sole weight is much lower or at least lower than a certain threshold than the weight of the neighborhood tile (each sovereign is basically a primitive AI at that stage that is able to make decision to create the alliance). Here is couple of scenarios Here are the examples for bigger maps with possible alliances So my question is is there some kind of algorithm that allows to achieve that or I have to create it myself or use training sets for AI to gain the ability to form alliances?


Pathfinding in hex grid based game I'm making a TBS using a hex grid. Player can move units from one hex to another using bridges, which will be randomly generated. I'm using cubic and axial coordinate system for my grid, it's well described in Red Blob Games' Hexagonal Grids. I don't know how to make a hex understand connection with another one and then calculate best path for units. I'm not sure how to approach the issue should I make six slots for bridges in my hex class and then calculate path or should I make movement system somehow and then use absence of bridge as a "blocker"?


How do people implement pathfinding movement? I understand how A works, but I don't understand how movement is implemented, e.g. creating a list of directions and then going through that list until every direction is empty. How does that work? EDIT Node based.


Why can't my A implementation find a path out of an open room? I tried to follow this article with the following example, but in my attempts it always ends up with a dead end. If we take G being 10 in a straight line or 14 in a diagonal, and H the distance in horizontal or vertical to the target point, then we restart this search for every tile that is the nearest one to the target point. I have this result if we take one or the other direction with 54, it ends up with a dead end. For example, if we go up from 40 to 54, then to 60, when we restart the search with G and H, it ends up with "4" (second shema) and comes back in a dead end Why does this happen and how can I solve it? I also looked at the wiki, but I did not understand the system with the colors and the code shown.


Help me to fine tune my diamond square algorithm Check this map i generated I seeded a sine wave to act as a mountain range. The lower portion of the sine wave looks fine, but the upper side is thin, the algorithm did not do its magic there (expanding with some noise the seeded values to generate wider mountain ranges and then some hills (brown and light brown)). Also, the whole continent shape is not affected by the sine wave. Ideally, it should be like a "S" as the mountain range pretends to be. I bet this is how the diamond square algorithm takes the values it uses to make the average. If not seed the center point of the map, i can not generate a continent, it just makes a pelinesque noise of random hills. Basically, i'm having some hard time trying to control the noise with seeds and toying with amplitude and randomness reduction values. I need some experienced people in world generation and noise to help me out! Thanks! (PS red dots are rivers).


Algorithm for a dense crowd of people who avoid the player? I want to make a game like this. When player moves other humans will move too. And other humans will push people around. Are there any algorithm for this ? How can i solve this very efficient way ? I dont want to check all objects at scene with loop. And i dont want people overlap. Video https youtu.be V5ZMicq05LQ


Level design algorithm pattern for Linerunner etc I am wondering how does someone make levels for a game like Linerunner or any other game that uses similar patterns? About Linerunner (game) You are a stick man running, you have to jump or crawl without hitting boxes. Google Play is very illustrative. The algorithm I am looking for How does the game engine know that if it places a box here and here and here, the user will be able to make it without hitting any of the boxes? Two possible solutions came to mind, but neither of them seem very good. Design the entire level. Create an array of small patterns the user can win in and then join the patterns to create a level. I hope someone understands what I am talking about, otherwise I am willing to explain in depth what I want to accomplish.


Algorithm to generate small tree like branches? I'd like to seed a void map with "branches" of sine waves or any other waveform. Something like Know of any algorithm? Has to be one to generate trees or something like that.


Algorithm for "healing" multiple rectangles into a smaller number of rectangles? Say I have a grid of rectangles of different shapes and colors and I want to reduce (reasonably close to optimal is fine, optimal is not necessary) the number of rectangles to represent the same layout of colors. The image above is a very simplified case and the whitespace between the rectangles is for visualization only they would actually be tightly packed. What is an approach or algorithm name (happy to google) that can help me do this?


AI parameters for Tetris like game I am building an AI to play a variation of Tetris. The rules are changed in that there are 19 different types of pieces, rotation is not allowed, and the pieces can be placed anywhere in a 10X10 grid. Also, a line is removed once it is full (all 10 cells contain some block). I was trying to figure out which parameters I might choose in order to optimise how the game is played. Some obvious parameters which I thought of a) A piece should be placed in a position where it forms the maximum number of full lines, as they can be removed in the next step. b) A piece should be placed to minimise the 'bumpiness' or roughness of the topmost surface, i.e, it should be as level as possible. c) This is arguable, but the AI should try to keep as minimum height as possible. d) The number of columns containing atleast one block should be minimised. But the AI is still not playing good enough and keeps getting stuck. I would like to know if there are some other important parameters which I may be missing?


2D Drag Racing Algorithm What algorithm can I devise for a 2D drag racing game to simulate a race? The gameplay is 2D and the camera's perspective is from the right side of the cars i.e. cars are seen from their right side in the game. This means that the cars travel in a horizontal line, from left to right till they reach the finish line. There can be many participants in the race however the algorithm must not be affected by the number of participants in a race. It must work for any and every car given the stats of that car and other race time driving info e.g. the time of a gear shift, good shift, perfect shift, over rev, etc. To rephrase my question I am just asking for an algorithm which simulates the car motion velocity along a straight line according to the stats the car has and according to the way the driver shifts up down and revs a car. A car can have many stats. Some I thought of including in the game are General stats Top speed (mph) Acceleration (can be represented by just a number) Power (bhp) Weight (lbs) Grip (can be represented by just a number) Tuning stats Nitrous duration vs. nitrous power (can be represented by just a number) Final drive (can be represented by just a number) Gear ratio for each gear (can be represented by just a number) Tire pressure (can be represented by just a number) Upgrading a part will usually vary these stats. Each participant is able to shift up or down but once the race starts acceleration is automatic. Players will be able to choose from automatic and manual acceleration in a later release for this release the acceleration is automatic. Players must only worry about gear shifting in a race. And outside a race players must worry about changing, upgrading and or tuning their cars. Also, the game is multiplayer on a single system and not on a network. That is, the kind of multiplayer we have on consoles with two controllers. No LAN WiFi networking is involved so we don't have to worry about network lags. Actually, I'm developing the game for Sifteo Cubes. If a single player plays the game we then have AI opponents. We can have any mix of human and AI players in a race as long as their number is within the capacity supported by that race. Right now I am trying to build a prototype so this must be all there is to the game. However, the game will keep evolving after the prototype. It will even keep on evolving after its release in the form of updates and sequels. Any ideas from the gamedev community to make this game better or add remove features are gladly welcome.


Is there a known most efficient version of A search algorithm? Is there a known 'most efficient' version of the A search algorithm? I know some people write papers on the most efficient way to compute common operations, has this been done for A ?


Procedural river or road generation for infinite terrain I should say paths, not roads as I'm thinking more medieval like. Also, not looking for realism. The answer I'm looking for will be to fit into the mold I describe rather than realism. I am looking for a method to generate procedural roads rivers in a curvy sort of fashion, but I'm wanting to do so for a infinite terrain type system. Just like how perlin noise generates blobs, I'm wanting to generate random length line segments (possibly infinite length). I'm aware of strategies like the suggested answer found here, however it relies on a specified start and end point to work, I don't have a specified start and end point. I'd like to be able to simply call a function using arbitrary coordinates and have it return whether the specific coordinates are part of the river road. I am not wanting to require terrain to be generated in advance. That includes a heightmap (like used for rainfall simulations or similar). I would also not want to require a start end point. Is there such an algorithm or tweak to a noise algorithm someone might know of to accomplish what I'm trying to explain? The closest I've came to so far is multi ridged fractals, if I'm using the name properly. I'm just taking the absolute value of value noise (assuming it is scaled to 1 to 1) and setting a threshold. My primary issue with this is the lines overlap way too often, are mostly circular, sometimes converge to form large lakes which is neat but undesired, and often times the thickness of the lines vary too much. Here's a picture of what I have so far in 2D, but at a very high frequency to show more detail


Enemy mathematical behavior I'm really trying to up my game in game mathematics and now I'm working on enemy movement and a bit of AI. I have an enemy with two modes attack and avoid, based on an integer avoid variable that's either 1 or 0. On avoid I want it to hover by the player, moving back and forth at a distance until it is set to avoid. On attack I want to go close at a steady pace say an x and y velocity of 12, then once it reaches a certain distance to gain speed. I have disx and disy variables that have the distance from each other for each coordinate. I also have a totDis variable with the normal a 2 b 2 c 2 formula. I'm pretty sure I'll need another variable that I'll have to change depending on the distance that effects the speed. It kinda feels like I have all the pieces to the puzzle, I just don't know how to put them together though lol. I'd like to be able to do this as mathematically as possible and I don't want anyone to give the the answer or do it for me. I was hoping if anyone could give me pointers or tips or just ideas on the directions I can go myself because I really want to have an understanding of this. I hope this is specific enough, if not I'll try to edit my question for you.


Creating a Roguelike game in C I'm trying to create a simple rogue like game in ncurses in a C program. The idea here is that, I'd parse a file like this 10X10 ds2 de2 dw5 12X12 ds3 de2 dw1 14X14 ds5 de1 dw5 10X10 ds5 de3 dw5 12X12 ds5 de2 dw5 14X14 dw2 de1 ds2 Where the first number is a door size(rows,columns), the second string being a door, where s south, w west, etc, so ds2 door south 2 down (in the y direction). Effectively, this looks like this when parsed, I have this Where (hopefully viewable), the plus signs at the end of each room, are the doors that lead to another room, so in the first room, the east door would lead to the room to the right, etc. However, this is where I'm not sure how to go about implementing my logic. I need to make it when I step on a plus sign "effectively" a door, I'd teleport the player (the sign cursor) to the correct door. Okay, great I know the locations of each doors, but how would I actually mvoe the cursor to the next room. I can't simply hard code the distance between two rooms, as that's just ineffective and would take too long. Just to clarify, what I mean about teleporting See this picture Where the user " " symbol would move to the door (in the first room), then get teleported to the second room (12x12 room). (AS seen in the next picture) (Again where the symbol is the user, moving the cursor around (w,a,s,d). So to clarify I need a way to move a cursor, between two rooms, without hardcoding the distance between rooms, unless there is an effective way to hard code the distances. Any ideas?


How to deal with objects placed in the root nodes of a quad tree? I've implemented a quad tree where points and axis aligned rectangles can be put. It works fine, except for one issue that I'll try to describe. When you put a rectangle in the tree and this rectangle collides with quadtree's node borders, than your rectangle is put in parent node of that node. It's ok! That's how it should work! Let's consider I have a small rectangle (red) laying in quadtree's center (x 0, y 0). And I would like to retrieve other rectangles near my rectangle (blue rectangles). But here's the problem, when I do that the algorithm will return all rectangles(blue green), because my rectangle collides with quad tree nodes border and is put in quadtree's root node. I don't need green rectangles and I can't allow myself to have such an overhead. How can I avoid such problem? What would be the easiest way to implement solution to this problem? The current Retrieve method recursively walks to each subnode of the node where red rectangle is positioned. I've heard about overlapping node borders solution, but I guess it won't help in case if red rect would be 3x time bigger?!


Want to play 1 of 3 tracks depending on current level I want to play a gameplay music track depending on what the current level is. E.g. 1 Play track 1 2 Play track 1 3 Play track 2 4 Play track 2 5 Play track 3 repeat... 6 Play track 1 7 Play track 1 8 Play track 2 9 Play track 2 10 Play track 3 This is what I have, but problem is track 2 will be used at level 6 when it should be track 1. public static function playGameplayMusic(waveId Int) Void var gamePlayTrackId Int if (waveId 5 0) gamePlayTrackId 3 else if (waveId 3 0 waveId 4 0) gamePlayTrackId 2 else gamePlayTrackId 1 trace('playing gameplay track ' gamePlayTrackId) SoundPlayer.playMusicByName('gameplay ' gamePlayTrackId, false) Update Went with this. Thanks for all your contributions! public static function playGameplayMusic(waveId Int) Void var gamePlayTrackId Int Math.ceil(((waveId 1) 5 1) 2) SoundPlayer.playMusicByName('gameplay ' gamePlayTrackId, false)


Need help with algorithm for generating connected bricks in Pick A Brick clone I want to make a clone of an Amiga 500 game, Pick A Brick, a 2D game where the goal is to clear a table of bricks by matching them up, following certain rules. I am getting nowhere when it comes to the algorithm for generating the layout of the bricks. I have added the rules of the game (as I remember them) below. The player wins the game by clearing all tiles before the time runs out. Tiles are cleared by clicking on a pair of them and if the following is true The tiles must be of the same type (there is only one pair of each type). There is a clear path between them (more on path in the points below). The path from a tile must always start towards an (clear) edge of the screen. The path between the tiles must be u shaped. (edit) NOTE In the video the path is not always the u shaped. I do not recall if the path shown is just a shortcut or not, but regardless, in my version I do not want to allow removing tiles "from inside out". I have done some manual testing prototyping using both outside in and inside out approaches, with variations on both. So far, nothing I have come up with has really come close. I kind of dislike asking a question like this since it is so specific, probably not of general interest and may take up more than a little time for anyone interested in helping out. That being said, some people enjoy coming up with algorithms and "solving stuff", and the community may learn something from the answer, so, a post it is. (edit) Clarification. The algorithm must provide a solvable solution.


What algorithm can I use to detect simple shapes in a 4x4 matrix? I'm working on a simple multiplayer game that receives a random 4x4 matrix from a server and extracts a shape from it. For example XXOO OXOO XXOX XXOO XOOX and XOOO XXXX OXXX So in the first matrix the shape I want to parse is oo o oo and the 2nd oo oo ooo I know there must be an algorithm for this because I saw this kind of behavior on some puzzle games but I have no idea how to go about to detecting them or even where to start. So my question is How do I detect what shape is in the matrix and how do I differentiate between multiple colors? (it doesn't come only in X and O, it comes in a maximum of 4). Additionally, the shape must be a minimum of 4 blocks.


How can I generate random levels like in "Square it!" game? In this game, you have a 2d field with some free squares and two colored squares which you can move but only together (they'll move only if the spot is still "free"). And you have to fill whole free space. Here is a video that demos how the game is played. How can I generate random game levels like in that game?


Are hard coded "rooms" better than dynamically generated on a smart phone, from performance point of view This question pertains to a type of platform maze game (made with Unity 5) for typical smartphones (iOS Android). This game has following characteristics 1. an upper limit (about 100) on the amount of rooms 2. 3 5 different "levels", each with a different amount of rooms 3. the shape and type of the "ground" in each room is dynamically generated 4. each room has some items that are dynamically placed in the room but are generated from a prefab A rough idea on the rooms in this game is given in below screen shot. In that image only the platforms (black and white tiles) and the ground (light brown) would be shaped by an algorithm. The other objects shown in the image are prefabs that would be located somewhere in the room by an algorithm. But considering that this game would not exactly be an infinite runner, and since it should run on smart phones, would it be better from performance perspective, to create 100 hard coded rooms instead?


"Solve" a game algorithmically creating bots (and making them smart) EDIT at first I gave a lot of context for this question, explaining why I wanted to create a bot. I'm sorry it distracted people from my "actual" question. My question is pretty simple how does one create a bot for a game ? (Especially... on a mac, if it's possible though I can use a Linux virtual machine if needed). Is it interfaced with the application, or just "watching" the screen and extracting information from it (as if it was taking pictures and analyzing them to get informations such as your HP, your position, etc.) ? Could I use python to code it, or are there specific languages ? The forementioned context Since I started programming, I've wanted to try to create algorithms that would be able to "play" (or even "beat") video games. Many games require only logical choices, more and more complex as the difficulty grows, which seems perfect for algorithms. I currently enjoy the game "Pixel Dungeon" a lot (see here), but it's not always nice to you (and you die. A lot.). A few researches on the internet show that a lot can be achieved just by following simple guidelines. So I figured maybe this would be a good game to try and create bots to play it. In the long term, I would like to let bots play, extract data out of it, and modify my algorithms according to these data. I am really enthusiast about this, but also really novice. (maybe this belongs more to https stackoverflow.com ?)


What are your favourite game specific coding gems? I'll start off with John Carmack's the Fast Inverse Square Root in Quake III float Q rsqrt(float number) long i float x2, y const float threehalfs 1.5F x2 number 0.5F y number i ( long ) amp y i 0x5f3759df ( i gt gt 1 ) y ( float ) amp i y y ( threehalfs ( x2 y y ) ) return y


Flowfield density conversion I'm trying to implement flowfield navigation, as described in http grail.cs.washington.edu projects crowd flows but I can't understand how the Density Function in Figure 4 of the paper is supposed to handle unit radius. Has anyone ever implemented that and can provide more information? This is the part in question Their algorithm seems to be using only 4 cells, pointing to the lower left of the unit, so is this some kind of kernel that needs to be applied multiple times? Thanks.


How could I improve this random map? following my previous post on random world map generation, I used several algorithms and obtained results similar to this http i.imgur.com CKL2R.png (the height values are quantisied for viewing but they go from 1 to 500 before quantisation). Now I am trying to improve the "lakes", as you can see, the water bodies that are inside the map are always at 0 altitude, which means that every lake would be at the ocean level. I am willing to keep these "ocean level lakes" (or remove them), but I would like suggestion on how to create from this heightmap real lakes that would be possibly at any height, while keeping most of the altitude structure (ie mountains positions, etc) thanks


How do you map a 3D scene to a stero image pair? I'm a novice. I'm working in XNA studio with simple models. How can I turn a 3D image into two images meant for the left and right eyes respectively? Note I'm not referring to "magic eye" I'm wondering how you calculate the left and right images starting from the 3D scene info.


Real Time Dynamic Pathfinding? I'm currently doing some pathfinding research and my simulation is the following I have a 3d scene with a start and end point represented, I'm capable of creating navigational meshes, waypoints and polygons to aid with pathfinding. I've tried an A algorithm and some of its variants and they work perfectly. However, now I'm more interested in 'dynamic' pathfinding. For example, while finding a path from point A to point B, if a new obstacle suddenly appears, i want my algorithm to immediately be able to re plan a path and not start searching from scratch again. I've done some reading on the D algorithm and wondering if this would be appropriate for what I need or would this seem like an overkill. So my questions basically are What algorithm would be best for Real Time Dynamic Pathfinding? OR what combination of techniques could I use instead?


C XNA Effecient mesh building algorithm for voxel based terrain ("top" outside layer only, non destructible) To put this bluntly, for non destructible non constructible voxel style terrain, are generated meshes handled much better than instancing? Is there another method to achieve millions of visible quad faces per scene with ease? If generated meshes per chunk is the way to go, what kind of algorithm might I want to use based on only EVER needing the outer layer rendered? I'm using 3D Perlin Noise for terrain generation (for overhangs caves etc). The layout is fantastic, but even for around 20k visible faces, it's quite slow using instancing (whether it's one big draw call or multiple smaller chunks). I've simplified it to the point of removing non visible cubes and only having the top faces of my cube like terrain be rendered, but with 20k quad instances, it's still pretty sluggish (30fps on my machine). My goal is for the world to be made using quite small cubes. Where multiple games (IE Minecraft) have the player 1x1 cube in width length and 2 high, I'm shooting for 6x6 width length and 9 high. With a lot of advantages as far as gameplay goes, it also means I could quite easily have a single scene with millions of truly visible quads. So, I have been trying to look into changing my method from instancing to mesh generation on a chunk by chunk basis. Do video cards handle this type of processing better than separate quads cubes through instancing? What kind of existing algorithms should I be looking into? I've seen references to marching cubes a few times now, but I haven't spent much time investigating it since I don't know if it's the better route for my situation or not. I'm also starting to doubt my need of using 3D Perlin noise for terrain generation since I won't want the kind of depth it would seem best at. I just like the idea of overhangs and occasional cave like structures, but could find no better 'surface only' algorithms to cover that. If anyone has any better suggestions there, feel free to throw them at me too. Thanks, Mythics


Pathfinding with inertia I'm currently working for pathfinding for a game where units are moving, but they have inertia. Most typical pathfinding algorithms (A , Djikastra, etc.) are simply designed to minimize the length of the path. However, these techniques do not apply, as far as I know, to instances where the unit has inertia. If the unit has inertia, then there is a significant difference in the cost to leave a tile in a particular direction based on the direction you want to go. For example, the cost of leaving a tile proceeding North is significantly higher if you entered the tile from the East than if you entered from the South. (In the former example, you would have to slow down to halt you East West velocity, while in the latter, you could go straight through.) The fact that the system has inertia means that in order to make a turn, you may have to slow down well in advance of making the turn. My best thought to date is that you calculate the additional time it would take to slow down, and then add it to the heuristic cost of moving. However, this would seem to imply that you could never add a tile to the closed list, as entering from another direction could fundamentally change the cost of moving. In addition, the concept of using a grid is an abstraction anyway, because both position and velocity are floating point concepts. Is there some algorithm that could handle pathfinding on an open plane with inertia better than A , or what modifications could I make to a pre existing algorithm to make it suitable to this kind of motion?


Can you use A to make a unit move nonspecifically? A is typically used to calculate the best way to move towards something, and it's quite flexible when it comes to threats, extra movement costs, and 'refuelling' on the way to something. However, if you designate only threats, perhaps with a main threat first and foremost, can you use it for "finding somewhere to go"? What about adding both threats, safety, resources and other such heuristic influencers to determine what a unit does when idle?


Creating the nodes for path finding during run time more like path making and more I'm making my 1st game. I'm using javascript as I currently want to learn to make games without needing to learn another language but this is more of a general game dev question. It's a 2d turn based tile grid game. You can check it here http www.patinterotest.tk it creates a movable area when you hover a player and it implements the A algorithm for moving the player. The Problem I want to make the 'dynamic movable area creation' already implement a limited number of steps for a player. The Questions What is a good way to do this? Is there another algorithm to use for this? The A algorithm needs a start and destination, with what I want to do I don't have a destination Or should I just limit the iteration of the A algorithm to the steps variable?


How does A pathfinding work? I would like to understand on a fundamental level the way in which A pathfinding works. Any code or psuedo code implementations as well as visualizations would be helpful.


Spell casting How to optimize damage per second Imagine we have a wizard that knows a few spells. Each spell has 3 attributes Damage, cool down time, and a cast time. Pretty standard RPG stuff. Cooldown time the amount of time (t) it takes before being able to cast that spell again. A spell goes on "cooldown" the moment it begins casting. Cast time the amount of time (t) it takes to use a spell. While the wizard is casting something another spell cannot be cast and it cannot be canceled. The question is How would you maximize damage given different sets of spells? It is easy to calculate the highest damage per cast time. But what about in situations where it is better to wait then to get "stuck" casting a low damage spell when a much higher one is available? For example, Fireball 3000 damage, 3 second cast time, 6 second cool down. Frostbolt 20 damage, 4 second cast time, 4 second cool down. Fireblast 3 damage, 3 second cast time, 3 second cool down. In this case your damage per second is higher if you chose to go for the lower DPCT spell (fireblast) instead of the frostbolt. So we must consider consequences of choosing a spell. In the following example are cases of "over casting" and "waiting".


Tennis game algorithm and maths Tennis courts are real dimensions and game is 3D Ball has position (x,y,z), speed(vx,vy,vz) and acceleration (ax,ay,az) Game has 30 fps and on each update (1 30sec) it has these properties vx ax vy ay vz az ball.x vx ball.y vy ball.z vz function hitBall(destinationx, destinationy 0, destinationz) calculate vx, vy, vz, so ball imapcts the point (destinationX, 0, destinationZ) destinationY 0 bounce on floor vx .... vy .... vz .... I guess this problem has infinite solution, so we must intersect with 1 point intersection line is (x,1,12) 12 is middle of the tennis court and 1 is 1 metter above the ground. ball passes there 1 meter above the ground. Any clue on how to resolve that math problem ? regards Google doc https docs.google.com presentation d 1EiUYpalDXlJUgjg8aIxLiWENgZJW7fnH4bGHsj1jb9I edit?usp sharing


Calculate 8 different directional input based on arrow keys combinations Considering I have four variables event binded to each arrow key, that can be 0 or 1 My current approach to this issue is simply 8 nested ifs checking each combination or keys Is there a more math y clever way to solve this issue?


Raycast algorithm fails to collide with diagonal walls in specific locations I'm having a problem with my ray cast algorithm in a 2D tile based universe. I feel the situation would be best explained with a picture, so here it is The ray, represented by the blue line, is passing "through" the wall to hit its target when the wall passes through a point where the quantized line moves diagonally and the wall is perpendicular to it. The raycast function is as such def raycast(pos, direction, level) dx, dy direction t 0 x, y pos obj None while not obj and t lt 5000 t 1 x dx y dy obj level.get at((round(x),round(y)),True) pass return obj Is there a simple, efficient way to eliminate this kind of edge case?


How to implement A.I. for checkers draughts? I saw this checkers game and I wondered how the A.I. was implemented. How should I implement an A.I. for checkers (draughts, dama, dame)? Are there any known algorithms? Very thnaks full to all. I m very wonder to see this Tic Tac Toe game tutorial blog post. So, i want dama game algorithm open source code and blog post.. Is there any helpful link or any doc file..? please let me know..


MiniMax strategy What is the context of the numbers? I've watched a new videos about the MiniMax concept and invariably the lecturer will say that the computer has 2 parties, Min and Max Min always takes lower number and Max takes higher number. The problem I have is this. I'm finding it hard to understand why Min takes the lower number at all or why Max takes the higher number at all? What is the reasoning and context for these numbers? I mean, logically I know that 7 is higher than 3 but that doesn't mean anything by itself. What is the context of the numbers? Many thanks