• Advertisement

# suliman

Member

1425

1659 Excellent

• Rank
Contributor

• Interests
Art
Design
Programming
1. ## A* pathfinding: nodes instead of grid?

But while searching on a strict grid, it DID (always) find the shortest path. What do you mean by understating values? Could I do some trick with the move-cost for a connection (now I use simple distance) to lessen the errors? Or could I manually lessen the optimization to increase precision (without rebuilding it fully into djukstra). It seems to already optimize the NUMBER of nodes in a path (to have the least steps).
2. ## A* pathfinding: nodes instead of grid?

Yay it works! @Frob Maybe i ran into the problem you mensioned though: It always finds a path, but in certain circumstances it chooses a valid path that are slightly longer (around 10 %) compared to the most optimal path. I use distance (float) between nodes as movement cost for that connection. If I move that node so that path is now 20-30 % longer it will choose the shortest path instead. Any idea where this slight error may come from?
3. ## A* pathfinding: nodes instead of grid?

I propose to use the grid as normal (a 2d array of tiles), but I also give the pather access to my collection of "nodes". These have (max )10 neighbours which make up the "restriction". So when a tile checks for "neibours", they used to find all 8 adjacent tiles, but now it looks in the node-collection which tiles it could add as possible neibours. See the pic below. Node 3 would have only node 2 and 4 as neibours for example. It cannot find the tiles "right next to it" as it would in my normal grid-based mode. The nodes acts as my old tiles in other part of the code, they still have a x/y position which actually describes their position on the grid.
4. ## A* pathfinding: nodes instead of grid?

@Frob: not sure if I understand the problem, or if this would be a problem for me. After code inspection: So much of my code (both finding and storing the path and following it) depends on a grid (and I need one anyway for drawing the world / placing objects) I now consider this setup: 1. Use my tried and tested grid-based A* system. 2. Add a "node-based mode". This is work the same way but also keep track of the "nodes" in the way described above. Basically they inform the pather which are the adjacent "tiles" to each node-tile. So when running the grid-mode each tile has 8 adjacent tiles, but when running the node-mode it will check the structure outlined above for which (up to) 10 adjacent tiles are reachable from that tile. So basically I would pathfind over a restricted grid where only certain tile-to-tile connections are allowed. Seems doable?
5. ## A* pathfinding: nodes instead of grid?

I guess its the "find adjacent" and "adjacent costs" i need to fix. (i dont have it in front of me right now:). More info will follow! But in the grid version i just give the pather the pointer to the start of the 2D-array holding map data (terrain type for each tile) so now maybe a pointer to the array of all the nodes? I assume it's best to calculate the adjacentCost (cost/distance from a node to each of its linked nodes) beforehand and store them (in each node). Otherwise I need to calculated such distances thousands of times each pathfind. When it was a grid i just used the adjacentCost of "1" (or 1.41 for diagonal movement) so no calculation was needed. So something like: class pathfindingNode{ int id; int posX, posY; int adjacent[MAX_ADJACENT]; //the adjacent nodes(IDs) possible to move to. id -1 means no node at that slot float adjacentCost[MAX_ADJACENT]; //cost to move to an adjacent node };
6. ## A* pathfinding: nodes instead of grid?

Im using micropather, a c++ implementation of a* pathfinding in my games. I got it to work fine with a strict grid-based system, but now need it to also work with "nodes". My setup is like this: 1. I have a collection of nodes. Each node has a X/Y-position, an ID, and an array of max 10 node-ids it can move to ("adjacent nodes"). 2. Which nodes are reachable from each node are checked (based on a max distance and not having any obstacles between them). 3. Cost to move from a node to another is simply the distance between the 2 nodes' positions. I guess some things will be silimar to how a grid works, but im not sure how to reconstruct the code.
7. ## C++ Savegame headers?

Hi Im using binary files to save and load savegames. But when you list your savegames for the user you want some metadata such as date/time, gameday, difficulty, map name etc so the user more easily can identify which savegame they want to load. What is the prefered way of doing it? 1. When saving, save metadata first in the file. Then do a function "scanSaveFiles()" before showing the available savefiles for the user. This will read each "header" of each file (reads the first section of the binary file without actually loading that game) and can then show the info to the user. 2. When saving, update a table of savegame-metadata held by the "gameMaster" that holds other stuff like user options, progress etc. However this seems bad since if the user manually moves or modifies the savefiles the table of savegame-metadata will no longer sync with the actual save files. Or any other smarter way of doing it?
8. ## Progression in racing game: keep money and upgrades between races?

Thanks for your feedback! Useful input.
9. ## Progression in racing game: keep money and upgrades between races?

