Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411196 Posts in 69314 Topics- by 58380 Members - Latest Member: feakk

March 19, 2024, 02:25:46 AM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsCommunityDevLogsDwarf Fortress meets The Outer Wilds? "Ultima Ratio Regum", v0.10.1 out Feb 2023
Pages: 1 ... 31 32 [33] 34 35 ... 53
Print
Author Topic: Dwarf Fortress meets The Outer Wilds? "Ultima Ratio Regum", v0.10.1 out Feb 2023  (Read 176290 times)
RujiK
Level 2
**



View Profile
« Reply #640 on: July 01, 2015, 09:26:00 AM »

Dang, genetic spreading... This is some hardcore stuff.

How did you optimize the vision script?! Tell me!!
Logged

Ashedragon
Level 2
**



View Profile WWW
« Reply #641 on: July 01, 2015, 02:51:00 PM »



This honestly hurts my eyes and is exceedingly confusing to look at.
Logged

Ultima Ratio Regum
Level 7
**


Game Studies Lecturer, "Ultima Ratio Regum" person


View Profile WWW
« Reply #642 on: July 02, 2015, 02:02:06 AM »

Dang, genetic spreading... This is some hardcore stuff.

How did you optimize the vision script?! Tell me!!

Heh - a few things, really. Firstly I reduced the number of tiles it needs to actually print each turn (i.e. if a tile output hasn't changed since last move, don't bother); secondly, I improved the reading of the tiles so that it doesn't have to go into memory, but instead into a specialized dictionary of terrain colours; thirdly I improved the "is this in vision right now?" code, which I noticed had a lot of unnecessary garbage in it. The combination of all that meant that the previous small FOV window was only taking about 1/10th of the time it used to, and thus it could be expanded! It could still do with some further optimization, and I intend to do that before the 0.8 release (I think I could reduce it by another 30-40%?), but for now, it is as fast as it used to be, but you can see vastly more.

This honestly hurts my eyes and is exceedingly confusing to look at.

I'm very sorry it hurts your eyes, but I will have to disagree that it's in the least bit confusing to look at. From walking around in the world it's very clear - and since it is something that the majority of players have been asking for for *years*, I'm afraid it's staying!
Logged

gimymblert
Level 10
*****


The archivest master, leader of all documents


View Profile
« Reply #643 on: July 02, 2015, 06:17:43 AM »

It's not necessary but maybe if we tone down the ground saturation by 10% to increase contrast?
Logged

Ultima Ratio Regum
Level 7
**


Game Studies Lecturer, "Ultima Ratio Regum" person


View Profile WWW
« Reply #644 on: July 05, 2015, 06:52:30 AM »

It's not necessary but maybe if we tone down the ground saturation by 10% to increase contrast?

Maaaaybe... I need to change how terrain is stored at some point, so I'll think about it then!
Logged

Ultima Ratio Regum
Level 7
**


Game Studies Lecturer, "Ultima Ratio Regum" person


View Profile WWW
« Reply #645 on: July 05, 2015, 09:05:19 AM »

This week I’ve been developing the crowd mechanics, and it’s going well, but first we need to talk about how exactly I need this to work:

We have two levels of resolution: the map grid the player is walking around on, and then every other map grid (in the 250×250 tile world map) which is not currently loaded. Therefore, any NPCs who are important but are not currently spawned must be tracked by the game when they’re on a non-loaded world map tile. This, of course, gets very complicated when you have an important NPC start on the loaded map tile the player is walking around, and then step off that map tile onto another… and then how do we track them over, say, 50 turns if the player THEN decided to follow this important NPC onto another map tile, spawning that tile (which the NPC has been walking in, even though it hasn’t been spawned)? Well – for the time being we aren’t worrying about that, although I think I have a good solution. What I’ve been doing this week is getting the standard crowd spawning and walking around sensibly in city districts, which means Lower-Class, Middle-Class, Upper-Class, Military, Market, City Centre, and Religious districts (docks and castles are still not spawning; castles will be coming 0.9, and docks either 0.9 or 0.10 depending on how development plays out).

I tried a few systems last week where NPCs could walk freely around the map without paying attention to the roads, and this ran into two issues. Firstly, having 100+ NPCs moving at once was necessary for the city districts to not feel like a ghost town (even if I made sure the game slyly spawned/de-spawned NPCs around the player to give a false impression of greater density) and this, on 200×200 maps, was beginning to cause minor performance issues; secondly, it just didn’t look very interesting, and there didn’t seem to be any real method or deliberate action to what NPCs were doing. If you trailed them until they hit their target location, they’d just then choose another location, and repeat.

So, this new method had three logics: firstly, to create a form of pathfinding which doesn’t actually need the game to calculate paths to reduce CPU usage; secondly to make NPC movement seem more deliberate; and thirdly to allow NPCs to “path” (or rather, fake-path) towards the gates at the edge of cities, and thereby withdraw themselves from the map if the player trails them long enough, rather than just continuing to identify new locations on one map which they are allowed to travel between. So, I got to work.



The first step (above picture) was to identify areas of the map which a) any NPC could walk (light green), b) which any NPC could walk on and which were curves in the road which the NPCs would have to stop walking straight to traverse (yellow), and which only certain NPCs would be allowed on (dark green) for each of the seven current city districts. There are also some areas of the map which aren’t roads which are blocked to some NPCs (like the courtyard in a mansion, for example), but those aren’t integrated just yet. I created this secret road map, got NPCs spawning on roads, wrote a bit of code for them to be able to identify another road coming off the first road, and let it run.



