Search the Community

Showing results for tags 'Algorithm'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Categories

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

Categories

  • News

Categories

  • Audio
  • Visual Arts
  • Programming
  • Writing

Categories

  • Audio Jobs
  • Business Jobs
  • Game Design Jobs
  • Programming Jobs
  • Visual Arts Jobs

Categories

  • GameDev Unboxed

Forums

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

Calendars

  • Community Calendar
  • Games Industry Events
  • Game Jams

Blogs

There are no results to display.

There are no results to display.

Marker Groups

  • Members

Group


About Me


Website


Industry Role


Twitter


Github


Twitch


Steam

Found 53 results

  1. I am working on a game in which we control a rectangular box at the bottom of the screen. Three sphere which has alphabets in it fall down. When the game starts, a word is generated from the predefined list of words(which I'll give) and we are supposed to touch the correct sphere having the alphabet based on that word. The question is how to detect if I have touched the correct sphere. secondly, if I have touched a correct sphere before and there is no recurrence of that alphabet in that word then during the second wave the game should not proceed if I touch the same alphabet again. Looking forward to your answers, i have to submit this project in a couple of days. please help! (Working on Unity 3D) Thanks
  2. Hi there everyone! I'm trying to implement SPH using CPU single core. I'm having troubles in making it stable. I'd like some help in order to understand what is wrong and how could I fix it. Please, take a look at the following videos: Water inside sphere using Kelager's parameters Water inside big box Water inside thinner box I've already tried using XSPH, the hash method to find the neighbors (now I'm using the regular grid, because the hash method didn't work for me) and two different ways of calculating the pressure force. I'm using mostly the following articles: Particle-Based Fluid Simulation for Interactive Applications, Matthias Müller, David Charypar and Markus Gross Lagrangian Fluid Dynamics Using Smoothed Particle Hydrodynamics, Micky Kelager Smoothed Particle Hydrodynamics Real-Time Fluid Simulation Approach, David Staubach Fluid Simulation using Smoothed Particle Hydrodynamics, Burak Ertekin 3D Langrangian Fluid Solver using SPH approximations, Chris Priscott Any ideas? Thanks!
  3. Surely, VB.net and C# (in Visual Studio express and other editions) Bitmaps were creatable from its GDI+ methods.(ex. Dim b as bitmap = new bitmap(image)) But not supported programming-based procedural generated bitmaps, only bitmaps from bitmap-files or its (related) objects or classes supported. Now, this article describes about algorithm-based generated bitmaps in VB.net/C# using both built-in GDI+ methods and external Windows APIs. so-called "binary" bitmaps created from the Createbitmap API. But its usage was not simple, pretty difficult. Then I show up samples in source codes below. 1.form(an app-window) initialization (on this app, form.size fixed in 1600*900) Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Me.Load bmp = New Bitmap(1601, 865, Imaging.PixelFormat.Format32bppRgb) 'screen resolutions in 1600*864 Sm = "Scene 1" : At = 1 : g = Me.CreateGraphics: BmphDC = g.GetHdc : MainhDC = CreateCompatibleDC(BmphDC) Me.Top = 0 : Me.Left = 0 : SetTextColor(MainhDC, &H32A77400) : SetBkColor(MainhDC, 0) : SetBkMode(MainhDC, 1) Dim f As New Font(New FontFamily("Times New Roman"), 14, FontStyle.Regular, GraphicsUnit.Pixel, 1, False) : SelectObject(MainhDC, f.ToHfont) End Sub mixed .net objects/methods and windows APIs up. those codes were working correctly as it is... Then cleanups. Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) DeleteDC(MainhDC) : g.ReleaseHdc(BmphDC) : End End Sub 2.binding binary values to bitmap Public Function LenB(ByVal stTarget As String) As Integer Return System.Text.Encoding.GetEncoding(932).GetByteCount(stTarget) End Function Private Sub RefreshScenes() ' Create a new bitmap and Lock the bitmap's bits. Dim rect As New Rectangle(0, 0, bmp.Width, bmp.Height) Dim bmpData As System.Drawing.Imaging.BitmapData = bmp.LockBits(rect, Drawing.Imaging.ImageLockMode.WriteOnly, bmp.PixelFormat) Dim ptr As IntPtr = bmpData.Scan0 ' Get the address of the first line. ' Declare an array to hold the bytes of the bitmap.This code is specific to a bitmap with 32 bits per pixels. Dim bytes As Integer = Math.Abs(bmpData.Stride) * bmp.Height ':Dim rgbValues(bytes - 1) As Byte ' Copy the RGB values back to the bitmap System.Runtime.InteropServices.Marshal.Copy(rgbValues, 0, ptr, bytes) bmp.UnlockBits(bmpData) ' Unlock the bits. bmpHandle = bmp.GetHbitmap : SelectObject(MainhDC, bmpHandle) 'TextOut(MainhDC, 637, 10, "A Single Textout Line called like this", 19) For Iu As Integer = 0 To 9 If Not DispMsgShown(Iu) = "" Then Dim RenCache As Integer = LenB(DispMsgShown(Iu)) TextOut(MainhDC, 27, 21 + (Iu * 22), DispMsgShown(Iu), RenCache) End If Next Iu : BitBlt(BmphDC, 0, 0, 1601, 865, MainhDC, 0, 0, SRCCOPY) : DeleteObject(bmpHandle) End Sub 3.texts to be used in overlays Private Sub StrLoader() Select Case At Case 1 DispMsgShown(0) = "textout sample..." DispMsgShown(1) = "at the same time using bitblt and textout..." DispMsgShown(2) = "likely this way to code." DispMsgShown(3) = " " DispMsgShown(4) = "coffee-drinking is relaxing us" DispMsgShown(5) = "" DispMsgShown(6) = "" DispMsgShown(7) = "yoga included the same affects " DispMsgShown(8) = "" Case 2 DispMsgShown(0) = "A" DispMsgShown(1) = "B" DispMsgShown(2) = "C" DispMsgShown(3) = "D" DispMsgShown(4) = "E" DispMsgShown(5) = "F" DispMsgShown(6) = "G" DispMsgShown(7) = "H" DispMsgShown(8) = "I" DispMsgShown(9) = "JKLMNOPQRSTUVWXYZ...thanks!" End Select End Sub 4. Procedual generation samples using above and a timer component Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick Cur += 1 : Randomize() Dim RRInt As Integer = Int(Math.Sqrt(Cur * 410)), Sr As New System.Random Dim X2, Y2 As Integer, Iu As Integer Select Case Sm Case "Scene 1" Select Case At Case 1 For Iu2 As Integer = 0 To 13 For Iu = 0 To Math.Sqrt(Cur * 173) + 37 retry: X2 = -Int(RRInt * 1.5) + Sr.Next(RRInt * 3) : Y2 = -RRInt + Sr.Next(RRInt * 2) If Y2 < 0 And Y2 ^ 3 + X2 ^ 2 < RRInt * 40 Then GoTo Retry Pset1(800 + X2, 510 + Y2, Math.Min(255, Sr.Next(RRInt)), Math.Min(255, Sr.Next(RRInt)), Math.Min(255, Sr.Next(RRInt))) Next Iu Next Iu2 Math.DivRem((Cur - 1) * 5, 460, SecCur) For Iu2 As Integer = 0 To 4 'If Cur < 460 Then For Iu = 0 To Math.Sqrt(SecCur) + 14 Pset3(1140 + SecCur + Iu2, 10 + Iu, 40, 60, 70, , , Math.Sqrt(SecCur * 7) + Iu * 2) Pset3(1140 + SecCur + Iu2, 44 + Iu, 40, 60, 70, , Math.Sqrt(SecCur * 7) + Iu * 2) Pset3(1140 - SecCur - Iu2, 74 - Iu, 40, 60, 70, Math.Sqrt(SecCur * 7) + Iu * 2) Pset3(1140 - SecCur - Iu2, 40 - Iu, 40, 60, 70, , Math.Sqrt(SecCur * 4) + Iu, Math.Sqrt(SecCur * 4) + Iu) Next Iu ':End If Next Iu2 Case 2 Dim SecCur As Integer If Cur < 2100 Then For Iu2 As Integer = 0 To 780 'Pset1(1600 - Cur, 120 + Int(Math.Sqrt(Cur)), 60, 240, 140) Pset1(1600 - Cur * 2 + Iu2 * 4, 120 + Int(Math.Sqrt(Cur * 3)) + Iu2, 60 - Int(Math.Sqrt(Iu2)), 240 - Int(Math.Sqrt(Iu2)) * 3, 140 + Int(Math.Sqrt(Iu2)) * 2) Pset1(1600 - Cur * 2 - 1 + Iu2 * 4, 120 + Int(Math.Sqrt(Cur * 3)) + Iu2, 60 - Int(Math.Sqrt(Iu2)), 240 - Int(Math.Sqrt(Iu2)) * 3, 140 + Int(Math.Sqrt(Iu2)) * 2) Next Iu2 Else SecCur = Cur - 2100 For Iu2 As Integer = 0 To 780 'Pset1(1600 - Cur, 120 + Int(Math.Sqrt(Cur)), 60, 240, 140) Pset1(1600 - SecCur * 2 + Iu2 * 4, 120 + Int(Math.Sqrt(SecCur * 3)) + Iu2, 160, 240 - Int(Math.Sqrt(Iu2)), 160 + Int(Math.Sqrt(Iu2))) Pset1(1600 - SecCur * 2 - 1 + Iu2 * 4, 120 + Int(Math.Sqrt(SecCur * 3)) + Iu2, 160, 240 - Int(Math.Sqrt(Iu2)), 160 + Int(Math.Sqrt(Iu2))) Next Iu2 End If End Select End Select : StrLoader():RefreshScenes() End Sub If you hope to add more scenes, one solution is increasing "case" statement . Surely In a large project, external package files required I think. 5.Header declarations within Windows APIs and module-common values Private Declare Function ReleaseDC Lib "user32.dll" (ByVal hwnd As IntPtr, ByVal hdc As IntPtr) As Long Private Declare Function SelectObject Lib "gdi32.dll" (ByVal hdc As IntPtr, ByVal hObject As IntPtr) As IntPtr Private Declare Function DeleteObject Lib "gdi32.dll" (ByVal hObject As IntPtr) As Boolean Private Declare Function CreateCompatibleDC Lib "gdi32.dll" (ByVal hdc As IntPtr) As IntPtr Private Declare Function GetWindowDC Lib "user32.dll" (ByVal hWnd As IntPtr) As IntPtr Private Declare Function GetDC Lib "user32.dll" (ByVal hwnd As IntPtr) As IntPtr Private Declare Function DeleteDC Lib "gdi32.dll" (ByVal hDC As IntPtr) As Boolean Private Declare Function SetTextColor Lib "gdi32.dll" (ByVal hDC As IntPtr, ByVal crColor As Integer) As Boolean Private Declare Function SetBkColor Lib "gdi32.dll" (ByVal hDC As IntPtr, ByVal crColor As Integer) As Boolean Private Declare Auto Function BitBlt Lib "gdi32.dll" (ByVal hdcDest As IntPtr, ByVal nXDest As Integer, ByVal nYDest As Integer, ByVal nWidth As Integer, _ ByVal nHeight As Integer, ByVal hdcSrc As IntPtr, ByVal nXSrc As Integer, ByVal nYSrc As Integer, ByVal dwRop As System.Int32) As Boolean Private Declare Function TextOut Lib "gdi32" Alias "TextOutA" (ByVal hdc As IntPtr, ByVal x As Integer, ByVal y As Integer, ByVal lpString As String, ByVal nCount As Integer) As Boolean Private Declare Function SetBkMode Lib "gdi32" (ByVal hdc As IntPtr, ByVal iBkMode As Integer) As Boolean Private Const SRCCOPY As Integer = &HCC0020 Private Sm As String, At As Integer, Cur As Integer, Bm As Bitmap, rgbValues(5539459) As Byte Private g As Graphics, Iu As Integer, SecCur As Integer, bmp As Bitmap, bmpHandle As IntPtr Private MainhDC, BmphDC As IntPtr, DispMsgShown(9) As String Private Stride_Value As Integer = 6404 'stride values related in bitmap's X-width 6.methods in pixel painting (compatible only this application) Private Sub Pset1(ByVal XPos As Integer, ByVal YPos As Integer, ByVal RedValue As Byte, ByVal GreenValue As Byte, ByVal BlueValue As Byte) If YPos > 864 Then YPos = 864 If YPos < 0 Then YPos = 0 If XPos > 1600 Then XPos = 1600 If XPos < 0 Then XPos = 0 Dim AddressOfBinaryIndex As Integer = XPos * 4 + YPos * 6404 rgbValues(AddressOfBinaryIndex) = Math.Max(rgbValues(AddressOfBinaryIndex), BlueValue) rgbValues(AddressOfBinaryIndex + 1) = Math.Max(rgbValues(AddressOfBinaryIndex + 1), GreenValue) rgbValues(AddressOfBinaryIndex + 2) = Math.Max(rgbValues(AddressOfBinaryIndex + 2), RedValue) End Sub Private Sub Pset3(ByVal XPos As Integer, ByVal YPos As Integer, ByVal RedValue As Byte, ByVal GreenValue As Byte, ByVal BlueValue As Byte, Optional ByVal AdditionalRedValue As Byte = 0, Optional ByVal AdditionalGreenValue As Byte = 0, Optional ByVal AdditionalBlueValue As Byte = 0) If YPos > 864 Then YPos = 864 If YPos < 0 Then YPos = 0 If XPos > 1600 Then XPos = 1600 If XPos < 0 Then XPos = 0 RedValue = Math.Min(255, AdditionalRedValue + RedValue) : GreenValue = Math.Min(255, AdditionalGreenValue + GreenValue) : BlueValue = Math.Min(255, AdditionalBlueValue + BlueValue) Dim AddressOfBinaryIndex As Integer = XPos * 4 + YPos * 6404 : rgbValues(AddressOfBinaryIndex) = Math.Min(255, BlueValue) rgbValues(AddressOfBinaryIndex + 1) = Math.Min(255, GreenValue) : rgbValues(AddressOfBinaryIndex + 2) = Math.Min(255, RedValue) End Sub Private Sub Pset2(ByVal XPos As Integer, ByVal YPos As Integer, ByVal RedValue As Byte, ByVal GreenValue As Byte, ByVal BlueValue As Byte, Optional ByVal AdditionalRedValue As Byte = 0, Optional ByVal AdditionalGreenValue As Byte = 0, Optional ByVal AdditionalBlueValue As Byte = 0) If YPos > 864 Then YPos = 864 If YPos < 0 Then YPos = 0 If XPos > 1600 Then XPos = 1600 If XPos < 0 Then XPos = 0 RedValue = Math.Min(255, AdditionalRedValue + RedValue) : GreenValue = Math.Min(255, AdditionalGreenValue + GreenValue) : BlueValue = Math.Min(255, AdditionalBlueValue + BlueValue) Dim AddressOfBinaryIndex As Integer = XPos * 4 + YPos * 6404 rgbValues(AddressOfBinaryIndex) = Math.Max(rgbValues(AddressOfBinaryIndex), BlueValue) rgbValues(AddressOfBinaryIndex + 1) = Math.Max(rgbValues(AddressOfBinaryIndex + 1), GreenValue) rgbValues(AddressOfBinaryIndex + 2) = Math.Max(rgbValues(AddressOfBinaryIndex + 2), RedValue) End Sub 7.Buttons on form to proceed scenes Private Sub ResetScreen() Dim Iu As Integer : For Iu = 0 To rgbValues.Length - 1 Step 4 rgbValues(Iu) = 0 : rgbValues(Iu + 1) = 0 : rgbValues(Iu + 2) = 0 Next End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click If At = 1 Then ResetScreen() : At = 2 : Cur = 0 End If If At = 2 Then MsgBox("sample application finished. thanks for downloading!") End If End Sub A VB2010 sample solution will be attached later. I'd like readers to download it! Of course it also enables binding DirectX interop APIs and above bitmaps in additional coding with slimdx or sharpdx, If you require GPU optimization. thanks for long reading AMStudiosSample1.zip
  4. Hi all, I have written a nice(ish) looking game of solitaire in Windows Forms, using VB.NET and Visual Studio 2015. It allows the player to play the game, and if their score is in the top 10, it saves the username and score o a leaderboard (saved in a text file so it is non-volatile). My next goal is to let the user know if the hand they are dealt is playable, but I'm not sure on the most efficient way of achieving this. I'm working on time complexity over space complexity! It's a simple game to code, but not an easy one to find the solution. Do you know of any algorithms that may achieve this goal that I would be able to look at?
  5. Hello, I'm a trainee for software development and in my free time I try to do various things. I decided I wanted to figure out how "Dual Contouring" works, but I haven't been successful yet. I could find some implementations in code which are very hard to follow along and same sheets of paper "explaining" it written in a way that I have a hard time even understanding what the input and output is. All I know that it is used to make a surface/mesh out of voxels. Is there any explanation someone can understand without having studied math/computer science? The problem is also that most of the words I can't even translate to German(like Hermite Data) nor I can find a explanation which I can understand. I know how Marching Cubes work but I just can't find anything to Dual Contouring also I don't quite get the sense of octrees. As far I'm aware of this is a set of data organized like a tree where each element points to 8 more elements. I don't get how that could be helpful in a infinite 3D world and why I shouldn't just use a List of coordinates with zeros and ones for dirt/air or something like that. Thanks A clueless trainee ^^
  6. Lately I've been working on building up a game's terrain from grid-aligned pieces. We might call these pieces metatiles because each piece is made of a collection of grid tiles that work together to create a unified feature in the game world. The beauty of this approach is that it fits neatly within the grid of a height mapped terrain. The difficulty is determining how to maximize the flexibility of the system using very few metatiles. Not only does a metatile require time and effort to design and model, but having a vast library of metatiles to choose from would complicate the world editing process. In my experience, most complicated metatiles boil down to arrangements of a few fundamental types of pieces. My idea is to simplify the whole process by restricting the game to features built up out of these six metatiles, plus flips and rotations: The red lines represent the feature that is drawn through the grid cells, and the gray lines represent how the cell is triangulated around the feature. For example, the red line might represent a vertical cliff or the boundary between one area and another, like the edge of a road or the shore of some body of water. These pieces, plus the flexibility of a height map, should be enough to create a wide variety of game terrains. The question is how does one build build an easy-to-use editor around assembling such small metatiles? For example, you can build up a curve out of these pieces by starting at a point and dragging the mouse in the desired direction. The editor would automatically choose the piece that most closely matches the direction from the current point to the mouse cursor. We can preview the next piece and perhaps wait for a mouse click to accept it, then continue with yet another piece until the curve catches up with the mouse. If the next piece would overlap with an existing piece, we display the preview in an error color and refuse to place the piece. Has anyone ever seen a system like that? While the above seems technically sufficient, there are a few details that would make editing awkward without additional automation. For example, a road would usually tend to have two parallel edges, and manually creating two parallel edges along a curved road in a system like this would be tedious and tricky. There is also a question of UV-mapping and how the user would specify the UV-coordinates of things like cliff walls and road surfaces. Ideally UV-coordinates would be handled entirely automatically.
  7. Hello, I am in need for somebody to come in and create a new battle script for my browser game. The current one that is being used is 13 years old and needs to be re-written. Needs to use existing stats (strength / intellect, agility, endurance), as well as item (weapon / spell, armour / cloak, helm / scepter, shield / field) stats, bonus` received from various features in the game. My game is Land of Nevard (https://www.landofnevard.net) Contact me at dravenlon@gmail.com
  8. Using my loop based on this: https://gafferongames.com/post/fix_your_timestep/ Trying to get my game to run at fixed 60FPS (both update and render) for all machines. Studied the link above and have been stuck on this game loop for weeks trying to get it to work smoothly to glide this image across the screen. I had dealt constantly with jittering and possible tearing. I can't recall what I did to fix it exactly, but I believe it may have something to do with not rounding a variable properly (such as delta). So yeah, currently the loop works but I'm afraid as I develop the game more and have to render more, eventually something I'm doing in my loop could cause slowdowns or larger CPU usage. Does the structure of the game loop below seem okay or is there something I can do to optimize it? The 2D game is a generic sidescroller. Not too heavy on physics, mainly just simple platformer physics. I feel as though I'm using way too much CPU. void Game::mainLoop() { double fps = 60.0f; int frameSkip = 5; int deltaSkip = frameSkip; double miliPerFrame = 1000.0 / fps; double xx = 0.0f; double playSpeed = 5; Uint64 previous = SDL_GetPerformanceCounter(); double accumulator = 0.0f; bool shouldRender = false; bool running = true; while(running){ Uint64 current = SDL_GetPerformanceCounter(); double elapsed = (current-previous) * 1000; elapsed = (double) (elapsed / SDL_GetPerformanceFrequency() ); previous = current; // handleEvents() handleEvents(); // when we press escape reset x to 0 to keep testing // when he goes off screen if(key_states[SDL_SCANCODE_ESCAPE]) xx = 0; accumulator+=elapsed; if(accumulator >= miliPerFrame * frameSkip) accumulator = 0; shouldRender = accumulator >= miliPerFrame; while(accumulator >= miliPerFrame){ // update() //cout << playSpeed << endl; double delta = ceil(elapsed); if(delta > deltaSkip) delta = 1; //if(elapsed >= 1) delta = elapsed; xx+= playSpeed * delta;// * (1 / fps); // /update() accumulator -= miliPerFrame; //get what's left over } if(shouldRender){ // render() SDL_SetRenderDrawColor(gameRenderer, 0xFF, 0xFF, 0xFF, 0xFF); SDL_RenderClear(gameRenderer); imageController.drawImage("colorkeytest", floor(xx), 0); SDL_RenderPresent(gameRenderer); // /render() } } }
  9. In Chess, there are many options for starting and answering. The Sicilian defense is one of them, but not the last, but, on the contrary, one of the most popular and successful. So, the goal of the presented game is to open and study all variants of the Sicilian defense in chess in a game form. The game develops concentration and attention, so necessary in chess. This game can be useful not only for chess players, experienced or beginners, but also for people who are just beginning to get acquainted with the ancient art of chess. And also to those who are quite far away from chess (smile). iTunes Store: https://itunes.apple.com/us/app/chess-match-sicilian-defense/id12… ls=1&mt=8 iTunes Store iPad: https://itunes.apple.com/us/app/chess-match-sicilian-defense/id12… ls=1&mt=8
  10. I am just a newbie game developer, I am trying to create a frame independent game loop. I am currently using the following code private class MainGameThread extends Thread { public static final int PAUSE_SLEEP_TIME = 10; long previous = getCurrentTimeInMillis(); long totalElapsed = 0; long gameTimeStart = 0; long currentTime = getCurrentTimeInMillis(); long accumulatorTime = 0; @Override public void run() { gameTimeStart = getCurrentTimeInMillis(); while (mIsRunning) { // Pause game while (mIsPaused) { try { Thread.sleep(PAUSE_SLEEP_TIME); } catch (InterruptedException e) { e.printStackTrace(); } } long current = getCurrentTimeInMillis(); long elapsed = current - previous; previous = current; processGameInput(); updateGameState(elapsed); totalElapsed += elapsed; if (totalElapsed > MainGame.MS_PER_FRAME) { drawGame(); totalElapsed -= MainGame.MS_PER_FRAME; if (totalElapsed > MainGame.MS_PER_FRAME) { Log.e("GAME", "Performance warning, rendering or update took too long"); } } checkIfGameShouldStop(gameTimeStart); } shutdownGracefully(); } private void shutdownGracefully() { } } It works, how ever it performs differently on different devices In my game models update method I am performing the following actions mCenterX += (mVelocityVector.x * timeElapsed); mCenterY += (mVelocityVector.y * timeElapsed + gameSpeed.getValue()) I have read this article https://gafferongames.com/post/fix_your_timestep/ But I can't understand the final example double t = 0.0; double dt = 0.01; double currentTime = hires_time_in_seconds(); double accumulator = 0.0; State previous; State current; while ( !quit ) { double newTime = time(); double frameTime = newTime - currentTime; if ( frameTime > 0.25 ) frameTime = 0.25; currentTime = newTime; accumulator += frameTime; while ( accumulator >= dt ) { previousState = currentState; integrate( currentState, t, dt ); t += dt; accumulator -= dt; } const double alpha = accumulator / dt; State state = currentState * alpha + previousState * ( 1.0 - alpha ); render( state ); } What does the State class object mean in this case. Could someone please help to adapt this example to my case or explain the example from the article and how I could update my loop to be frame independent ? Thanks
  11. Hi all, More than a decade ago, a problem came up on this forum for computing a fast transpose of a 3x3 matrix using SSE. The most sensible implementation stores the matrix internally as a 3x4 matrix (so, one row stores 4 elements, aligned in a vector). A version, which I believe to be the fastest currently known, was presented: I am pleased to report that I have been able to come up with a version which should be faster: inline void transpose(__m128& A, __m128& B, __m128& C) { //Input rows in __m128& A, B, and C. Output in same. __m128 T0 = _mm_unpacklo_ps(A,B); __m128 T1 = _mm_unpackhi_ps(A,B); A = _mm_movelh_ps(T0,C); B = _mm_shuffle_ps( T0,C, _MM_SHUFFLE(3,1,3,2) ); C = _mm_shuffle_ps( T1,C, _MM_SHUFFLE(3,2,1,0) ); } This should be 5 instructions instead of ajas95's 8 instructions. Of course, to get that level of performance with either version, you need to inline everything, or else you spend tons of time on moving floating point arguments to/from input registers. The other thing that is crucial is that the instruction set be VEX encoded. This allows generating instructions that take three arguments, like `vunpcklps`, instead of instructions like `unpcklps` that take only two. VEX is only available in AVX and higher (usually passing e.g. `-mavx` is sufficient to get the compiler to generate VEX instructions). -G
  12. In ordinary marching squares, we're trying to find isolines on a height map for some particular height. It's a delightfully simple algorithm because we can use a look-up table to determine the structure of edges and vertices within each grid cell based on whether each corner is above or below the desired height. In multi-material marching squares, each point on the grid has some proportion of several materials and we're trying to draw the boundaries between the areas where each material is dominant. This is less simple, since there are more than two options for each corner of each cell; at worst each corner could have a distinct dominant material. Even so, it's not too hard to approach this problem with a look-up table based on the corners of each cell. Finally, we have constrained multi-material marching squares, which is much like other constrained triangulation problems. In addition to the multi-material grid, we now have pre-defined boundary edges in some of the grid cells, and the multi-material marching squares must respect those pre-defined edges as if they accurately represent the boundary between two materials. I'm finding it hard to wrap my head around this problem. It seems that a look-up table will be of no use because the pre-defined edges create too many possibilities, even if those edges are restricted to the kinds of edges that marching square would naturally produce, but doing this without a look-up table also seems daunting. Motivation: In principle the goal seems quite simple. Take a 2D grid and use it to define terrain as a height map and as a material map that will form the foundation for a procedurally constructed mesh. Aside from the usual hills and valleys of a plain height map, the multi-material aspect of the grid allows us to define swamp, forest, desert regions on the map and apply particular procedural meshing for each. In addition to that, we want vertical cliffs that get their own special meshing and define the region boundaries. The cliffs are the constraints of constrained multi-material marching squares because when there is a cliff running through a grid cell, that should always act as the boundary if the material at the top of the cliff is different from the material at the bottom, even if marching squares would have naturally put the boundary somewhere else.
  13. Hi, i’m trying to build an effective AI for the Buraco card game (2 and 4 players). I want to avoid the heuristic approach : i’m not an expert of the game and for the last games i’ve developed this way i obtained mediocre results with that path. I know the montecarlo tree search algorithm, i’ve used it for a checkers game with discrete result but I’m really confused by the recent success of other Machine Learning options. For example i found this answer in stack overflow that really puzzles me, it says : "So again: build a bot which can play against itself. One common basis is a function Q(S,a) which assigns to any game state and possible action of the player a value -- this is called Q-learning. And this function is often implemented as a neural network ... although I would think it does not need to be that sophisticated here.” I’m very new to Machine Learning (this should be Reinforcement Learning, right?) and i only know a little of Q-learning but it sounds like a great idea: i take my bot, making play against itself and then it learns from its results… the problem is that i have no idea how to start! (and neither if this approach could be good or not). Could you help me to get the right direction? Is the Q-learning strategy a good one for my domain? Is the Montecarlo still the best option for me? Would it work well in a 4 players game like Buraco (2 opponents and 1 team mate)? Is there any other method that i’m ignoring? PS: My goal is to develop an enjoyable AI for a casual application, i can even consider the possibility to make the AI cheating for example by looking at the players hands or deck. Even with this, ehm, permission i would not be able to build a good heuristic, i think Thank you guys for your help!
  14. Hi, I came across this udk article: https://docs.unrealengine.com/udk/Three/VolumetricLightbeamTutorial.html that somewhat teaches you how to make the volumetric light beam using a cone. I'm not using unreal engine so I just wanted to understand how the technique works. What I'm having problems is with how they calculate the X position of the uv coordinate, they mention the use of a "reflection vector" that according to the documentation (https://docs.unrealengine.com/latest/INT/Engine/Rendering/Materials/ExpressionReference/Vector/#reflectionvectorws ) it just reflects the camera direction across the surface normal in world space (I assume from the WS initials) . So in my pixel shader I tried doing something like this: float3 reflected_view = reflect(view_dir, vertex_normal); tex2D(falloff_texture, float2(reflected_view.x * 0.5 + 0.5, uv.y)) view_dir is the direction that points from the camera to the point in world space. vertex normal is also in world space. But unfortunately it's not working as expected probably because the calculations are being made in world space. I moved them to view space but there is a problem when you move the camera horizontally that makes the coordinates "move" as well. The problem can be seen below: Notice the white part in the second image, coming from the left side. Surprisingly I couldn't find as much information about this technique on the internet as I would have liked to, so I decided to come here for help!
  15. Consider how one makes terrain using marching cubes. By having a grid of floats we can represent a continuous field that marching cubes will interpolate and turn into a nice smooth isosurface for the player to walk around on. This is easy and excellent for creating mountains and valleys and so on, but what if we want more variety in our game? A game is not normally made of just grass and sky. Maybe some places should be sand, or water, or road. How could that be worked into the mesh that we're getting from marching cubes? The obvious approach seems to be to have multiple fields, so each point on the grid has a certain level of sand, soil, rock, water, and so on. Then we modify the marching cubes algorithm to look for transitions between materials, so it puts a surface between areas of mostly one material and areas that are mostly other materials. We'd also want to keep track of when these surfaces touch the air, because that's the only time when we'd actually want to triangulate and render the surfaces. Suddenly the delightfully simple marching cubes algorithm is looking a lot less obvious. Has anything like this ever been done? Does anyone have any tips? Is this the right approach? Edit: Embarrassing mistake! I didn't think of phrasing the problem as "multiple materials" until I went to post this question, but now that I have I see there are plentiful google results for marching cubes with multiple materials. I'm still interested in any tips and advice, but now I have other resources to help with this problem. From the Google results, this paper looks especially interesting: Automatic 3D Mesh Generation for A Domain with Multiple Materials
  16. Hey I want to try shade particles by compute a "small" number of samples, e.g. 10, in VS. I only need to compute the intensity of the light, so essentially it's a single piece of data in 2 dimensions. Now I want to compress this data, pass it on to PS and decompress it there (the particle is a single quad and the data is passed through interpolators). I will accept a certain amount of error as long as there are no hard edges, i.e. blurred. The compressed data has to be small and compression/decompression fast. Does anyone know of a good way to do this? Maybe I could do something fourier based but I'm not sure of what basis functions to use. Thanks
  17. I'm being plagued by a desire to make a game where the player has a level editor that allows the player to draw a 2D level map and then it will pop up into a 3D level. Of course that sounds much like a height map, but sadly I have ambitions beyond what a height map alone can offer. I want the player to be able to draw a curve on the map and have that curve become a vertical cliff. I want the player to be able to draw a thick line and have that line become a road, its vertices lined up with the vertices of the surrounding landscape, but horizontal from side-to-side and with UV coordinates set to allow its texture to follow the direction of the road. If the player draws a road across a chasm, I want that to become a bridge. That may seem like it's asking too much, and it's true that for as long as I've been thinking about this problem I have yet to find an approach that works to my satisfaction, but there are limits to the goals of this project. Just like a height map, this project doesn't attempt any sort of cave or overhang. The final level needs nothing that cannot be represented in a 2D map. Aside from bridges, no part of the level ever needs to cross over itself. Aside from vertical cliffs, the landscape is restricted to being smooth slopes or flat land; there is no desire for the kind of jagged detail that's possible in a height map for this project. Aside from the cliffs that are specifically drawn in the level editor, there should be nothing blocking the player from moving around the level, so everything except the cliffs ought to be relatively smooth. I've tried starting from a regular mesh of equilateral triangles and adjusting the positions of the vertices to match the player's map. I appreciate the regular mesh because it makes it easy to give every vertex, triangle, and edge a number and store the level in an array. It also forms a graph structure that makes it easy to create smooth slopes and know when those slopes ought to be interrupted by cliffs. Unfortunately I have never been able to overcome the technical challenges of making the mesh and the player's drawings line up. I've tried starting from the player's drawn map and building a mesh around it. Unfortunately, computational geometry has never been one of my strengths, so figuring out where to put the vertices and edges to smoothly fill out the rest of the map is daunting. I've considered simulating the vertices as if they were electrons so they can form a minimum energy distribution around the fixed vertices specified by the player, but I'm not sure how to maintain the smoothness of the slopes if the vertices keep moving as the player draws. The bottom line is that I'm really not sure how to even begin solving this problem. I'm willing to put effort into implementing a complicated system, but first I need an idea for how that system ought to work. I really need the wisdom of someone more experienced than myself.
  18. I've come across a multiplayer game framework https://github.com/jondubois/iogrid and it features an algorithm to efficiently handle the movement and collisions of multiple players on a huge map. What it tries to do is to divide the map into smaller cells and create child processes (because it is single thread in javascript) for those cells. Then the algorithm distributes the game workload to different processes of the CPU. So basically each cell will be handled by a child process but everyone of them will share the same game context. This way if I use a 4 core or 8 core CPU I can use all the cores of the CPU by creating new workers processes. And supposedly it will reduce the burden of the master process. In C++ or Java we may choose to create new threads but in javascript there is only one thread in the code so creating processes is very similar. However, I am not familiar with the algorithm. I am not very sure if this is a standard way or a better way to deal with the multiplayer game scenario. But by looking at the way it describes this should be more efficient than using a single core to run the game server on a modern computer. I guess if this is the case there must be some kind of algorithm using by the game development community that does the same thing. What is the name of this algorithm and how can I find articles/materials about it? At the moment I find it hard to understand the algorithm. Particularly in how to deal with the cell overlapping and avoid duplicate calculations when players frequently moving between two adjacent cells. I hope this is not too programming language specific because we all need to deal with multi-core CPU and distribute the workload to improve game performance at some point.
  19. Hi, Im working on a procedural road system and I use bezier splines to genereate the mesh ( tri strip ) but I have a problem with calculating proper uv coordinates. The texture looks distorted on curved segments like on the attached picture When calculating uv i first init them to ( 0.0f, 0.0f ) or ( 0.0f, 1.0f ) for each vertex, and then add the distance between current and previous point on a curve to the previous vert U coord ( V stays the same ). Something like this: float dist = ( pos - prevPos ).Magnitude(); float lenScale = roadWidth / m_uvStretch; dist /= lenScale; verts[ currVertIndex ].uv.X = outVerts[ currVertIndex - 1 ].uv.X + dist; What am I missing? Thanks
  20. Are there any good books on the topic of MMORPG or RPG engineering. (like MU) I'm more interested in the server side architecture than client side. A book concentrated on rpg server development is preferred. I understand that there are too many topics to be covered in a single book. I'm looking for a book that will give me an idea about: Principles, ideas with example code or pseudocodes... Project structure Code structure How to properly structure the game loop How to handle zoning How/Where to handle AI Threading (what should be in separate threads) Multi servers (what should be in a separate server/machine) Putting it all together The book could also be on developing RPG's and I can just adapt it for multiplayer (server side). I currently have these books: Synthetic Worlds: The Business and Culture of Online Games Massively Multiplayer Game Development Massively Multiplayer Game Development 2 Game Development Essentials: Online Game Development Networking and Online Games: Understanding and Engineering Multiplayer Internet Games Designing Virtual Worlds Developing Online Games: An Insider's Guide Multiplayer Game Programming Multiplayer Game Programming: Architecting Networked Games Don't get me wrong they are great reads but they are mostly geared towards designing game-play, economy and solutions to common problems; some even marketing. Except for Multiplayer Game Programming which has some of the things I'm looking for but I'm still looking for more or a more comprehensive book. I considered looking into an open-source server for ragnarok online but it's already so matured that it's hard to follow the code and thought process of the developers.
  21. Hi folks, a fellow gamedev here. So recently I've been trying to make a business simulation games (similar to Holiday Island or Sim City), and start moving on the vital element of the game: terrain generation and manipulation. The terrain is a simple heightmap with a randomly generated height values (I haven't implemented the random generation part, cause of this issue I'm talking about). Basically, in my game the terrain has to have fixed elevation, so when you compare a terrain vertex to its neighbors, they could either: have similar height have a 0.5m height difference (higher or lower). It must not have more than 0.5m difference. I need to do that to simplify the terrain manipulation (the game kinda heavily relies on it). I was thinking on simply generate the random height first, and then loop over every vertex to force its offending neighbors to lower/heighten itself accordingly. But alas it just doesn't seem to be the right way. Perhaps any of you ever done similar things in the past? I hope you could give me any advice on this matter. It's been boggling my mind. basically this is the game that inspires me.
  22. Hi everyone, thank you for your attention. I'm making a 3D model editor based on voxel, to create models which looks like cubeworld ones (see https://i.stack.imgur.com/y5SWz.jpg) I've implemented a skeleton-key frames animation system. (My model has a mesh of vertices, and each vertices has a list of bones and weights, to determine how much a bone transformation affects the final vertex transformation) **And now, I'm looking for an algorithm to generate vertex bones weights automatically. I have each vertex position and bone position/rotation/size relatively to the model referential.** (Blender does implement this functionality https://blender.stackexchange.com/questions/782/how-can-i-automatically-generate-vertex-groups-for-an-armature ) PS: Google searching "auto rigging algorithm" actually gives some essays, but as I'm using voxel (as raw cubes), I would be glad to find something more specific/optimized/good looking
  23. I am currently working on a dynamic LOD system, After searching for algorithms to do this I found the quadric mesh simplification which looked very promising, however I have no idea how to implement it without any clear example of code. Does anyone have an example of how to implement this algorithm or any mesh simplification algorithm which would be useful for my goal?
  24. This is a technical article about how I implemented the fluid in my game “Invasion of the Liquid Snatchers!” which was my entry for the fifth annual "Week of Awesome " game development competition here at GameDev.net. One of the biggest compliments I’ve received about the game is when people think the fluid simulation is some kind of soft-body physics or a true fluid simulation. But it isn’t! The simulation is achieved using Box2D doing regular hard-body collisions using lots of little (non-rotating) circle-shaped bodies. The illusion of soft-body particles is achieved in the rendering. The Rendering Process Each particle is drawn using a texture of a white circle that is opaque in the center but fades to fully transparent at the circumference: These are drawn to a RGBA8888 off-screen texture (using a ‘framebuffer’ in OpenGL parlance) and I ‘tint’ to the intended color of the particle (tinting is something that LibGDX can do out-of-the-box with its default shader). It is crucial to draw each ball larger than it is represented in Box2D. Physically speaking these balls will not overlap (because it’s a hard-body simulation after all!) yet in the rendering, we do need these balls to overlap and blend together. The blending is non-trivial as there are a few requirements we have to take into account: - The RGB color channels should blend together when particles of different colors overlap. -- … but we don’t want colors to saturate towards white. -- … and we don’t want them to darken when we blend with the initially black background color. - The alpha channel should accumulate additively to indicate the ‘strength’ of the liquid at each pixel. All of that can be achieved in GLES2.0 using this blending technique: glClearColor(0, 0, 0, 0); glBlendFuncSeparate(GL_ONE_MINUS_DST_ALPHA, GL_DST_ALPHA, GL_ONE, GL_ONE); Putting all that together gets us a texture of lots of blurry colored balls: Next up, is to contribute this to the main backbuffer as a full-screen quad using a custom shader. The shader treats the alpha channel of the texture as a ‘potential field’, the higher the value the stronger the field is at that fragment. The shader compares the strength of the field to a threshold: Where this field strength is strong enough then we will snap the alpha to 1.0 to manifest some liquid. Where the field strength is too weak then we will snap the alpha to 0.0 (or we could just discard the fragment) to avoid drawing anything. For the final game I went a little further and also included a small window around that threshold to smoothly blend between 0 and 1 in the alpha channel, this softens and effectively anti-aliases the fluid boundary. Here’s the shader: varying vec2 v_texCoords; uniform sampler2D u_texture; // field values above this are 'inside' the fluid, otherwise we are 'outside'. const float threshold = 0.6; // +/- this window around the threshold for a smooth transition around the boundary. const float window = 0.1; void main() { vec4 col = texture2D(u_texture, v_texCoords); float fieldStrength = col.a; col.a = smoothstep(threshold - window, threshold + window, fieldStrength); gl_FragColor = col; } This gives us a solid edge boundary where pixels are either lit or not lit by the fluid. Here is the result after we apply the shader: Things are looking a lot more liquid-like now! The way this works is that when particles come within close proximity of each other their potential fields start to add up; once the field strength is high enough the shader will start lighting up pixels between the two particles. This gives us the ‘globbing together’ effect which really makes it look like a fluid. Since the fluid is comprised of thousands of rounded shapes it tends to leave gaps against the straight-edged tilemap. So the full-screen quad is, in fact, scaled-up to be just a little bit larger than the screen and is draw behind the main scene elements. This helps to ensure that the liquid really fills up any corners and crevices. Here is the final result: And that’s all there is for the basic technique behind it! Extra Niceties I do a few other subtle tricks which help to make the fluids feel more believable… Each particle has an age and a current speed. I weight these together into a ‘froth-factor’ value between 0 and 1 that is used to lighten the color of a particle. This means that younger or faster-moving particles are whiter than older or stationary parts of the fluid. The idea is to allow us to see particles mixing into a larger body of fluid. The stationary ‘wells’ where fluid collects are always a slightly darker shade compared to the fluid particles. This guarantees that we can see the particles ‘mixing’ when they drop into the wells. Magma particles are all different shades of dark red selected randomly at spawn time. This started out as a bug where magma and oil particles were being accidentally mixed together but it looked so cool that I decided to make it happen deliberately! When I remove a particle from the simulation it doesn’t just pop out of existence, instead, I fade it away. This gets further disguised by the ‘potential field’ shader which makes it look like the fluid drains or shrinks away more naturally. So, on the whole, the fading is not directly observable. Performance Optimisations As mentioned in my post-mortem of the game I had to dedicate some time to make the simulation CPU and Memory performant: The ‘wells’ that receive the fluid are really just colored rectangles that “fill up”. They are not simulated. It means I can remove particles from the simulation once they are captured by the wells and just increment the fill-level of the well. If particles slow down below a threshold then they are turned into non-moving static bodies. Statics are not exactly very fluid-like but they perform much better in Box2D than thousands of dynamic bodies because they don’t respond to forces. I also trigger their decay at that point too, so they don’t hang around in this state for long enough for the player to notice. All particles will eventually decay. I set a max lifetime of 20-seconds. This is also to prevent the player from just flooding the level and cheating their way through the game. To keep Java’s Garbage Collector from stalling the gameplay I had to avoid doing memory allocations per-particle where possible. Mainly this is for things like allocating temporary Vector2 objects or Color objects. So I factored these out into singular long-lived instances and just (re)set their state per-particle. Note: This article was originally published on the author's blog, and is reproduced here with the author's kind permission.
  25. Hello, so I wanted to get an opinion on the best ways to manage gameplay logic in a multithreaded manner. After watching these two presentations : http://www.gdcvault.com/play/1020886/Killzone-Shadow-Fall-Threading-the http://www.gdcvault.com/play/1022164/Multithreading It seems that the best approach is to create a dependency graph for object updating, and for any object that needs to access another object that isn't a dependency, a message should be constructed and called after the "multithreading" phase. I wanted to know if anyone had any experience with multithreading game objects in this manner, or if they have any other solutions.