Consumable upgrades is the same as my suggestion 2 i guess (buy upgrades/weapons for each race). Having upgrades weak or very expensive (=player gets less upgrades) just makes upgrades less impactful, which is not very fun for an arcade game (but would make sense in a simulation). It's halfway to just removing upgrades alltogether. You want to feel the difference when getting something new. Giving the loosing player a boost by giving him/her more money might work yes, but it's a bit strange lore-wise Then it would make more sense to give all players the same upgrade-resources like i suggested (maybe just call it "time" as in "time spent in workshop" to upgrade and improve your vehicle").
10. ## Progression in racing game: keep money and upgrades between races?

Hi Im designing a arcade topdown racing game in the tradition of rock and roll racing (SNES), super cars 2 (AMIGA, PC) etc. You run a "campaign" of linked races, and you can upgrade, buy weapons and gadgets etc. There is both powerups on the tracks and stuff you can buy inbetween races. This is set in space with lasers and small spacecrafts but the logic is the same. How to hadle progress/upgrades/investments? If the player earn money from success (getting a good placement in a race), the player who starts off well will be able to buy better upgrades and weapons and it will be even harder for the other player to catch up later in the campaign (two players and many AI are allowed in the game). This is how it's done in super cars but im not sure it's good design. Some ideas could be: 1. Upgrades are persistant between races for the entire campaign, but each player get the same amount of money/resources no matter how well they do in the races. 2. Like above, but each player gets some fixed points/money to invest in each race for upgrades/configration/weapons: next race the crafts are reset. So you can try out a completely different loadout each race or build something you have already tried out. If you can choose different vehicles I get even more options:) I could replace some upgrades (like "better engine"/higher speed) with just having different vehicles: "shiptype X" may move faster, but cost more so less money left to stock up on missiles for the race ahead. Thoughts?
11. ## Pirate game: treasure hunting mechanic

Thanks guys! Some good thoughts. Any more input is always appreciated.
12. ## Unresolved external symbol?

yes it does. I continued to clean up and now it works (even with the body in the h-file). I think I had a reference to an old version of it that was local and not the standardized version i now use (#include "file.h" instead of #include <file.h>). This is one of my big problems with C/C++. It's so easy to get stuck on code administration (linking, include order, circle reference etc) It takes time (especially when reviving an old project that had a slightly different code architecture). Thanks for your help!
13. ## Unresolved external symbol?

Cool! Commenting out that call allows for it to compile. But what can be wrong here? That file (with the constructor for gameInventoryMaster) is included in all my project and those work without commenting out the call togameInventory::setSingleSlot(). Why is it now not allowed? I moved the body of the contructor (of gameInventoryMaster) to the cpp file (from the h file) and now all projects compile. So im confused, what could have have done here?
14. ## Unresolved external symbol?

Hi Having coded alot, i still get stuck on these things sometimes. I've restarted an old project so I needed to clean it up, fixed paths etc before it could compile. I still have one compile error: Error 1 error LNK2019: unresolved external symbol "public: void __thiscall gameInventory::setSingleSlot(class int2)" (?setSingleSlot@gameInventory@@QAEXVint2@@@Z) referenced in function "public: __thiscall gameInventoryMaster::gameInventoryMaster(void)" (??0gameInventoryMaster@@QAE@XZ) C:\Dropbox\PROJECT\code\games\racing\source\gameMaster.obj May it be a circular include or something? The function "setsingleSlot" is defined in a file called "inventory.h" which i dont have any references to in my project, so im a little stuck here. Any ideas? Happy holidays ya'all!
15. ## Pirate game: treasure hunting mechanic

Im doing a carribbean pirate game in the tradition of sid meiers pirates. In THAT game, you would buy pieces of treasure maps in taverns, and when you had all four you could see on the map where in the gameworld you should travel to find the tresure: you went there and got the treasure. Each "rival pirate" (there were 9) could be fought and defeated and also had a treasure you could find with the above method (defeating them and finding their treasure was independant from each other. Any ideas on how to mix this up for my game? I want famous pirates (10-12) rooming the world that you can defeat, and maybe their buried treasure should be linked to defeating them instead of buying map pieces? Another idea is to have rumour you buy from tavern reveal different things about a treasure location, such as: 1. close to which port (eg. "close to Port Royale") 2. direction relative to that port (eg. "south-west of it") 3. Distance from that port (eg. "12 leagues from it") Im using a simple 2d travel map as game world (satellite photo) of the carribbean which the players traverses. It's more fun gameplay to link together evidence such as those 3 above than to collect 4 map pieces and then place a marker "treasure is here" on the travel map (that feels to direct and guided). Once you have the idea of more or less where it is, you approch the beach there. If its close enough your crew finds the treasure. If not you just leave the beach. Sp you CAN find it without the 3rd piece of information but it might be harder. Or to get info about the treasure not before you defeat the pirate in question? (As a payment for not killing him?) Or tavernfolk only start to reveal info about the treasure after the pirate owning the treasure is defeated (since they are scared of him killing them)
• Advertisement