The first trials would up like the above picture. NPCs spawned on roads, and could sometimes path correctly… but they were always looking for other branches of the road networks they could move onto, but seeing parts of the road they were already on as being a “different” road, and therefore they kept flicking uncertainly back and forth between hundreds of subjective “roads” which, to a human player, would be obvious.The next step was to add a road_direction variable (basically the same as the player’s facing variable) where they keep track of what direction they have been moving, and they can’t read a “road” into their current direction, or their opposite direction, and thus will only detect new roads to explore if those roads are at right-angles. I then upgraded the code for the curves, creating hidden “lanes” for the NPCs to path along:



Which can be usefully compared to the overall pathfinding map for the same district…



…for when we come to NPCs moving off the roads.

Anyway. With that fixed, I upped the number of NPCs, and we got this wonderful image:



This looked cool, but it was a bit too dense, and they looked too similar all sticking to the road paths rather than diverting. We’ll be coming to the “going off the road” issue later in this entry, but the next step was to try and balance their spawning, de-spawning, and the density of the crowd. I firstly needed to make sure an equal number were spawning in front of the player and behind the player, and that some NPCs would spawn directly at the gates, even if those gates are in full sight of the player, and that they would then cut back across the player’s movement. Once that was done, and people were likely to spawn in front of the player, and behind, and at all different locations – and a full complement of civilians was spawned before the player even set foot into a map grid – we had something which looked much better. Here’s a gif of watching a wide range of people wandering around (for now it is spawning them with a random culture, rather than spawning an appropriate population distribution for each nation), and then after they’ve walked around for a bit, I decided to have a closer ‘l’ook at one of them and browse their clothing:



And here’s a comparable screenshot of  “examining a passing NPC” in progress, which I have chosen simply because I really liked how this guy looked:



Two stages now remain: to ensure this works for all city districts (and then extend it to tribal settlements, fortresses, towns, etc), and to also make sure that sometimes NPCs wander off the road and go exploring on their own. The first is still in progress, but the second seems to be going reasonably well. The objective is to get the NPCs very rarely “breaking off” from the road and heading to other places on the map, either a randomly-selected location (which they are allowed to walk on), or a door they are allowed to go through (so a random “human” (‘h’) can path towards a random house in a lower-class or middle-class district, and then if the player sees them go through, that NPC is then associated with that house). Equally, we should have a small number of NPCs spawn off roads out of the player’s line of sight, and then path towards the roads, and then move towards road properly. When working nicely, this gets the majority of NPCs keeping to the roads, whilst very rarely we see one of the NPCs break off and head elsewhere, and if you follow them, they will either carve a path through the terrain or make their way to a door and then pass through – I’m clearly going to need some flavour text for “You see a person go through a door”, “You hear a door open and shut” if you’re right next to it but don’t actually see them go through, etc (whilst making sure this doesn’t get obnoxious and it doesn’t fill up the message log). As was suggested in a previous thread, I’m also going to add lots of flavour text when you enter/exit buildings, but that’ll come later this release. I’m still finishing off the pathfinding to non-road areas, so that’ll probably come next week when I’ll likely have finished pathfinding (I hope) and have the remainder of that to show off, and possibly some other clothing too? See you then!
Logged

gimymblert
Level 10
*****


The archivest master, leader of all documents


View Profile
« Reply #646 on: July 05, 2015, 10:37:03 AM »

That's look WAY too complex for a crowd system (or I'm not reading it correctly lol)

1. It's procedural generation, you don't need "pathfinding" you can generate any npc at the correct place without any tracking at all. Just generate the schedule per npc, every path is a time interval between two places so you just need the time to know where the npc is, leverage the procedural data structure to find the precise tile to the microsecond and beyond precision. Scale very well to any time sensitive behavior complete with animation and current state. Don't forget that place prescribe behavior (sleep in bedroom, work at job, etc ...) it help a lot filtering check and allow for hge increase in credibility and richness.

2. If you spend some time you can correlate npc generation to spatio temporal parameter you won't even need to maintain a list of all npc (important or not), just generating the place ill automatically generate NPC doing the right stuff (hint the procedural virtual list can be bucketed temporally into space, so querying the space give you a small bucket of relevant npc)

3. If you need pathfinding, leverage the procedural description to sort through path. When generating you use hierarchical description in general, it allow you to sort and tag paths in order to compute schedule (which are very predictable generally, home > job > service > home, and variant) there is logical relation within path and logical function, path that lead to different functional area like home, to services or job etc ... it's not entirely mixed up, there is a logical order too in generation that allow to find pathes specific to each npc. Even path inside the same functional area are grouped within a sibling logic so it help a lot finding path without spending too much time computing it.

