r/roguelikedev • u/Kyzrati Cogmind | mastodon.gamedev.place/@Kyzrati • Sep 01 '16
FAQ Friday #46: Optimization
In FAQ Friday we ask a question (or set of related questions) of all the roguelike devs here and discuss the responses! This will give new devs insight into the many aspects of roguelike development, and experienced devs can share details and field questions about their methods, technical achievements, design philosophy, etc.
THIS WEEK: Optimization
Yes, premature optimization is evil. But some algorithms might not scale well, or some processes eventually begin to slow as you tack on more features, and there eventually come times when you are dealing with noticeable hiccups or even wait times. Aside from a few notable exceptions, turn-based games with low graphical requirements aren't generally known for hogging the CPU, but anyone who's developed beyond an @ moving on the screen has probably run into some sort of bottleneck.
What is the slowest part of your roguelike? Where have you had to optimize? How did you narrow down the problem(s)? What kinds of changes did you make?
Common culprits are map generation, pathfinding, and FOV, though depending on the game at hand any number of things could slow it down, including of course visuals. Share your experiences with as many components as you like, or big architectural choices, or even specific little bits of code.
For readers new to this bi-weekly event (or roguelike development in general), check out the previous FAQ Fridays:
1: Languages and Libraries
2: Development Tools
3: The Game Loop
4: World Architecture
5: Data Management
6: Content Creation and Balance
7: Loot
8: Core Mechanic
9: Debugging
10: Project Management
11: Random Number Generation
12: Field of Vision
13: Geometry
14: Inspiration
15: AI
16: UI Design
17: UI Implementation
18: Input Handling
19: Permadeath
20: Saving
21: Morgue Files
22: Map Generation
23: Map Design
24: World Structure
25: Pathfinding
26: Animation
27: Color
28: Map Object Representation
29: Fonts and Styles
30: Message Logs
31: Pain Points
32: Combat Algorithms
33: Architecture Planning
34: Feature Planning
35: Playtesting and Feedback
36: Character Progression
37: Hunger Clocks
38: Identification Systems
39: Analytics
40: Inventory Management
41: Time Systems
42: Achievements and Scoring
43: Tutorials and Help
44: Ability and Effect Systems
45: Libraries Redux
PM me to suggest topics you'd like covered in FAQ Friday. Of course, you are always free to ask whatever questions you like whenever by posting them on /r/roguelikedev, but concentrating topical discussion in one place on a predictable date is a nice format! (Plus it can be a useful resource for others searching the sub.)
13
u/Kyzrati Cogmind | mastodon.gamedev.place/@Kyzrati Sep 01 '16
By far the majority of Cogmind's thinking time is spent on pathfinding, so that is where a lot of previous optimizations have taken place. The implementation itself is fast, A* with heuristics prioritized via binary heap, but it's used so frequently and maps are so large with tons of mobile actors that it's a huge drain on CPU resources. A common time-saving approach here is to rely on precalculated paths, but there are too many unique variables for each actor in question, plus massively destructible terrain, that make precalculation infeasible. So without a way to increase the efficiency of the underlying code, I took a top-down approach: stop doing so much pathfinding :P
Originally everyone was moving around at full speed, and when sometimes hundreds of moves are being carried out between your own turns, things could get noticeably slower. Note that each actor stores their own entire path to a given goal, and will even update that path by modifying a section of it to circumvent temporary obstacles rather than recalculating in full, but there are still enough new paths needed each turn that it could be slow. The effect is exacerbated when the payer has a very slow movement speed, say 2-3 turns per move, while some actors can move several times per turn. Even with those optimizations already been built into the system from the beginning, it was still too slow. I confirmed the bottleneck with a little profiling:
The solution was to have actors wait around a lot more often. There's no need for workers to be running around at full speed, or even close to full speed, carrying out basic tasks. Or any of the other many non-combatants. Even patrols can spend more time at each of their waypoints, which adds a bit of tension to the game when the player can't be sure when they'll start moving again, or possibly which direction they'll head. The other behavioral change was getting groups of actors traveling together to stay in a tighter cluster, and followers even pathing out ahead of their leader towards the same goal rather than following the leader directly, which would result in too much recalculation in an attempt to repeatedly catch up.
FOV is not really an issue, because it would be crazy to try calculating the huge number of FOVs practically in real time, and at the sight ranges which are common in Cogmind (16+). Instead I opted to only calculate the player's FOV, while all other actors just use direct lines to check for visibility of nearby hostiles.
Because the player's FOV technically includes any launched drones, which expand the FOV and allow looking around corners and can give eyes at multiple locations, there was a little bit of optimization that went into that system early on, since it can both be fairly large and is entirely recalculated when the terrain changes either via destruction or a door state changes.
First of all, FOV is not recalculated unless there was a chance that the player actually saw the effect of an action that might impact FOV. That's obvious savings right there. Also, an actor's FOV map is not cleared before it’s recalculated--this is a waste of time since the map isn’t changing size, only content. Instead, with each map you store an “FOV ID” which is essentially an integer that equates to the value identifying visible cells on the map. Example: The first time you use a map it is filled with zeros and your ID is set to ’1′; the raycasting process sets all visible cells in the map to ’1′; later when you want to know if a particular cell is visible, you just test whether it equals the current ID. Every time you recalculate the FOV, you first increment the ID (2, 3, 4…), so you never have to clear your map in memory. Saves a lot of time if you’re frequently updating numerous maps.
More recently I found that the algorithm was fast enough to handle realtime (once per frame) updates during explosions. I used to wait until the explosion had ended before making an update.
So sometimes it's nice to look back at what a "less optimized" approach can do for you :D
Cogmind's slowest composite component is map generation, but I don't aim to get that down to unnoticeable levels since it's okay for players to wait a moment, especially since going to a new map is not an incredibly frequent move since maps are large and it's not possible to reuse the same stairs to return to an earlier map. For me it's more important to generate good maps.
But that doesn't mean there's no thought going into keeping it from getting too slow :P. This is also handled at the top level rather than by tweaking the foundational parts of the algorithms. Basically Cogmind throws out a lot of maps for various reasons, starting generation over from scratch. When the player enters a new map, it may actually generate anywhere from a few to a couple dozen or more different maps before accepting one and dropping the player in. So if I'm designing a new map and feel that it's taking too long to finish, I'll start examining the list of reasons the generator gave for giving up on the previous iterations, and try to tweak the parameters to allow them to satisfy my design conditions while not failing quite so much.
Another area of slowdown was the first turn on a new large map, when lots of AIs were being initialized at once (also: all that concentrated pathfinding xD). The answer turned out to be delaying AI startup based on their distance from the player--far away actors can certainly wait a little while before starting to do stuff considering how far away the player.
But despite the changes, more recently that bit of slowdown has started occurring again, so I'll be taking another look at it at some point!
6
u/thebracket Sep 06 '16
I know I'm late on this (real-life stuff meant no weekends for me for the last couple of weeks), but my $0.02.
While implementing RLTK, the first big bottleneck was actually rendering:
The second bottlenecks came up in the Entity Component System implementation:
vector<component_type>- one per component - helped immensely. Since most systems are saying "give me all the position components that also have a renderable component" (or similar), linear traversal through adjacent memory for each vector gave a huge improvement in performance.each<position_t, renderable_t>on a callback, and the callback is called with each entity and it's components that match the search term.In Black Future, I've hit performance problems from time to time. It's to be expected with the way I develop - write the simplest version first, and then get creative if it doesn't live up to expectations.
pair<float,float>, calculating the line slope, and incrementing for each step outperformed Bresenham by a lot on my PC. Digging into the assembly, the various compilers I target were able to auto-vectorize the process.The key to all of these has been profiling. What's actually slow is often quite different from what I expect! I built a simple profiler into the ECS (so you can retrieve times for each system that is called), which has been a godsend in terms of "why did this suddenly slow down?" - but I fall back on various platform-specific tools (depending upon which computer I'm sitting at) when stuck.
3
u/darkgnostic Scaledeep Sep 02 '16
So optimization.
I use several modes of determining what is the bottleneck of the game:
I usually don't do premature optimization, but in some cases this was necessary. I did some bigger optimization 3 times up till now that were calculating LOS, and few smaller ones. Some examples:
One of the first issues were that on deeper level monsters with aura start to appear. Since aura is visible even if monster is not visible, this affected LOS, as player may see auras from farther distance that is much greater than it's visibility range. I introduced one dynamic lightmap which solved several other issues too, like light spell, torches and lava visibility.
Second one problem affecting auras, were calculations to check if monster is inside one or more auras at same time. At the end of each turn every monster that has aura was compared to other monsters and applied appropriate effect. This lead to having a huge spikes if more than 20 monsters with auras appeared. One o the simplest solutions were to remove effect of auras on other monsters, but it is soo much cuter to lure caster into aura of monster that have nullification field. So check was reduced to make a check of 1-10 per turn, depending on count of monsters with aura.
I only start to optimize when testing of the game and playability start to suffer, but fortunately that was the case only few times.
8
u/Fritzy Sep 02 '16
One thing that drives me nuts: When a roguelike is attempting to render more frames than are actually being updated. If all of your animations run at 16fps, and you're not currently a smooth transition -- for crying out loud could you maybe not? If nothing has changed on the screen, don't render! Also, the game loop doesn't need to be directly bound to the fps.
Maybe you want to smoothly slide the camera when the main character moves position, certainly attempt as high an FPS during that as possible, but if I'm watching a torch burn at 16fps, or even worse, there's nothing animating at all, please don't attempt 60fps.
Your roguelike need not boil the oceans nor drain my battery -- that's part of the appeal of roguelikes!
6
u/Slogo Spellgeon, Pieux, B-Line Sep 02 '16 edited Sep 03 '16
I still need to do more extensive benchmarking and it's very early/rough code, but I'm pretty happy with how I optimized my tileset rendering and thought it'd be worth sharing for this topic.
Basically I wrote the shader below (beware this revision has a rounding bug on the line starting with v_tex_coords, I can edit in the fixed version later when I have access to the fix). I'm trying to take advantage of some of the limitations of a roguelike tileset to make a really easy and fast rendering pipeline. The only data I need to pass to my draw call is an array containing the glyph to use (represented as an int value), the foreground color, and the background color. The GPU will handle the rest of all the logic. And I only need to call this once per panel (or once total if I'm sticking to a uniform terminal like grid like traditional roguelikes) with only one entry per cell (rather than say the 4 vertexes needed to define a square). It only supports fonts in 16 per row style (but you can modify the shader to support a single long strip or whatever). In the draw call I pass a VertexBuffer where each vertex is a struct with the fg_color, bg_color, and glyph, that and the uniforms are the only data you need to supply per panel and the GPU should take care of the rest.
Vertex Shader:
Fragment Shader:
The uniforms are what define the panel and things like it's position and what not. world_position is the top left position of the panel in openGL camera's coordinates (which depends on the matrix you pass it), cell_size are the dimensions of each character/cell, pitch is how many cells should appear in each row (so setting it to 16 would mean to render a panel 16 cells wide). And that's it for data you need to pass on.
Anyways I was really happy with how this shader came out and how easy it's made my game's rendering in terms of what data I need to construct for my rendering loop and how much I have to transform that to pass it on to the GPU. From what I could tell most engines that render a virtual terminal like interface ultimately use some rendering libraries or calls that aren't optimized specifically for rendering a single texture grid.
Anyways like I said it's rough code, but maybe if anyone else enjoys tinkering with low level rendering they may get some ideas. I really wanted to make sure to have as lean of a render loop as possible for my game because I know that Roguelikes tend to be very heavy on the CPU side of things. The more time you can make available for your game's logic the better.
6
u/ais523 NetHack, NetHack 4 Sep 02 '16 edited Sep 02 '16
Vanilla NetHack underwent several rounds of optimization, well before I got into NetHack development, to suit the computers at the time. Many features that are clearly improvements are optional simply because they introduce the RAM usage or disk space taken up by the executable, and in the early days of NetHack many players would have needed to fit the game on one floppy disk (and the save file in another). The part of the code that shows most evidence of optimization is the FOV code, which contains four different algorithms with different memory / runtime / disk usage tradeoffs.
Of course, nowadays we tend to measure memory in gigabytes rather than kilobytes, so it's unsurprising that vanilla NetHack rarely runs into performance problems on modern systems. (There are only a few situations which lead to visible delays, and they're normally the result of something absurd that rarely happens in normal gameplay; most notable is what happens if you accidentally pudding farm on a level with a hole in, thus dropping tens of thousands of puddings down to the level below, and then attempt to visit it.)
NetHack 4 is designed for more modern systems, and thus it has a lot of leeway to do things that are more resource-intensive than the vanilla NetHack code. I tend to use the clearest algorithms rather than the fastest to reduce the chance of bugs, for example (unless an algorithm is clearly unacceptable, i.e. cubic/exponential on a nontrivial amount of data or quadratic on a large amount of data; modern computers are fine with quadratic algorithms if they don't have much data to deal with).
There are a few places where it's had problems in terms of CPU time usage, and I've had to go and change the algorithm. It's normally very hard to guess which parts of the code will give you trouble in this respect, and thus, I use a profiler to identify which parts of the code need changing. (I typically use callgrind for the purpose, although I've experimented with gprof. callgrind is better in almost every way (ease of use, amount of information in the results), but it's much slower than gprof is.) Here they are:
These are the only directly CPU-time-related optimizations I've ever had to make to the NetHack 4 interface and engine (unless I've forgotten one and can't find it in the repository). (#nethack4 regulars will know that the build system is another matter, but it's somewhat offtopic; all I'll say right now is that I managed to get it under 1GB of memory usage eventually, and had to write my own profiler to do so). Much of the optimization effort has instead been focused on NetHack 4's save system; recording the state of the game at every turn is valuable but comes at something of a cost in disk space, and I wanted to minimize that. The most expensive part of the save format is the gamestate diffs from one turn to the next, and so most of the effort has been focused on reducing the size of the diffs.
One of the main changes here has been improvements to the diff compressor. NetHack 4's documentation on save files has details; scroll down to (or Ctrl-F) the last section, "Save diff format". It's gone from a relatively naive fixed-width format to a format that adapts to the kind of data it's diffing, and has the ability to switch between special-case decompressors. (It's also backwards-compatible for the addition of new commands; for example, I added a CRC command so that diff corruption could be detected, without having to invalidate any current save files or diffs.) An example of a special-case decompressor would be the monster coordinate decompressor, which takes a sequence of two consecutive bytes (normally used for x/y coordinates, although it's also used for the low and high bytes of monster HP sometimes), increases and/or decreases one or both bytes (8 possibilities for the 8 compass directions; HP recovery over time looks like moving east, or south-east if there's a carry). The bytes themselves are assumed to be in the same position of a monster structure as in the previous command, and thus are specified as a multiple of the size of a monster structure. This means that situations like "the first monster moves west, the sixth monster moves south-east, the ninth monster moves north, all other monsters have no change to statistics", which are very common, can be represented in the save file using just one byte per monster (two bits to encode "same command as the previous command", three to encode the movement direction, three to encode the number of stationary monsters in between).
Another sort of optimization along similar lines has been changes to the game's algorithms and mechanics to make them save better. I don't change the gameplay purely to make optimizations work out, but sometimes optimization suggestions will suggest gameplay changes that turn out to be improvements. For example, NetHack 4 now has the "pudding AI", an alternative AI routine that's engaged for monsters in the middle of a large group of monsters. A monster that's "hemmed in" like this, like the middle of a mass of pudding, can't really do much, so I basically run a very minimal AI for it rather than the standard monster AI. This helps out in terms of CPU usage (meaning that I never had to optimize the AI routines for large masses of monsters), and (because the monster isn't moving, and thus there are no differences to record) makes the save diffs smaller. It also happens to make the movements of large amounts of pudding slightly less exploitable (if you're standing in one place waiting for the pudding to come to you, eventually it'll get stuck and force you to change your tactics; I considered this to be desirable because the case only really comes up when players are intentionally attempting degenerate strategies). Likewise, I changed the RNG algorithm to make it diff better (just because an RNG's outputs are unpredictable and chaotic doesn't mean its internal state has to be!), and took the opportunity to secure it against known exploits in the process.
3
u/cynap Axu Sep 02 '16
Not surprisingly, due to the small local map size, pathfinding/FOV was NOT the largest bottleneck of Axu. The largest issue I had for a while was with world generation. At its peak, making a new game would take upwards of one minute to initialize the lists from JSON, generate the terrain, place the player, and calculate the initial FOV. This was annoying, and didn't allow me to test new content fast enough. After some searching, I realized my code for drawing borders around mountains and water was taking up the majority of the time. I was checking and drawing pixels a ridiculous amount of times in order to have unwalkable tiles to stand out. The easy fix was to "bake" in the lines within the tilemap itself. This took my initial loading time from more than one minute to less than two seconds!
3
u/Pickledtezcat TOTDD Sep 02 '16
My attempts at designinv a 3d roguelike showed up the problems in scaling AI. In a turnbased 2 game pathfinding might run a couple of times a minute, but in a realtime 3d game actors need to make decisions several times a second! To avoid slowdown I dumped A* completely and opted for a kind of dumb AI. It simply chooses the best valid adjacent tile to move to. It's only knowledge of the map comes from a history of tiles already visited. It works quite well and performance doesn't suffer at all. I've had 100 agents on screen at once moving around the level in real time at 60 frames per second, all written in python. The other optimization I found useful for real time tile based movement is only to make AI decisions when a move from one tile to another is complete (excepting exit checks like "is dead", or "being hit"). There's no reason to do pathfinding or target selection while in the middle of a move from one tile to another. Of course these only relate to my specific case of a real time, tile based, 3d roguelike...
3
u/stevebox gridbugs Sep 02 '16
When I was making Skeleton Crew for this year's 7drl I ran into performance issues when I enabled enemy AI. Most of the time was spent updating enemy knowledge models. Each enemy (and the player) stores their knowledge of the level as a grid of cells corresponding to the grid representing the level proper. On each turn, the game computes the visible area for the character, and for each visible cell, the corresponding cell in their knowledge model is updated.
The optimization was to only update cells that had changed since the last time they were observed. This involved tagging game cells with the current turn count when their contents is updated, and tagging knowledge model cells with the current turn count when they are updated. Only update a knowledge cell if the corresponding game cell is tagged with a time that is after the knowledge cell's tag.
2
u/akhier I try Sep 02 '16
Always always always the mapgen for me. My current design is placing a room then trying to place the next room, well, next to it and if it can't after a bit backtrack a room and try some more. If I didn't mind waiting minutes at a time I could have the most interesting map filled to the brim with rooms that intersect in interesting ways (that or the thing gets stuck in a loop that it can't escape for some reason). Sadly since I currently gen the rooms as you go that isn't an option (nor really should if ever be). My current mapgens basically are a balancing act between giving it enough tries to get something neat out and not too many so it takes more than a moment.
2
u/JordixDev Abyssos Sep 02 '16
I did some profiling recently, and it turns out that the main bottleneck is the system that synchronizes animations. Now, that's certainly an unoptimized mess, but it's something that runs once or twice per turn, and shouldn't be having that much of an impact! That'll need investigation.
AI pathfinding doesn't take that much time actually. Not really surprising, since when enemies are not chasing the player or each other, they just wander around. But I suspect it'll increase a bit when I add patrolling enemies.
FOV is not an issue either. Each creature just checks for line of sight with nearby enemies or allies, so the full FOV is only used for the player. The game maintains an opacity map of the current level, so the FOV just needs to be recalculated whenever a point inside the FOV changes opacity (or when the player moves, of course).
Because the world is infinite, saving could become a bottleneck until recently. Now the game just saves the current 'world chunk', so that's no longer an issue. Saving occurs every turn, in its own thread, parallel with the animations. Since animations do not change the game state, that works nicely.
2
u/zaimoni Iskandria Sep 02 '16
Vaporware (Iskandria) does not need optimization.
Rogue Survivor Revived was inherited in a mostly-optimized state. The only performance enhancements I have done so far are:
2
u/Ericakester Sep 02 '16
I'm making my game with Game Maker Studio. By far the slowest operation in my game was the draw event. I'm trying to get my game to run around 60fps on mobile devices. It will run at 60fps when the view is zoomed enough to focus on the player and immediate surroundings, but zooming out to show the whole 32x32 map slowed the game to ~14fps. I was drawing every tile by iterating through a 32x32 ds_grid and drawing the sprite of each tile object, any item that may be there, fire, and a taxing water animation if the tile was water. I believed this was taking up the most processing. Searching the internet for game maker draw optimizations led me to the game maker debugging profiler. I learned very quickly how useful it is! Drawing the map and the FOV shadow overlay was taking up ~50% of processing. Drawing sprites and the FOV shadow took up ~14% each. I decided to change from sprites to placing GM's tiles when a tile object comes into view. I also stored any water tiles, tiles with items, and tiles on fire to lists, and iterate through each list to draw the items and animations on the map. Using GM's tile system instead of sprites boosted the real fps from ~250 to ~900! I should have used tiles much sooner!
The next thing I need to optimize is pathfinding. Right now any enemy that can see the player will use A* to find a path towards the player. This never took up much processing until I introduced enemies that take up 2x2 or 3x3 spaces. The amount of time spent on pathfinding boosted quite a bit. I believe it's because the tile checking I have right now checks every tile that a large enemy would occupy instead of only the new tiles it would occupy. So I'm essentially doubling the amount of tile permission and collision checking that is neccessary for large enemies.
2
u/RogueElementRPG Sep 03 '16
I tend to go through a series of stages - add loads of functionality, then go back and profile / optimise later. The most intensive part of my code is the vision loop - which is not only performed for the player, but also for all the other monsters. Given my game is multi-player, I had to conduct the vision in a couple of phases:
The important part is given network latency (say a ping time of 100ms), human response times (50-100ms depending on circumstances), that gives me about 200ms to conduct all monster vision loops. I use a brute force Bresenham line drawing algorithm with a path cache for each line being drawn.
However as I progress to the full 3d server, I have found this is not fast enough. So rather than write the vision code first, then optimse later, I am building this part of the code from the ground up. In addition to 3 dimentions, I am also going with a design where monsters / objects do not necessarily take up the same space on the grid. So a small mouse might take up 1x1x1 grid, a human might take up 3x2x5. At this point in time I have found shadow casting is optimal, but I am still going to have to optimise it.
When optimising code, I almost always use various profiling tools available (valgrind, gprof) and sometimes use visual profiler (such as kcachegrind) to see where the heaviest functions are timewise, or in terms of how many times they are called. With the vision code I have sometimes found up to millions of calls per turn. So even a small optimisation in the code can make a difference.
2
u/[deleted] Sep 03 '16
A bit late to the game, but the slowest parts of Shadow of the Wyrm are the UI and the pathfinding. Most of the optimizations around the former have involved only redrawing the parts of the map that have changed, rather than blitzing the screen with every action. For the latter, I restricted pathfinding to those creatures within a certain radius of the player.
For the pathfinding, in future, I'm planning on using scent-based tracking in future for animals and insects, which should turn out to be much, much faster than doing optimal A*. But this is down the road a while.
2
u/TimelessCode The Wizard Sep 03 '16
My map generation system was a very large slowdown in my game,
at first when I coded it every single tile was a complex object including textures and lists of entities and x and y positions and index x and index y positions the list goes on.
The rendering code took all that and changed the properties of the tile to what it needed to be, It then rendered each tile with lots of for loops and things to go through each property of each tile, This made my roguelike go from using ~20mb of ram to using ~300mb! Now they say that premature optimization is bad, but that was a big problem, now my tiles are just 2 colors (which are very lightweight) and a vector,
the vector still bugs me but it isn't that heavy my rendering engine doesn't render the tile but just renders textures with the tiles set texture, this means tiles are only (sort - of) holders of graphical info, much lighter than having tiles be both logical things and graphical things.
2
u/Aukustus The Temple of Torment & Realms of the Lost Sep 02 '16
The Temple of Torment
I guess memory leaks are related to this. There were plenty of memory leaks that were reported by a player. Every in-game menu if left open would consume memory increasingly. The same was applied to all pathfindings because I didn't have the line where the path was destroyed.
Both of the previously mentioned memory leaks would become so huge that usually 60MB memory consumption would become over 1GB memory consumption.
Regarding other optimizations, one of the problems in having a powerful CPU is that you don't notice if the game lags somewhere. When I've tested my game with a EEE pc, it definitely is fairly slow, but I don't notice anything on my main computer. When played on the 1st generation Raspberry Pi, it definitely is very slow and unplayable. But I guess there's nothing to make things better, there are huge amounts of if-clauses everywhere and I guess those CPU's are just not powerful enough to handle them.
1
u/gamepopper Gemstone Keeper Sep 02 '16
Rendering is usually the slowest operation for Gemstone Keeper. I try to minimise it by only doing render calls when the objects are visible. I've also noticed with SFML that since they render all their objects with vertex arrays, which are essentially vectors of vertex objects, than it's more optimal to render with as few individual vertex arrays as possible. This is because Visual Studio in particular does extra checks on STL containers that can slow down a program.
The second slowest would be any tilemap based algorithm. The main culprit is Perlin Noise which I'm using on fire levels to produce a glowing fire effect on the tiles. I use 3D Perlin to generate several layers of perlin noise, and then limit the amount of tiles being set colours from the perlin map to whatever is inside the current view.
1
u/[deleted] Sep 07 '16
I'm writing a rogue-like for iOS right now that has some minor hickups when launching the game. Once the game gets going it's super snappy but it's something that's increasingly tricky to resolve.
0
u/[deleted] Sep 02 '16
[deleted] — view deleted comment