4. If you really need complex path finding, try to make npc a "particle" own by route. In pathfinding decision only happen to intersection, dead end are only goal, and a series of waypoint is just as good as a straight line (no matter how twisted, it's just going forward or backward from one end to another). So you get a system that just increment NPC own "direction" (positive or negative along the waypoint)whenever it's not on an intersection (all waypoint path), and when npc collide with intersection it update once its direction to a new path. Intersection can (should) also own "signposting" like in real life (ie own all destination within it's own area, which is easy to get with procedural generation), when a npc collide with intersection he query the intersection to know which direction is goal is. If the goal is outside the area of the signposting it goes up the hierarchy (for example district city) find the district with the goal, find the connected path to the next district (or step area) and store that as a subgoal (you only need one at any time), when the npc is at the district local signposting take over to the final destination.

5. In procedural generation CORRELATION is king (more locale), if you use causality you are doing a simulation (more global) not a procgen system (I make the distinction at least), for example river are notoriously difficult to simulate, it's hard to find realistic but functional path when mountain are already generated, however if you generate the river first, generating the mountain is easier after the fact by following up the river. Another problem is the prey/predator ratio, in simulation it tend to become chaotic and not predictable (which we like in procedural generation to do various hack and saving or for gameplay reason), however a statistical correlation is enough for credibility and is predictable (and we can use a randomness filter to create illusion of chaos when needed).
FAKE IT TILL YOU MAKE IT

6. Use "stand" to give life. Stand are some kind of spawn POI where you generate npc at slot and various function. It's likely what you use to generate house and populate it with npc or the path themselves. For example group of people hanging together, a fight with its crowd, a seller, or just lover hanging out (mobile stand).

7. Label place along privacy and intimacy axis. Privacy rate how own a place is, for example public space is own by all members, the house is own by a family, bedroom by one person, it control membership. Intimacy rate how occupied a place can be, toilet are public but intimate (you don't let other people there with you), a park is completely public. It help generating the right kind of person at the right place and prescribe the right behavior, they combine together to facilitate credibility, a bedroom is both private and intimate, entering one will automatically put people off (violation of privacy) or be acknowledge by some npc (can be seen as a proposition). It give affordances to space. Other metric can be used to facilitate generation and behaviour's credibility (theose are generally more common such as how forbidden a place is by "law").
« Last Edit: July 05, 2015, 10:50:48 AM by Jimym GIMBERT » Logged

Ultima Ratio Regum
Level 7
**


Game Studies Lecturer, "Ultima Ratio Regum" person


View Profile WWW
« Reply #647 on: July 06, 2015, 07:21:49 AM »

Whew - that's a very interesting comment.

Firstly, I think I need to distinguish between two kinds of NPCs - those who matter, and those who don't (harsh, but true). By this I mean that the general crowd don't matter - they are there purely to make the world *look* lived in, and to behave as if they live there. Therefore, I don't need to schedule things like food and sleep etc for every NPC, I only need to ensure that the tiny number of NPCs which the player is currently able to see are behaving appropriately, which is a much simpler task. And I have to say, I'm surprised you say that my system seems complex, as your system seems vastly more complex to me! (Though I really appreciate the thoughts). The NPCs who do matter will be few and far between (a few hundred?) and they will be tracked specifically, though that system will come later.

But ultimately, what matters is that the crowd *looks like* it's behaving how it should, as the crowd only serves to make places look lived-in, and to give the player a look at the "normal citizens" in each nation. This is the kind of reason why the world generation algorithm in URR is actually pretty simple compared to, say, Dwarf Fortress - because what matters to me is what the player sees/perceives/experiences, not the actual underlying systems (though were I making a more "simulationist" roguelike, I'm sure I would feel differently on the matter). Privacy/intimacy is an awesome idea, but far too detailed a simulation for what I'm after - some areas do have permissions for certain categories, but that's all. Were I trying to create a world where every NPC was tracked and had a fully logical schedule I would certainly be doing it differently, but the appearance of the crowd and the crowd's logical actions are what matter here. As I say, important NPCs will be modeled in a lot more detail, and that'll be handled probably next month (or started late this month, depending on how quickly everything else goes... but let's assume next month), and you've made some interesting suggestions I'll definitely take on board!
Logged

gimymblert
Level 10
*****


The archivest master, leader of all documents


View Profile
« Reply #648 on: July 06, 2015, 08:18:13 AM »

haha I kinda get carry a bit and toss many suggestion beyond the scope of the initial reaction!

However in case that help I will elaborate a bit:

1. It's complex, because it's a lot of small difficult problem (tracking npc in unload part, pathfinding, ie little simulation problem) but it's easy to conceptualize. My proposition is that if you correlate space and npc then those little problem just disappear but the complexity come in the leap of logic you need to do to conceptualize it ... I have already made that leap so it seems simple to me XD the solution is simple ONCE you find it. Also because it's procedural if it works for one NPC it works for all. The beauty of procgen is to be scale independent. Seriously time dependent bucket is way simpler once you understand the concept! And super powerful!

2. Since you mention following a npc that do plausible thing, I proposed the schedule as a solution. Schedule can be as complex as you want (they don't need to eat  got carried away by proposing more potential lol), it's procedural happy because it's really just a parametric template you fill accordingly (and template can be filled with other template lol, for example a simple home>job>home template can fill the job template with a schedule pattern that depend on the job, then using the personality of the npc to parametrize that job schedule, etc ...).

That quality allow for "agenda" creation, aka spawn a npc inside the simulation bubble, fill a schedule template that match the context (I assume you generate npc based on a template you fill randomly based on the district context, you just add time as a constrain, which you likely do ), assign location outside or inside the bubble simulation (for example he is going to job that match his description, if there is an empty job slot inside the simulation bubble he can go there or he might choose one outside of the simulation bubble not yet generated, simplify or complexity according your need).

Of course you can also just choose a plausible destination without generating the full schedule by finding logical goal moment by moment each time he fulfill the previous one (or an event modify the current one if that's a thing you do, like in gta). In implementation you have just a kind directed "behavior"graph that loop onto itself and that have all the logical schedule transition, so when the npc is at a node he can query the next logical step randomly but also based on time parameter.

Of course following a given npc inside the simulation bubble might lead to the exact same home another npc entered before as soon as you leave the place and come back (nothing exist outside the simulation bubble the data is lost). GTA has teh same problem.

Of course I'm assuming you have day night cycle ... however the complexity does not change if you don't lol just the input of of the data set.

I know it will drill into your mind over time, I remembered when I proposed you a procedural way to look at puzzle, it seems that soon after it lead you to realize the whole world can be based on following trail of information as a valid mechanics ala Umberto. I don't know if it's correct lol.
« Last Edit: July 06, 2015, 08:27:52 AM by Jimym GIMBERT » Logged

Ultima Ratio Regum
Level 7
**


Game Studies Lecturer, "Ultima Ratio Regum" person


View Profile WWW
« Reply #649 on: July 11, 2015, 03:05:50 AM »

Heh, not a problem! I like the discussion.

So: this is interesting, but I've honestly got everything implemented already using the technique I'm using, which can apply reasonably to any city district (it will need a little bit of tweaking for villages, fortresses, other structures) and it only takes a few milli seconds to calculate and enact the moves for every crowd NPC on the map (and my laptop is GARBAGE, so I always keep in mind that it'll be much quicker/slicker on an actual modern machine).

However, 2), a schedule is definitely something I'll be implementing and will be absolutely essential for the tracked NPCs. As you say, it'll just be a template where I can insert different tasks, locations, places the NPCs need to move to, etc, and then ensure that the game can abstract that out reasonably well when the map the NPC is on isn't actually loaded but the NPC still needs to be acting anyway (which is going to be extremely tricky). Yeah, the GTA problem is the one, and I know it will be very tough to sort out. Heh, I do indeed have a day/night cycle, but I have not yet implemented any variation to go along with it (though I will); there's just so much to do for NPCs that I'm focusing entirely on crowd mechanics for cities first, THEN moving onto every other type of settlement, and then I'll come back and do things like day/night cycles, and then move onto tracking the important NPCs.

And yes, the entire game is, basically, a massive procedural puzzle! Umberto Eco remains a huge inspiration for a world full of secret texts, hidden meanings, etc...
Logged

Ultima Ratio Regum
Level 7
**


Game Studies Lecturer, "Ultima Ratio Regum" person


View Profile WWW
« Reply #650 on: July 11, 2015, 05:31:15 AM »

This week I’ve pretty much finished off crowd mechanics for cities. I’ve also been working on the lower tiers of clothing, and the middle-class clothing looks great, but the lower-class clothing needs some work to be aesthetically comparable to the upper/middle equivalents, so I’ll show that off in a future entry. Right now, though: crowd mechanics are done (or cities), and that’s what we’re going to talk about here.

Permissions (and Guards)

Each tile of the human-scale in the game now has a variable called only_allow – this lists the permissions required to enter that tile (if the list is empty, than anyone can enter it). For example, we might have (“Religion”, 25) which means that believers of the religion with the “25” id can enter it, (“Family”, 6), and so forth. Sometimes I’m sure these will overlap, though currently they do not. At the moment these restrictions exist on upper-class mansions (where only that family and its allies can enter), warehouses in shop districts (so that random citizens don’t path towards them for no reason), religious buildings in religious districts (where only believers will enter them, though I suppose very occasionally someone from another hostile religion will…?), embassies in city centres (which are heavily guarded), and military districts per se. I’m sure some others will appear in the near future, but those are the only permissions in the city so far. As well as the existing crowd mechanics, I’ve also begun to write the code for guards who are tethered to a given permission, and are alerted if/when that permission is violated, and will act accordingly – but this isn’t a crowd mechanic, and isn’t finished, so we’ll talk about it more later. Here’s a simple example of a permissions diagram for an upper class district along with the outside of that district, where the areas inside walls for each of the major families is blocked for any outside that family (I will be adding in “lesser families” this release and giving them appropriately less-impressive crests). It’s simple, but effective (the other houses around the edge are wealthy, but not wealthy enough to merit guards, “territory” in the district, etc).





Irrelevant and Branching Roads

The NPCs on roads now avoid (for the most part) roads which go nowhere, and if they do go down a road which goes nowhere, they know that and will generally branch off and move towards their own target outside the road system. Equally, NPCs will no longer run in circles sometimes (a major improvement, as I’m sure you’ll all agree) and won’t branch onto tiny pieces of road. They can also cross each other intelligently without losing their sense of direction – in an earlier version two NPCs walking around each other would sometimes get “diverted” by the act of stepping around each other and wind up changing direction. Many of these irrelevant roads are also connected to permission-based areas as in the above section, and this is obviously a system I’ll be developing in more depth in the future as NPC/player relationships and factions become more complex. So this is the district from the above diagrams, where the light green roads can be walked by anyone, and the dark green roads either cannot be walked, or will only be walked by those with appropriate permissions or pathfinding objectives:



Moving Off-Road and On-Road

As above, NPCs can now sometimes decide to move off the road to find their own targets. They’ll do this if they see themselves approaching a dead-end road, and they’ll sometimes do this anyway regardless of what kind of road they’re on. In these circumstances they either select a region of the map where there is nothing in particular and path to there, and then continue pathing from there to elsewhere if the player is still viewing them (or despawn if they’re out of sight), or they will choose to path towards a specific door (which they have permission to enter) and then go through that door. As the below gif hopefully shows, this makes the movement of NPCs appear far more organic and stops NPCs looking like creatures just being channeled down the road with no ability for doing their own thing. We’ll obviously see how this works once we introduce important NPCs who have their own non-crowd objectives, etc, but you can see it pretty well in the gif in the section below…

Crowd Generation

The game can now generate appropriate “crowds” who might move around. For example, a civilization with the “Theocracy” and “Vassalage” ideologies might decide to have priests moving around their city, escorted by priests. A civilization with the “Monastic” (new to this release) and “Conscription” ideologies might enlist conscripts to escort high-ranking monks safely. Equally, there are some more general groups – groups of clerks and diplomats in the city centre, groups of general humans in any area, etc – who can also spawn in any nation regardless of their ideological preferences. Here’s an example of a priest and a few general citizen followers moving around a district – one will also note that certain skin tones are surprisingly hard to see against the road’s background colour. On the one hand, all roguelikes which expand their colour schemes a little bit (e.g. DF, CoQ, etc) will sometimes have certain colours which can’t be combined well, and whilst it’s annoying I’m not sure if there’s a solution; but on the other hand, maybe there is some solution? Change the road colour to make it more grey so it always stands out against all skin tones? I’ll ponder it. Either way, this gif starts with a priest (‘p’) being escorted by a bunch of soldiers (‘5′) moving around the corner around this religious building. I then just let it play on a little longer to see the slaves (since this is a slaving nation) wandering about. Note also that the game ensures the priest is “leading” the little convoy, since i had some problems with the leader’s escorts dancing around in front of the leader due to a quirk in the pathfinding system. Enjoy!



“Party” Generation

I’ve also implemented a system where “parties” (in the “group” sense of that word) can spawn more organically around certain areas – these include parks and gardens, around taverns, around markets, and in graveyards. In this case a number of NPCs from all over the map will path towards the area and then basically “hang around” for a while, before then making their way off. I’ve found around some places it gives an interesting feeling to these areas when you just sit and watch, and although I’m still working on exactly balancing the algorithm so that the ebb and flow of NPCs is exactly how I want it, this gif from a city centre garden is *fairly* illustrative, though it still needs some tweaking. And bear in mind, of course, one isn’t generally going to be waiting around to see the grounds form and un-form, but I’ve just stood here for this example so we could see groups forming, growing, and then disbanding.



District Demographics

I’ve also implemented a system for spawning appropriate demographics of NPCs (and their clothes, items, etc) for each NPC who spawns in each district. This comes down to three things: NPC type, NPC wealth, and NPC “distance”. To explain this slightly better, let’s have a look at this diagram, newly added to the in-game Guidebook (‘?’ to access). This is (currently) the full set of possible NPC types which will be able to spawn in the game:



So, NPC type is the “class” of NPC – we might want general humans to be spawning in lower-class housing districts, classes of soldier to spawn in the military districts (who I intend to give patrol routes to, but that hasn’t been coded yet), clerks and diplomats might be spawning in the city centre, and so forth. Capital letter NPCs will be specially tracked by the game, whereas lower-case NPCs make up the crowd. Also, nations which keep slaves will spawn slaves in the appropriate districts, just as nations which have eunuchs will spawn a very small number of those unfortunate individuals around the place. NPC wealth, meanwhile, means currently the quality of their clothing (and, in the future, the quality of any armour, weapons, bodyguards, jewelry, etc) – this is obviously closely tied to the district that the crowd NPC is spawning in, but with some variation. Middle-class districts spawn mostly middle and a few lower wealth NPCs, lower-class districts do the reverse, markets spawn an even mix, and so on. NPC distance, lastly, relates to whether the NPC spawning is from that nation and from its capital; from that nation and from a distant town or colony; or from a different nation altogether. Currently everyone who walks around in a city is from that nation (though I will of course later add groups from other nations) but might be from different regions, so you’ll see people who are culturally similar – clothing, hair style, etc – but physically different (skin tone, hair colour, eye colour, etc) as they come from different areas of the same nation. The game picks all of these according to a range of factors, and then spawns a mix of NPCs appropriate for the crowd in a given nation.

Bugs and Issues

In this process I ran into a bunch of bugs and issues. Firstly, for some reason, saving and loading the game would cause the AI for each NPC in the crowd, and the NPC itself, to become disconnected so they no longer referred to each other, meaning that when I tried to delete “self” from the list of NPCs when a given NPC no longer needed to be around, it couldn’t find self, and crashed. Weird. I tried to find a proper solution to this issue, but in the end I just changed it so that the scheduler only referenced the .npcid of each NPC, rather than the NPC itself, and that meant that even if some byte somewhere in the AI changed itself in saving/loading for reasons I could not divine, the npcid was always remaining the same (being a variable, not an instance of the AI class attached to an instance of the NPC class), and so the game could always identify the correct NPC and AI to delete upon reloading. Similarly, moving on the human-scale from district to district made some weird errors like massive groups of NPC suddenly spawning and NPCs from the next map tile teleporting into another map tile, but those were all quickly fixed. Some maps were also coming up with extremely rare tiles which didn’t have a .roadmarker variable, which denotes what NPCs are/aren’t allowed on it and whether it is a road curve which should be treated specially, but that was due to another bug I hadn’t even noticed involving the types of terrain spawning under trees (we had some trees spawning on road tiles!). This has all been sorted, and it all runs extremely smoothly. Additionally I noticed some unnecessary variables were still stored on every tile in the human-scale maps, so those have been removed, and save files have been reduced by around 15% as a result, with an attendant (very minor) improvement in load times!

Next up?

Well, the next things to do are to extend this outside cities. I need to get NPCs behaving sensibly in slums, graveyards, villages, fortresses and tribal settlements, each of which is going to need some unique changes to the algorithms I’ve worked on for cities. After that, we’ll be moving onto handling NPCs within buildings (and entering/leaving buildings), which is obviously extremely imporant. Then we’ll be moving onto unique NPCs who are specially tracked by the game because they matter (merchants in shops, rulers, nobles, etc) and who therefore need to be able to move around the world. These three steps are my three primary goals for the rest of July (it’s a lot, but I think I can crunch it), then in August I’ll be moving onto finishing off clothing styles (we’ve got feudal clothing almost finished, but I need to add military clothing, religious clothing, nomadic clothing, and tribal clothing, so there’s still a ton to do on that front!) and adding in a conversation system to the game. This system is going to be essential, so I really need to think hard about how the conversation system should work, what the balance is between the hand-made and procedural, etc. Then I need to redo how families and allegiances/associations work, fix a bunch of minor bugs from the last few versions which continue to stack up, and then 0.8 will (amazingly) be pretty much done. Aiming for a September release currently, which is around the time I’ll be starting a new job I can’t yet formally announce, and probably starting work on the other secret project I also can’t yet announce (both game-related, though!). Exciting times! Let me know what you think of this week’s development, and I’ll see you all in seven days…
Logged

Ultima Ratio Regum
Level 7
**


Game Studies Lecturer, "Ultima Ratio Regum" person


View Profile WWW
« Reply #651 on: July 19, 2015, 02:26:07 AM »

Very busy week and relatively little to show on the URR front (and off to Vienna for another talk tomorrow), so here's a post I wrote about my experience with the rather unusual "Syncself" game/interactive video:

http://www.ultimaratioregum.co.uk/game/2015/07/18/focus-syncself-and-gaming-feedback/
Logged

Ultima Ratio Regum
Level 7
**


Game Studies Lecturer, "Ultima Ratio Regum" person


View Profile WWW
« Reply #652 on: July 27, 2015, 04:36:42 AM »

Well, it has been another very busy week – I gave a talk on URR’s PCG and AI systems at nucl.ai in Vienna (and spent an afternoon sitting the sun outside a rather nice vegan cafe working on the secret project I’ve mentioned a few times, which continues to inch closer to the point where I can actually announce something) and I’ve also had a piece the 35th Anniversary of Rogue published in Paste Magazine (which you can read at http://www.pastemagazine.com/articles/2015/07/before-spelunky-and-ftl-there-was-only-ascii.html) and another on the role of text and characters in classic roguelikes published in Imaginary Realities (http://journal.imaginary-realities.com/volume-07/issue-03/how-integral-are-letters-and-text-to-ascii-gaming/index.html), but nevertheless significant progress has been made (though I anticipate this next week to be a full week of coding with nothing else, so we should have a major update in seven days).

Towns, Fortresses, Etc

NPCs can now pathfind sensibly around other places which aren’t city districts – they know where to spawn and how to behave in the crowd in fortresses, in towns, in slums, and also in hunter-gatherer encampments. In these cases they generally don’t use the roads, because having people pathfind on a road until they get close to their target, and then move off the road, magnifies pathfinding complexity immensely – what if they get near the target, but then the actual path from the end of the road to the target is long due to a wall (so they are physically proximate but the path to that proximate location is huge), and the complexity of the problem of making sure they take an efficient road path, followed by an efficient off-road path, is massive – so we’re ignoring it. Besides, particularly in towns I think this actually works quite effectively when roads look more like a form of aesthetic/spatial structuring of the town rather than literally what everyone uses to walk around, and fortresses tend not to have roads anyway unless there’s a river cutting through them. The right groups of NPCs now spawn in fortesses and elsewhere, of course, so we see lots of soldiers in fortresses, the poorest of the poor in slums, ordinary citizens in towns, and tribal peoples in hunter-gatherer territories. This is, however, making it clear that I need to return to clothing generation at some point soon and really get moving on the other algorithms for lower/middle class feudal clothing, and other clothing types too – it’s a huge job, and actually bigger than I thought, so I’m going to devote a solid week or two to that once I’m back from GDC Europe (if you’re there, come along to my talk!). Here’s a town brimming with activity:



Inside/Outside

The big one – NPCs now actually go inside buildings (they previously despawned at the door, in essence) and if you then go into the building, you can then see that same NPC inside the building. If the building has already been spawned and exists, then the NPC will go about their business inside the building. Alternatively, if the building hasn’t yet been spawned, they are temporarily placed in “limbo” until one of two things happens. If the building is spawned (i.e. by the player stepping inside), then that NPC is granted a number of turns to move around in the building as if they had been moving around inside the whole time. Alternatively, if an NPC has “entered” a building that the player doesn’t spawn, then after a random length of time they will the leave the building and continue on their way. In this method we are left with no pointless NPCs milling around in “limbo”, ensures that the crowd is always centered on the player, and means that if you see NPCs going into a building, they will be inside. In this gif, an NPC has previously entered this tavern; we’ll now enter, causing the building to spawn, and then the NPC spawns and we see them take a seat, and then if we go outside, they’ll exit again after a certain point (at the end we then see another NPC enter). This basically means that regardless of the player’s actions and which parts of the map actually exist, the crowd’s actions always appear to make sense. A similar system will be needed once I start tracking the important and non-spawned NPCs around the world (rulers, merchants, etc).



Inside Behaviour

NPCs will now create a list of potential “targets” within a building and will hang around at those targets for sensible amounts of time, and then when those timers end, they’ll either leave or go to something else within the building. This process depends on the building and the nature of a given target. For example, someone who goes into a tavern and sits on a chair to drink for a while will not then get up and move to another chair – they’ll either just stay on the chair, or get up and leave. By contrast, somebody in a cathedral might spend a lot of time sitting at one chair worshipping in front of an altar, then move to study the holy texts at a desk, then talk to a priest, then leave, etc. I’m working at the moment on finishing off this list of targets, and then also adding a second layer whereby the list of targets is modulated by the time of day; so people will tend to leave as its gets near night, or people in this houses will head to bed, etc. Here’s a gif of some inside behaviour in a tavern:



As you can see, more people currently leave than enter; I’m working on balancing these two algorithms at the moment so we have a steady flow of entering/leaving whatever structure the player might happen to be in at the time.

Sorry also about the relative lack of images this week: a huge amount of this week’s work has just been improving pathfinding, improving how NPCs move and behave, a lot of technical improvement on saving/loading and managing buildings and floors and buildings which are/aren’t spawned, etc, so there aren’t that many pictures to show. I hope for more next time!

What now?

Making the interior behaviour sensible and interesting for all NPCs, giving buildings a “maximum” number of people they can hold, adding day/night differences, fixing the massive number of edge cases which are slowly building up… etc. More next week!
Logged

EvilDingo
Level 1
*


View Profile WWW
« Reply #653 on: July 27, 2015, 05:03:24 AM »

Quote
In this process I ran into a bunch of bugs and issues. Firstly, for some reason, saving and loading the game would cause the AI for each NPC in the crowd, and the NPC itself, to become disconnected so they no longer referred to each other, meaning that when I tried to delete “self” from the list of NPCs when a given NPC no longer needed to be around, it couldn’t find self, and crashed. Weird.

The likely reason this is happening is because you're referencing the object of the NPC which, in object oriented programming, actually references the memory location of the object. When you serialize something to a file, the game will continue to keep the references properly. But if you close the game, open it, and deserialize the information, all of those memory references will be broken and end up as null reference exceptions (or the equivalent in your coding language.)

A way to fix this is, like you discovered, a stack variable id (like an int.) Querying objects in memory works like a charm until you try to serialize them. Then everything falls apart in weird ways.
Logged

RujiK
Level 2
**



View Profile
« Reply #654 on: July 27, 2015, 10:58:32 AM »

That interior generating stuff is pretty cool! Since NPC's can walk into a house before it's actually spawned, do you already know what type of house it is going to become? Otherwise it sounds like you may get 10 high class NPC's walking into a chicken barn or something weird since it wasn't spawned yet.


Optimizing pathfinding? Care to give an old nosy man any details? I assume you are using some form of A*.
Logged

Ultima Ratio Regum
Level 7
**


Game Studies Lecturer, "Ultima Ratio Regum" person


View Profile WWW
« Reply #655 on: August 01, 2015, 12:30:19 AM »

A way to fix this is, like you discovered, a stack variable id (like an int.) Querying objects in memory works like a charm until you try to serialize them. Then everything falls apart in weird ways.

Yeah, that was the issue, and sorted that out. People often seem surprised (your message didn't imply this, but I've had others which have) by how "little" I know about coding when I'm making a game like this. I guess that just comes from learning it from the ground-up, never having been formally taught, experimenting with it, and having a background as far away from Computer Science as possible. *shrugs*. Either way: the thing is fixed, and a nice juicy update is coming today.

That interior generating stuff is pretty cool! Since NPC's can walk into a house before it's actually spawned, do you already know what type of house it is going to become? Otherwise it sounds like you may get 10 high class NPC's walking into a chicken barn or something weird since it wasn't spawned yet.

Optimizing pathfinding? Care to give an old nosy man any details? I assume you are using some form of A*.

Thanks! Heh, yes indeed, a lot is fixed through both keywords and reference to macro-scale factors (cultures, religions, etc) before something generates, and then they're just held in limbo until it does generate (and if it never does, then they are "released" after a given point or deleted if/when the player wanders away). I do like the idea of the aristos wandering into a chicken barn, though.

Pathfinding: briefly, I use A* mostly, but also a number of other methods I've developed myself. There's basically several different algorithms in there now - "local pathfinding" which means choosing the optimal route to your path, "roadmap" which means moving intelligently along/down roads, "meandering" which is precisely what it sounds like, and then a few special cases for things like "group leader" and "group member" for crowds, and each NPC basically switches back and forth between them at reasonably opportune moments, finds their way around other NPCs in the way (generally...), and then there's some code to handle areas they aren't allowed to path through without having to recompute the pathfinding map for every single NPC, as that takes up CPU. Some of those use A*, some use my own code for "following" roads, etc.
Logged

Ultima Ratio Regum
Level 7
**


Game Studies Lecturer, "Ultima Ratio Regum" person


View Profile WWW
« Reply #656 on: August 01, 2015, 04:02:06 AM »

This week I’ve worked on some new graphics, on a lot of the AI for interior behaviour, made some alterations to a district generation system I wasn’t happy with, fixed various bugs and minor issues, and moved closer to the point where I can confidently say all crowd NPCs are working correctly. First, though, I must give my appreciation to one James Patton for this extremely kind and very thoughtful write-up (http://james-patton.net/2015/05/29/the-world-is-a-found-object-and-we-are-imperfect-archeologists/) – he has (or “you have”, if he’s reading this) hit the nail on the head with my objectives, my design philosophies, and basically everything else, and that’s always very gratifying to read. Also, if you fancy some other roguelikey reading, I’m building up quite a number of roguelike pieces – I wrote for KillScreen about the demonic enemies in NetHack (http://killscreendaily.com/articles/demonic-properties-ampersand/), for Paste Magazine about the 35th Anniversary of Rogue (http://www.pastemagazine.com/articles/2015/07/before-spelunky-and-ftl-there-was-only-ascii.html), and for Imaginary Realities about the role of text, characters and letters in roguelikes (and URR) (http://journal.imaginary-realities.com/volume-07/issue-03/how-integral-are-letters-and-text-to-ascii-gaming/index.html). Hope you enjoy giving them a read… and now, onto the update, which is rather more substantial than last week’s paltry offering:

Prayer Mats

I took a moment this week to do some graphics, and decided to finally implement something I’ve been meaning to for ages: prayer mats. Some religions now use prayer mats in their religious buildings instead of chairs, and the design of these mats is dependent on both the religion, and the civilization the religious building is found within (so religions across many nations will have similar, and aesthetically comparable, but slightly different, prayer mats across nations). The colour scheme is based on the altar, as shown in the three examples here, and the shapes (squares, octagons, etc) are down to the nation, whilst the specific layout of shapes and symbols, and obviously the religious symbols, are down to the religion. Here are some rather nice examples:



And some prayer mats in a religious building and a cathedral (note that the colour of the maps vary based on the actual mat colours, though now ‘=’ can’t be used for anything else!):





Further Interior Behaviour

This week I’ve done a lot more NPC interior behaviour. There is still a little bit which needs doing, particularly with special cases – NPCs going into banks should talk to the clerks, for instance, just as NPCs in hospitals should go and sit by the bed-side of someone they know, etc, but a lot of these actions are now working very nicely. In a cathedral, for instance, I just sat by and watched as NPCs came in and prayed at the altars, sat on the chairs/prayer mats, looked at the relics, admired the cathedral’s decoration, talked to one another, sat down to study the holy texts, etc. Here is an awesome gif of this which is neat enough to watch to the end, I think, of various people in this cathedral (the one above) doing these types of activities:



Next up was the gallery. As with all buildings, I’m leaving the “permanent” NPCs until last – so worshippers will wander around a cathedral, for example, but there are no priests there yet, as they will be tethered to that building and a particular routine – but here we now have people coming in, admiring the paintings, and showing themselves out again. Painting generation will happen when I swoop in and redo the history generation from the fairly simple system there is now, to something which truly encompasses every piece of information in the world, and begins to lay the foundations for sneaking in clues to the game’s central cultural cipher. Anyway, the gallery:



By the end of next week I hope to have more interior algorithms finished, and by the week after, they should all be done (this week is GDC Europe and Gamescom, and I’m attending 100% of the former and ~25% of the latter, so that’ll be taking up a bunch of time). At this point I’ve implemented some general code for all buildings, and now it’s a matter of going into every building and checking the code actually works there.

Middle-Class Rivers

I suddenly noticed that under the new generation algorithm for middle-class districts, when a river goes through them, they don’t look very impressive at all, and we end up with something like this (with the issues ringed in red where multiple “bridges” seem to overlap:



This wouldn’t do, and it just looks rather dull, so I rewrote this algorithm into producing something rather more interesting, so here’s the same district using this new algorithm which encourages the river to flow around/past major roads, avoid smaller ones, and to then design the rest of the roads differently and place buildings/parks a little differently in order to accommodate the river. Here are two examples with a “corner” river and a “long” river, from the same city (note that the shapes of the corners and the roads sometimes change – I set it to randomize that aesthetic choice each time I generated an area so I could make sure the new system always worked):





Other Small Changes

A number of other minor changes have also been implemented this week:

– Colonies can now only be established with nations with the “Imperialist” ideology, rather than all nations which are not “Isolationist” (which it was until now).

–  An extremely unlikely edge case involving rivers and lower-class district generation has been fixed, ensuring you never end up with a part of a district that cannot be accessed without entering the district from another angle, due to the river’s location. See below:



– Each NPC’s face is now tinted fractionally to add further diversity within nations – everyone’s faces are tinted a tiny bit (between 0.03 and 0.06%) towards yellow, orange, red, white or black at random. That might sound tiny, but the difference is noticeable.

– Roads are now grey merged with just the tiniest bit of brown, and all skin-tones are now very easy to read on it. However, others do struggle on the “soil” terrain type, so I’ll fiddle with that too (probably make it a little more green, perhaps). Equally, chairs are made out of wood – with colours that range from light brown to dark brown – and therefore chairs, in some cities, do tend to blend a little with the populous. Again, considering solutions, but I might tint everyone’s skin tone a fraction to the red.

– Fixed a thrilling bug where chairs sometimes decided to spawn in the empty void of nothingness outside the map… and then NPCs wanted to sit on them.

Next Week

As above, I’m flying out tomorrow and returning in a week, and I’ll be doing lots of GDC stuff. So… expect either a shorter update, or a non-URR update, depending on how things go. See you then!
Logged

failrate
Level 1
*



View Profile WWW
« Reply #657 on: August 01, 2015, 06:42:02 AM »

Are you going to consider congregations of NPCs?  While people sometimes use religious buildings randomly, they usually use them regularly and at the same time/day as other people in their religion.  This also holds true for hangings, festivals, markets, etc.
Logged
Ultima Ratio Regum
Level 7
**


Game Studies Lecturer, "Ultima Ratio Regum" person


View Profile WWW
« Reply #658 on: August 01, 2015, 10:46:25 PM »

Are you going to consider congregations of NPCs?  While people sometimes use religious buildings randomly, they usually use them regularly and at the same time/day as other people in their religion.  This also holds true for hangings, festivals, markets, etc.

Oh yes, but that's another layer. First I'm doing "ambient" NPCs who wander around. Then I'll be doing NPCs who are tethered to a particular location (guards outside mansions, priests in religious buildings, etc). Then it'll be "special" ambient NPCs, like worshipers appearing at a certain time, groups going into areans when there's a fight on, etc; then it'll be the important NPCs being tracked on the global level.
Logged

failrate
Level 1
*



View Profile WWW
« Reply #659 on: August 02, 2015, 12:33:48 AM »

I'm glad you've already considered this.  Even a "No, it is out of scope" would be better than nothing.  Keep up the good work!
Logged
Pages: 1 ... 31 32 [33] 34 35 ... 53
Print
Jump to:  

Theme orange-lt created by panic