Arcen Games

General Category => AI War II => Private Alpha Discussion => : BadgerBadger March 18, 2017, 02:03:43 PM

: Helping out with External Code
: BadgerBadger March 18, 2017, 02:03:43 PM
Hey Keith/Chris,
     I'm feeling bored today and I'm wondering if there are any small coding pieces that can exist purely in the Externally Moddable code that people in the community could write for you guys, on a purely volunteer basis.
: Re: Helping out with External Code
: keith.lamothe March 18, 2017, 02:17:17 PM
The main things that come to mind for helping with development itself are UI stuff (refinement of the existing, replacement of the existing, new bits entirely) and balance analysis/changes. Both of those are pretty much wide open in the external code. But neither of those is to the point where you wouldn't be subject to it all going poof fairly soon anyway.

The AI will also be exposed more in external code later, but not much of it is there yet.

There's also turret patterns, but that's largely based on balance and UI considerations.

So if you're bored I'd suggest adding a new map type based on some pattern or algorithm you find interesting. You could start with changing an existing one, and then move to creating a new one from scratch (probably by copying one and replacing the innards).

Thanks for your interest :)
: Re: Helping out with External Code
: BadgerBadger March 20, 2017, 04:53:08 PM
I will look into the map generation code as I get the chance.

Also, on another vein of helpfulness, if you have "interesting scenarios" that need to get checked out, feel free to request people to try things in particular. If we can get people in the forums to test things then there's no need for you to do it in person, given that your time is more valuable
: Re: Helping out with External Code
: BadgerBadger April 15, 2017, 12:59:23 AM
So I was actually poking around in the MapGenerator code, and I note that each IMapGenerator takes a "numberToSeed", which seems to be the number of planets. However, we don't have a means of controlling that from the start of the game, which makes it hard to experiment properly.

I would add a drop down menu or something to Window_GameSetup.cs for my testing purposes, but I don't see exactly how to pass that information along to the map generator. My guess is that you should be able to get that information into a WorldSetup object, but my attempts to disassemble ArcenAIW2Core.dll to see check the variable for that have failed. If I asked nicely, could you tell me the name of the value in WorldSetup to set to allow me to tweak the number of planets? Or is that not implemented yet.
: Re: Helping out with External Code
: keith.lamothe April 15, 2017, 09:34:38 PM
Setting planet count isn't supported yet. I'm trying to avoid multiplying balance variables until after there's a real balance to vary.
: Re: Helping out with External Code
: BadgerBadger April 15, 2017, 10:33:35 PM
You're totally right, but could I persuade you to put ina "NumberOfPlanetsOnMap" into WorldSetup for silly people like me so I don't have to hardcode my test values in? You don't have to put the gui elements in (so it won't confuse others), I already wrote that for myself before I realized that StartingPlanetIndex wasn't what I was hoping it might be.
: Re: Helping out with External Code
: tadrinth April 24, 2017, 05:16:15 PM
*Goes to code for Encapsulated and changes rim planet percentage param from 0.40 to 0.25*

I always thought Encapsulated maps would be more interesting if the rim acted more like a superhighway with very few nodes. Now I can try that out!

As soon as I put Visual Studio on my desktop so I can compile the external code project, anyway. 
: Re: Helping out with External Code
: tadrinth April 25, 2017, 01:18:38 PM
So I was actually poking around in the MapGenerator code, and I note that each IMapGenerator takes a "numberToSeed", which seems to be the number of planets. However, we don't have a means of controlling that from the start of the game, which makes it hard to experiment properly.

In the map generator methods, you can just assign whatever value you want to numberToSeed.  You can even generate a random number of planets by using Context.QualityRandom.  That way, you can randomize the seed repeatedly in-game and see the different results.
: Re: Helping out with External Code
: BadgerBadger April 25, 2017, 01:28:58 PM
You are right, but I have to close the program, then edit my code, then recompile it every time. It's inefficient.
: Re: Helping out with External Code
: BadgerBadger April 29, 2017, 08:53:43 PM
Hey Keith/Chris! I managed to create a planet style that I think feels pretty cool. It's trying to feel like "solar systems ultra-lite", where we have planets on a ring, each orbited by a few other planets. You have to go via the central planet of each ring to get to the ring of planets, so for people who like choke points it should work well.

If you guys would like to include it in the base game you'd be welcome, I'll happily send you the code (or take feedback). I learned a bunch about how the MapGeneration code works, so if any other aspiring modders wants to poke around in there and doesn't want to bug Keith, feel free to give me a holler.

: Re: Helping out with External Code
: keith.lamothe April 29, 2017, 10:07:32 PM
Neat :)

An interesting refinement would be to have each cluster connect to its two neighbors by the two closest planets instead of center to center. as a lack of line-overlap generally seems to be more pleasing visually, and I think it would be more interesting strategically though center-to-center has its own points there.

And a variant could add a second "ring" of clusters closer to the center of the map, but there's only a few of them, each connecting to cluster N and N+2 in the outer ring (and possibly to other inner-ring ones, not sure if that would be an improvement).

A further variant would be to add a central cluster that connects to each of the inner-ring clusters.

Though it's hard to have that many clusters without a higher than normal planet-count (120 was tops in AIWC), I imagine.
: Re: Helping out with External Code
: BadgerBadger April 29, 2017, 10:19:08 PM
Thanks for the feedback! I shall give them a try and see how it goes.
: Re: Helping out with External Code
: z99-_ April 30, 2017, 11:24:03 AM
Hey Keith/Chris! I managed to create a planet style that I think feels pretty cool. It's trying to feel like "solar systems ultra-lite", where we have planets on a ring, each orbited by a few other planets. You have to go via the central planet of each ring to get to the ring of planets, so for people who like choke points it should work well.

If you guys would like to include it in the base game you'd be welcome, I'll happily send you the code (or take feedback). I learned a bunch about how the MapGeneration code works, so if any other aspiring modders wants to poke around in there and doesn't want to bug Keith, feel free to give me a holler.

This is really cool! Being in a circle, it's like a mini galaxy - which means we need a black hole at the center >D

Seriously though, if one of the more computer savvy Arcenites could figure out a way to put in star models in the center pieces, and maybe change the color of the wormhole lines connecting different solar systems, this could be a BIG addition to the game (I think)

The only question would be to what extent can we change AI behavior based off of planets having certain properties (to bring back the full solar system concept) ...
: Re: Helping out with External Code
: BadgerBadger April 30, 2017, 11:03:32 PM
So the first design was a ring of planets, and each ring had a smaller ring of planets around it (in solar system terms, a ring of suns, each with planets). While trying to make it more visually pleasing, I realized that if I took the main ring of suns and moved that into the center, this is topologically identical to my first design. So take a look at this; it's still essentially the same "solar system lite", with the only communication between the solar systems being through the set of suns, but it is much more pleasing to the eye.

Thoughts?

: Re: Helping out with External Code
: Draco18s May 01, 2017, 12:02:39 AM
That actually looks like a rather interesting layout!
: Re: Helping out with External Code
: keith.lamothe May 01, 2017, 07:59:06 AM
That does look like a much clearer way to do the sun-to-sun pattern :) Reminds me of the X pattern in terms of strategic implications, but I think I like this more than X.
: Re: Helping out with External Code
: BadgerBadger May 01, 2017, 02:11:38 PM
Thanks! I'm glad to see people seem to like it so far. There are still some tweaks left, so I'll be posting more pictures later (for example, my code doesn't scale up nicely to 120 planets).

I'm having some cool ideas for things that could be done with gameplay mods that are based on Map Types. A few brainstorming ideas:  "As soon as you leave an outer solar system and get to a planet in the inner ring, the Nemesis is unleashed from its home planet, which is at the very middle of the map. The Nemesis will attack anything that comes into the inner ring, but doesn't ever really go into the outer solar systems. However, if you go to the Nemesis' home planet and destroy a Magic Structure there, it will die permanently."

Another cool sort of thing would be "Each outer solar system has different types of guardians/defenses; one is heavy on MLRS, another uses Gravity, another uses lightning".

I'm not sure how possible this will be with the tools Keith can provide for us though, but a badger can dream!
: Re: Helping out with External Code
: BadgerBadger May 05, 2017, 10:53:34 PM
Quick question: Are there any bad side effects of calling "using System.Threading" in MapGeneration.cs? I'm considering trying an interesting map that might be computationally expensive, and want to make sure a threading implementation would work if I can't make the algorithm < O((n/2)!)
: Re: Helping out with External Code
: keith.lamothe May 06, 2017, 07:49:28 AM
Quick question: Are there any bad side effects of calling "using System.Threading" in MapGeneration.cs? I'm considering trying an interesting map that might be computationally expensive, and want to make sure a threading implementation would work if I can't make the algorithm < O((n/2)!)
The "Travelling Salesman" map type, eh? ;) Or using a force-driven untangling algorithm?

There's no inherent problem with multithreading the mapgen, but you'll need to make sure that the result is 100% deterministic based on the seed or it will break multiplayer (as well as violating the customary semantics of having a map seed). That generally means that either each thread gets its own random generator or only one thread does random generations. And of course you need to avoid more mundane race-conditions and non-determinacies.

Bear in mind that mapgen already happens on its own thread, so you don't have to worry about the screen freezing during the generation or whatever.
: Re: Helping out with External Code
: BadgerBadger May 07, 2017, 10:22:26 AM
So I dug out my old Graph Theory notes, because I thought that implementing a few graph theory algorithms might lead to interesting maps. Here's a map style constructed by scattering points at random across a circle centered on GalaxyCenter, then using Prim's algorithm to construct a minimum spanning tree. I think this looks pretty cool!
: Re: Helping out with External Code
: z99-_ May 07, 2017, 11:38:53 AM
So I dug out my old Graph Theory notes, because I thought that implementing a few graph theory algorithms might lead to interesting maps. Here's a map style constructed by scattering points at random across a circle centered on GalaxyCenter, then using Prim's algorithm to construct a minimum spanning tree. I think this looks pretty cool!

If I ever had any doubt that modding was worth the amount of time Chris and Keith have been putting into it, I can say they are now gone. Just glancing at it, I wouldn't be surprised if this ends up becoming my new favorite map type. :D I'm curious, how long did it take you to make this?

And do you have other awesome map types planned? :D
: Re: Helping out with External Code
: Draco18s May 07, 2017, 12:19:10 PM
So I dug out my old Graph Theory notes, because I thought that implementing a few graph theory algorithms might lead to interesting maps. Here's a map style constructed by scattering points at random across a circle centered on GalaxyCenter, then using Prim's algorithm to construct a minimum spanning tree. I think this looks pretty cool!

Looks cool, but it would be hell to play. It's basically an X map.

Now, if you added in extra linkages at random, you'd get some good connectivity.
: Re: Helping out with External Code
: BadgerBadger May 07, 2017, 02:40:18 PM
Yeah, it is pretty similar to an X, though it's got a more organic feel to it. I'll look into adding some extra linkages though.
: Re: Helping out with External Code
: z99-_ May 07, 2017, 04:11:40 PM
Looks cool, but it would be hell to play. It's basically an X map.

That depends on your playstyle. For a conquer-the-galaxy player (like myself) the many chokepoints and branching paths are a huge advantage.

It would be really interesting if some nomad planets were added to this map. That would certainly spicen things up  >D
: Re: Helping out with External Code
: keith.lamothe May 07, 2017, 04:28:11 PM
Don't some of the maze types use prim?
: Re: Helping out with External Code
: BadgerBadger May 07, 2017, 05:09:09 PM
@Keith, The Maze code uses an interesting set of backtrackings which seemed a bit daunting, so I never put much effort into grokking that code. It might use Prim's, though Prim's requires you to check distances, and I don't see obviously where you are doing so.  I found Concentric and Wheel to be a better source of coding inspiration, so I mostly taught myself using those.

@z99, coding this one wasn't too hard; think "First coding project for a 200 level graph theory course/comp sci course". The single hardest part of creating maps was making my very first one (it was 10 planets in a line), because I just wasn't sure how all the pieces worked yet.  Once the MapGen code has totally stabilized I will post my notes and write up a toy map generator with lots of comments (on the wiki, probably) so that it will be easier for anyone else. I also have more cool ideas for map types, just wait and see!

@Keith, I can see a number of useful ways someone could want to tune a map to their playstyle. For example, the Spanning tree one I just posted immediately had two opinions as to whether it was good as is, or whether it should have more random linkages. Since I don't expect most people will want to futz about in the C#, my thought is I could have a "Spanning" and a "Spanning with links" map type, but it might be easier if a given map type would expose some tunables for it that could be set by the user in the Map Selection Screen.
: Re: Helping out with External Code
: Draco18s May 08, 2017, 12:23:26 AM
So the way I added extra links in a project I was working on was to generate the MST and then randomly pick a node, from its list of neighbors* remove the ones its already connected to, then from the rest remove any that are already connected to any neighbor we already removed.  This results in loops that are at least 4 nodes in size (because we removed all 3-node hops by excluding any neighbor connected to a connected neighbor).

And you only need around 5-10% of the tree to gain an extra link for it to have sufficient alternate routes.

*Presumably you did a Delaney triangulation prior to MST-ing.
: Re: Helping out with External Code
: BadgerBadger May 08, 2017, 12:19:55 PM
@Draco, I tried out adding connections to the MST "randomly" but it did not give good results. Then I tried your idea (tracking nearest X neighbors, and only linking points that are sufficiently distant) and I really like it. My code now has flags for "How many random connections to add to the MST" and "How many jumps away must two planets be to consider linking them".

Opinions?
: Re: Helping out with External Code
: keith.lamothe May 08, 2017, 12:23:52 PM
Nice :)

I suggest only linking planets where the resulting connection does not overlap another connection (you can call GetWouldLinkCrossOverOtherPlanets( Planet First, Planet Second ) to check for that). Much more visually pleasing and understandable, though of course certain map types benefit from the extra flexibility.

: Re: Helping out with External Code
: BadgerBadger May 08, 2017, 12:53:16 PM
I have done so, but it doesn't seem to work (maybe I'm misusing it?); observe that the connection between Lehman and Orillia on the right overlaps with another connection.

Here is a map, and here is a code snippet that is used when generating the map.
I know there won't be overlaps from just the spanning tree, so these overlaps have to come
from the random connections code, but the random connections code uses your GetWouldLinkCrossOverOtherPlanets function.

            //Two potential planets are selected for random connections (neither has                                                                                                                                                                                                                                          
            //a random connection yet)                                                                                                                                                                                                                                                                                       
            //Lets make sure a link there does not cause any overlap in lines                                                                                                                                                                                                                                                 
            Planet firstPlanet = planetsForMap[firstPlanetIdx];                                                                                                                                                                                                                                                               
            Planet secondPlanet = planetsForMap[secondPlanetIdx];                                                                                                                                                                                                                                                             
            bool wouldLinkCrossOtherPlanets = UtilityMethods.GetWouldLinkCrossOverOtherPlanets(firstPlanet, secondPlanet);                                                                                                                                                                                                   
            if(wouldLinkCrossOtherPlanets)                                                                                                                                                                                                                                                                                   
              {                                                                                                                                                                                                                                                                                                               
                i--; //discard this pair, since there's an overlap                                                                                                                                                                                                                                                           
              }                                                                                                                                                                                                                                                                                                               
            else                                                                                                                                                                                                                                                                                                             
              {                                                                                                                                                                                                                                                                                                               
                firstPlanet.AddLinkTo(secondPlanet);                                                                                                                                                                                                                                                                         
                usedPlanetsForConnections.Add(firstPlanetIdx);                                                                                                                                                                                                                                                               
                usedPlanetsForConnections.Add(secondPlanetIdx);                                                                                                                                                                                                                                                               
              }                                                                                                                                                                                                                                                                                                               


When I look at your code, I see

                if ( Mat.LineIntersectsRectangleContainingCircle( First.GalaxyLocation, Second.GalaxyLocation,
                                                                                         planetToNotHit.GalaxyLocation,
                                                                                         planetToNotHit.TypeData.IntraStellarRadius ) )                                                                                                                                 


It looks like this says "Make sure the ensuing line does not intersect a planet body, not a connection", but I could easily be misreading this (I can't see the Mat class to check).(http://)
: Re: Helping out with External Code
: keith.lamothe May 08, 2017, 01:06:09 PM
Oh, right. Duh, sorry, didn't read my own method name there ;)

I was sure I was doing some kind of link-crossover prevention but I can't find any code in there that does so.

You could use Mat.LineSegmentIntersectsLineSegment to check for it, though.
: Re: Helping out with External Code
: BadgerBadger May 08, 2017, 01:08:25 PM
What arguments does that function take? My copy of MapGeneration.cs doesn't have any references to it.
: Re: Helping out with External Code
: Draco18s May 08, 2017, 01:13:47 PM
Oh yes. I meant random connections to nearby systems, not pure random anywhere.

That screen shot is almost prefect except for the crossing path, as noted. A Delaney triangulation would also solve that, as each system would only be connected to other systems in a flat network to begin with (impossible to form crossings) and then MST that (the MST from a Delaney triangle mesh will always be the MST performed any other way, due to the mechanics of the triangulation).

But yeah, you can get "closer enough" only looking at X nearest.
: Re: Helping out with External Code
: keith.lamothe May 08, 2017, 01:27:42 PM
What arguments does that function take? My copy of MapGeneration.cs doesn't have any references to it.
Sorry, I figured you were using visual studio and it would give you intellisense. What are you using to code?

Signature on that one is:

bool LineSegmentIntersectsLineSegment( ArcenPoint Segment1_P1, ArcenPoint Segment1_P2, ArcenPoint Segment2_P1, ArcenPoint Segment2_P2, int ConsiderIntersectingIfWithinThisDistance );

It's possible that you'll need to make the line segments a little shorter on each end to avoid colliding with the links each planet already has (because they all meet at the middle of the planet).
: Re: Helping out with External Code
: BadgerBadger May 08, 2017, 01:33:13 PM
I'm using Emacs. Does VisualStudio let you see the function headers and so on from things that are only in DLLs? I've been using a combination of guesswork and disassembling the DLLs to check variable/function names when necessary, which is not exactly the most efficient thing in the world ;-) . For example, it's less intuitive to figure out what

      IL_005f:  call       bool [ArcenUniversal]Arcen.Universal.Mat::LineSegmentIntersectsLineSegment(valuetype [ArcenUniversal]Arcen.Universal.ArcenPoint,
                                                                                                      valuetype [ArcenUniversal]Arcen.Universal.ArcenPoint,
                                                                                                      valuetype [ArcenUniversal]Arcen.Universal.ArcenPoint,
                                                                                                      valuetype [ArcenUniversal]Arcen.Universal.ArcenPoint,
                                                                                                      int32)

means than to just ask you
: Re: Helping out with External Code
: Draco18s May 08, 2017, 01:36:55 PM
I'm using Emacs. Does VisualStudio let you see the function headers and so on from things that are only in DLLs?

It super depends. In this case, probably yes.
In the work job I have now, there's a c# wrapper around a c++ dll, and the intellisense only works on the wrapper (the linkages to the c++ are handled via magic strings).
: Re: Helping out with External Code
: keith.lamothe May 08, 2017, 02:12:43 PM
Does VisualStudio let you see the function headers and so on from things that are only in DLLs?
Yep. Actually in my external code project I'm just using AIW2Core as a dll same as you are. Go-to-definition opens up the metadata for the class in question. And intellisense uses it correctly.

I mean, use whatever you like, but visual studio community edition is free to use. There's also https://code.visualstudio.com/download if you're on linux, but I don't know how it compares to the community edition.
: Re: Helping out with External Code
: BadgerBadger May 08, 2017, 02:37:43 PM
Okay, how does this one look? The number of random connections is easily tunable (I have it set to 4 right now)

: Re: Helping out with External Code
: Draco18s May 08, 2017, 05:56:39 PM
Looks pretty good to me. I might shift a few around, but that's mostly my sense of esthetics die to where the labels are (i.e not anything map get SHOULD worry about)
: Re: Helping out with External Code
: BadgerBadger May 08, 2017, 06:05:22 PM
It's all randomly generated, so feel free to hit "New Seed" ;-). I'm glad you like it though! It definitely adds something to the original (though I could imagine wanting to play the original map as well).

I also have two(!) new maps to offer. The first is a Gabriel Graph (which I think is also how some of the Clustering code works, but this is different because it's an entire graph done this way), the second is a Relative Neighbor Graph. These two examples are generated on the same set of planets, but will play very differently with the different map styles. I think they are both pretty cool.
: Re: Helping out with External Code
: keith.lamothe May 08, 2017, 06:11:23 PM
The Relative Neighbor Graph looks especially cool. It's a lot like AIWC's "Simple" but with a more pleasing arrangement.

And yes, the names often float way out at a not-good place (closer to some other planet, etc). I'm sure that will be tightened up in some manner.
: Re: Helping out with External Code
: Draco18s May 08, 2017, 07:09:26 PM
Gabriel looks really close to what a full Delaney triangulation would look like (particularly towards the center). Took me a moment to realize it was not fully connected.

Definitely like the relative neighbor one too.

Edit, for Keith:
Awe man, I just had an Awesome idea. So when I was doing some map-gen stuff for that stealth game I have on the back burner, one of the things was having "backdoor" routes that created linkages from room to room that were less planned (it was a "pick two rooms that aren't connected, they can be anywhere, do a brute-force search towards the destination: if at any point you dead-end with no reasonable method of placing a further passage, terminate and consider that the linkage instead).

So. The idea I had for AIW2 was having some kind of building/capturable/hackable node that would act as a long-distance warp gate that would provide linkages between planets that doesn't use the galaxy map linkages. They'd be predetermined and fixed, go in one side, come out the other, just like a wormhole only they'd be backdoor-y.
: Re: Helping out with External Code
: Toranth May 08, 2017, 07:57:45 PM
Edit, for Keith:
Awe man, I just had an Awesome idea. So when I was doing some map-gen stuff for that stealth game I have on the back burner, one of the things was having "backdoor" routes that created linkages from room to room that were less planned (it was a "pick two rooms that aren't connected, they can be anywhere, do a brute-force search towards the destination: if at any point you dead-end with no reasonable method of placing a further passage, terminate and consider that the linkage instead).

So. The idea I had for AIW2 was having some kind of building/capturable/hackable node that would act as a long-distance warp gate that would provide linkages between planets that doesn't use the galaxy map linkages. They'd be predetermined and fixed, go in one side, come out the other, just like a wormhole only they'd be backdoor-y.
I haven't gotten into modding yet, but are the wormholes objects that can be modded/have functions and such attached to them?  This would support a lot of interesting ideas, from Draco's buildable backdoors, to one-way links, to moving wormholes, to temporary wormholes, to wormholes with sizes limits...
: Re: Helping out with External Code
: keith.lamothe May 08, 2017, 08:02:41 PM
I haven't gotten into modding yet, but are the wormholes objects that can be modded/have functions and such attached to them?  This would support a lot of interesting ideas, from Draco's buildable backdoors, to one-way links, to moving wormholes, to temporary wormholes, to wormholes with sizes limits...
The wormhole traversal logic itself is in the core dll, but you could define other units that have the wormhole type. Depending on what you did you could run into problems, but temporary wormholes like the AIWC Nomads do should work.

Size limits and other "filters" are tricky for pathfinding purposes. But like all the other things in your list they could be done with some additional core dll work on my part. Whether they would lead to people pulling their hair out by the roots is a different question ;)
: Re: Helping out with External Code
: Draco18s May 08, 2017, 09:33:44 PM
Size limits and other "filters" are tricky for pathfinding purposes. But like all the other things in your list they could be done with some additional core dll work on my part. Whether they would lead to people pulling their hair out by the roots is a different question ;)

I figure if they're user-activated (i.e. not pathfinded normally) you'd get around most of those issues.
I'm thinking along the lines of how Achron handles the device that sends units back in time.
: Re: Helping out with External Code
: BadgerBadger May 08, 2017, 10:38:26 PM
I'm more concerned about a clean UI design to make the meanings clear. For example, if one-way wormholes become a thing, I feel like the connections in the Galaxy Map need to be descriptive (maybe a color gradient? Maybe with arrows?), and the Wormhole image itself should be tweaked.
: Re: Helping out with External Code
: keith.lamothe May 09, 2017, 08:06:29 AM
if one-way wormholes become a thing (...) the Wormhole image itself should be tweaked.
"Why does that icon look like a giant catapult?"

*THWONG!*

"Aieeeee!"

(Usability study, iteration 23, result: communicates necessary information almost quickly enough)
: Re: Helping out with External Code
: Draco18s May 09, 2017, 11:24:53 AM
If it floats like a duck, it must be a witch.
: Re: Helping out with External Code
: keith.lamothe May 09, 2017, 11:47:37 AM
If it floats like a duck, it must be a witch.
An icon of a crone with a pointy hat on a broom would be pretty funny. But an icon of a duck would be even better.

"Only traversible by ships equipped with a Mallard Drive"
: Re: Helping out with External Code
: BadgerBadger May 10, 2017, 08:21:08 PM
Okay, I've updated my Map Generators to handle the changes in .123. While I'm happy to just enjoy those maps myself, I'd like to share them with everyone else! I'm not sure how to do that best though. If you guys would like the code in the base game then I'm happy to send you the code and do a few rounds of cleanup to bring it up to your standards.
: Re: Helping out with External Code
: Dominus Arbitrationis May 11, 2017, 02:49:49 PM
Okay, I've updated my Map Generators to handle the changes in .123. While I'm happy to just enjoy those maps myself, I'd like to share them with everyone else! I'm not sure how to do that best though. If you guys would like the code in the base game then I'm happy to send you the code and do a few rounds of cleanup to bring it up to your standards.

I'd post the mod code for everyone, just in case Chris or Keith can't add it in for a bit that way others can still enjoy it. Plus, they can then integrate it and let you know what all cleanup is required.
: Re: Helping out with External Code
: BadgerBadger May 11, 2017, 02:57:57 PM
Cool, I'll try to upload a version of the code tonight.
: Re: Helping out with External Code
: BadgerBadger May 11, 2017, 09:18:25 PM
Alright, here you go! These are two files, an XML file which should be placed in GameData/Configuration/MapType, and a .cs file that should be placed in AIWarExternalCode/src. Recompile according to the instructions in https://wiki.arcengames.com/index.php?title=AI_War_2:Earlier_Than_Earlier_Alpha_Modding_Instructions. Note that you will have to tweak the .csproj to include MapGenerationBadger.cs.

The code is vaguely tidy and should be readable. This code implements 4 major map types; "Solar System Lite" (Circles from my original post), "Dreamcatcher" (a gabriel graph), "Simple" (Relative Neighbor Subgraph, in homage to AIWC) and "Constellation" (spanning tree).

There is also another included map type, "ExampleForAspiringModders" which I wrote for anyone else who wants to try their hand at this.  If you are interested in messing with the Map Generator code, please look at this example first. I promise it will make your life easier!

I'm happy to take suggestions or critique from anyone who wants to wade through it all. 
: Re: Helping out with External Code
: Draco18s May 11, 2017, 09:38:11 PM
That looks delightfully easy. Thanks Badger.
: Re: Helping out with External Code
: BadgerBadger May 14, 2017, 09:29:43 PM
Here's another interesting one (it's a mashup of the layout of solar system lite with a Gabriel graph, but I think it looks cool). Note you can't do this with the code I uploaded previously, but you will in a few days.
: Re: Helping out with External Code
: Draco18s May 14, 2017, 09:52:23 PM
Looks neat. A few overlapping connections, but they remain readable.
: Re: Helping out with External Code
: BadgerBadger May 14, 2017, 10:01:41 PM
Nice spotting, the overlaps were due to a bug. Here's a version w/o overlaps (and more planets, so it looks better).

: Re: Helping out with External Code
: Draco18s May 14, 2017, 11:12:46 PM
Very nice.
: Re: Helping out with External Code
: Draco18s May 16, 2017, 09:38:04 PM
Are there limits on the extents of the map?  I.e. what are the largest values you can plug in for a system's X/Y coordinates?
: Re: Helping out with External Code
: BadgerBadger May 16, 2017, 09:41:29 PM
You know, I haven't checked, given that maps that are too spread out don't feel appealing to me ("Man, how long do I have to scroll to find Murdoch?"). Go plug some values into the ExampleForAspiringModders ;-)
: Re: Helping out with External Code
: keith.lamothe May 16, 2017, 10:33:22 PM
I don't think there are any limits on the coordinates that you need to worry about (i.e. it's not infinity, but really). What you're more likely to run into is how far out you can zoom and possibly how far you can pan. Which could be made configurable if really necessary, but the info display won't work right past a certain zoom-out, and the game would get mighty tedious much past 200 planets, if not before, due to the core mechanics of wormhole traversal and the related input needed.
: Re: Helping out with External Code
: Draco18s May 16, 2017, 11:29:16 PM
I was speaking practical limits based on pan and zoom.

There are some galaxy gen algorithms from ol' Space Empires that can now be done in AIW2 and it occurred to me that I might want to make sure that things stay within reasonable bounds.
: Re: Helping out with External Code
: BadgerBadger May 17, 2017, 09:26:54 PM
Hey all, I have a new map type, and I'm looking for feedback! This is a very different one; it is vaguely similar to Clusters, in that it creates regions of planets, but each region has links according to a randomly chosen linking algorithm, and then the regions are linked together at the end. It feels like a Nebula to me, hence the name. One of the nice things about this map is that each instance is wildly different; to illustrate the point I've uploaded two copies.

The code needs more cleanup before I share it though, it's still kinda messy. Thoughts/preferences/opinions are welcome!
: Re: Helping out with External Code
: keith.lamothe May 17, 2017, 10:06:18 PM
Awesome :)
: Re: Helping out with External Code
: BadgerBadger May 19, 2017, 06:43:52 PM
Hey everyone! For your pleasure for the weekend, I have some new code with a few new map types. The coolest is "Nebula", but there are a couple other random ones as well (Geode1, Geode2 and Haystack). Haystack is kindof a mess, but if people have an opinion over whether Geode1 or Geode2 is cooler then I'd appreciate it. See this post https://forums.arcengames.com/private-alpha-discussion/helping-out-with-external-code/msg214871/#msg214871 for how to set things up. Running these will throw a bunch of output into the ArcenDebugLog.txt; all of those messages can be ignores though.

I feel like I'm starting to run a bit low on new map ideas (if only because I now have a bunch of cool maps to try once the game is a bit further in development), but if anyone else has some cool ideas or feedback I'd be happy to give them a try. Keith/Chris? Anything you guys wish you had time for?

And for Keith, is there any way you could finagle in some flags that I can expose in a GUI so I can pass some additional variables to the map generation subroutines? There are a ton of variables I'd like to tune to optimize things, but it's really annoying having to close the program, recompile, reopen the program and then navigate to the map I'm tweaking over and over.... "No, I'm busy" is technically fine, since it's not like it's prevented me so far, but I'd much rather ask and be told No than not ask!
: Re: Helping out with External Code
: keith.lamothe May 19, 2017, 07:24:12 PM
And for Keith, is there any way you could finagle in some flags that I can expose in a GUI so I can pass some additional variables to the map generation subroutines? There are a ton of variables I'd like to tune to optimize things, but it's really annoying having to close the program, recompile, reopen the program and then navigate to the map I'm tweaking over and over.... "No, I'm busy" is technically fine, since it's not like it's prevented me so far, but I'd much rather ask and be told No than not ask!
You're welcome to read a config file of your own off disk during mapgen, for now. Later external code will be locked down from doing file i/o.

A generic way to add additional settings that can be configured in-game would be great for modding in general, though, once we get there.
: Re: Helping out with External Code
: tadrinth May 30, 2017, 02:05:34 PM
Map type idea: take a maze or vines map.  Replace nodes at random with small clusters (5-7 planets).  Would have lots of chokepoints (good for Fallen Spire) but also lots of non-choke-pointed systems. 

Spiral galaxy: large cluster in the middle, 8 arms coming off, each arm is a series of linked small clusters. 

I was actually working on this one: Encapsulated, except the outer ring is only 12 planets.  And maybe some extra leaf planets coming off the internal clusters, to make them more defensible.
: Re: Helping out with External Code
: BadgerBadger May 30, 2017, 02:30:58 PM
Hey Tadrinth, those are cool ideas! I like them. If I get the chance I'll take a stab at them later (we'll see how busy my week winds up being).

Did you have any luck making encapsulated work with 12 planets in the outer ring? I think this code snippet will do it:
@@ -2658,6 +2660,8 @@ namespace Arcen.AIW2.External
                         break;
                     default:
                         numberOfRimPlanets = ( (FInt)NumberOfPlanets * FInt.FromParts( 0, 400 ) ).IntValue;
+                        if(numberOfRimPlanets > 12)
+                          numberOfRimPlanets = 12;
                         int planetsRemaining = NumberOfPlanets - numberOfRimPlanets;
                         while ( planetsRemaining > 10 )
                         {

: Re: Helping out with External Code
: BadgerBadger May 30, 2017, 10:02:09 PM
Hey Tandrith, I threw a little something together for your Spiral Galaxy notion. It's a bit different; here we have one large cluster, with a bunch of smaller clusters attached to it. I attached the smaller clusters directly to the main cluster for ease of coding.  The smaller clusters use a variety of linking algorithms, so some are strongly connected and others much less so. Does that capture enough of your original idea to be interesting for you?

And for everyone, does this sort of map look like fun? Any other feedback?
: Re: Helping out with External Code
: keith.lamothe May 31, 2017, 12:12:46 AM
That spiral galaxy map type looks phenomenal.

Part of it is that the darkish-blue backgrounds from Chris are a much better fit to AIW than what we were doing, but the graph itself looks very interesting :)
: Re: Helping out with External Code
: BadgerBadger May 31, 2017, 12:30:30 AM
Yeah, the new backgrounds are great. Huge improvement. But the map type is also a really good one I think. I think this map type lends itself to the style of "I'm going to start on one of the arms of the galaxy, then fortify that choke point and venture forth to do battle," which I think is one that a lot of people will enjoy. 

This makes me want to try a variant on clusters where there are "lots" of small clusters. The traditional Clusters map is up to 6 decent sized clusters, but what if there were, say, a dozen or more small clusters connected to each other in interesting ways?

I think between your maps and my maps we actually have a better selection for AIW2 in alpha than AIWC does now.
: Re: Helping out with External Code
: Draco18s May 31, 2017, 10:51:06 AM
And I haven't even dived in yet. I've got a couple of approaches on the back burner I want to doodle up. None of them are clearly explainable on the forum though.
: Re: Helping out with External Code
: tadrinth June 10, 2017, 01:32:36 PM
Looks like we lost the last few posts in here. =(

I heavily updated BadgerBadger's Octopus map type.  I was happy with my initial attempt, but I did some more tuning and am even happier with it now.

I put the code in a public github repo; Keith/Chris, is that okay?  I'm not sure if the external code is supposed to be public-to-all or public-to-game-owners.

Updated map gen here: https://github.com/tadrinth/AIWarExternalCode/blob/master/src/MapGenerationBadger.cs#L1835

I attached one sample, and here's an album with eight more examples: http://imgur.com/a/kpvd5

Should be super interesting to play on.
: Re: Helping out with External Code
: keith.lamothe June 10, 2017, 02:39:16 PM
The external code is public-to-all, so you did the correct thing. At some point we may put up our own repo and would ask that yours redirect people to ours, but that may or may not actually be desirable depending on what folks actually want at that point.

I've really enjoyed watching the beginning of community-created code mods with these map types. I wouldn't be at all surprised if more games wind up being played on map types y'all made than ones we did.
: Re: Helping out with External Code
: BadgerBadger June 10, 2017, 05:55:18 PM
I feel like there needs to be an efficient way to get community-modded maps into the hands of people who don't want to compile a bunch of C# code. The first ideas that come to mind are to either incorporate some community maps into the base game, or by finding some means of making it "really easy" to obtain new maps (maybe a button at game start for "Find new maps" that allows you to download curated DLLs from some type of "Arcen Curated Community Maps" page).

I think if the bar for obtaining new maps is to download source code off a forum and compile it, well, this will rule out anyone who doesn't want to put in the effort or anyone concerned (and quite reasonably so) about security.
: Re: Helping out with External Code
: Draco18s June 10, 2017, 06:05:10 PM
/me poke pokes at doing some galaxy gen

Um. Hmm.

Not sure how to get started or test things.
: Re: Helping out with External Code
: keith.lamothe June 10, 2017, 06:07:20 PM
incorporate some community maps into the base game
That's the main method, yes.

Making mods discoverable and downloadable are also things we want to do, but we also want to emphasize that the package we deliver is intended to be sufficient for full enjoyment without having to find more pieces to add to the package. Too many games are only so-so until you hunt down the right mods.
: Re: Helping out with External Code
: BadgerBadger June 10, 2017, 06:21:59 PM
Hey draco, hop over to discord and I'll talk you through mapgen
: Re: Helping out with External Code
: Draco18s June 11, 2017, 02:17:20 PM
Hey Keith, got a weird conflict with external code you might have insight on.

After getting set up with an old version of Badger's sample map-gen code, I added one. Everything is fine.
I redacted the file to contain only my code so that it would be able to load along side other DLLs.
Compiled, renamed the DLL, told the XML to use the new DLL name, restored the original DLL before I'd started mucking about and.... It breaks.

I can have the original (and none of Badgers or my map types, this is normal) or I can have the new DLL (containing my map types or Badgers depending on what I compiled) but I can't have both a DLL with my code and a DLL with Badger's.

It appears (to me) that there's some aspect of the DLL compilation process that prevents two DLLs with different code from loading next to each other.  This would handicap any sort of modding scene pretty harshly.  The base error doesn't make any sense to me (null pointer), see the attached log file (erroring on trying to create my map type, I can get the reverse if I rename the DLLs so that mine is AIWarExternalCode.dll and Badger's is AIWarExternalCode_Badger.dll).

Not sure if I'm missing something or what, so I thought I'd ask before doing a bug report.
: Re: Helping out with External Code
: keith.lamothe June 11, 2017, 02:22:26 PM
Does your DLL have a InitialSetupForDLL? That was added as a bandaid when adding support for certain input events handled by external code, and it may be implemented in such a way that requires all external dlls to have that method. I can fix that if so, but I wanted to check if your dll actually works if that type is present or if there are further problems as well.
: Re: Helping out with External Code
: Draco18s June 11, 2017, 02:30:47 PM
Does your DLL have a InitialSetupForDLL? That was added as a bandaid when adding support for certain input events handled by external code, and it may be implemented in such a way that requires all external dlls to have that method. I can fix that if so, but I wanted to check if your dll actually works if that type is present or if there are further problems as well.

I can use either DLL (mine, badger's) as long as it's the only DLL.
Examining the contents of each DLL, there is one reference to IInitialSetupForDLL (each) that I can see.
: Re: Helping out with External Code
: keith.lamothe June 11, 2017, 03:46:10 PM
Which namespace(s) is each dll using for its types?
: Re: Helping out with External Code
: Draco18s June 11, 2017, 07:15:07 PM
They're all in Arcen.AIW2.External.*

Mine I've put "D18" onto the class name, so it doesn't conflict.

I should note that if I put both Badger's cs file and mine into the project and compile that, the game's happy.
: Re: Helping out with External Code
: keith.lamothe June 11, 2017, 08:36:16 PM
Ah, ok. Yea, sounds like it may be a bug with our external type loader after all then. Will look into it, thanks for letting me know. Could you email me both of the dll's you're using, just to make sure I can reproduce it?
: Re: Helping out with External Code
: keith.lamothe June 12, 2017, 02:54:34 PM
Wiki's still down, so here's the release note for this in the next version:

* Fixed a problem with the mod support where every dll had to define a type which implemented the IInitialSetupForDLL interface, and further required a specific naming convention for that type.
** Now when loading a dll it looks at all types exported from it and runs the RunInitialSetup() of each IInitialSetupForDLL it finds.
** If it doesn't find any, it won't mind.

Thanks :)

Your example dll's still lead to (different) errors on load, but it appears to be due to the xml not pointing to the right dll's rather than the game just not loading the dll's. Or possibly I didn't copy them right, etc.
: Re: Helping out with External Code
: Draco18s June 12, 2017, 03:26:00 PM
My xml was newer than my DLL, that's probably it. If it was complaining about missing map types, at least.

Anyway, cool.
: Re: Helping out with External Code
: Draco18s June 16, 2017, 09:21:25 PM
Alright, I've got a whole bunch!

We've got here...

(https://forums.arcengames.com/index.php?action=dlattach;topic=19644.0;attach=10584;image) (https://forums.arcengames.com/private-alpha-discussion/helping-out-with-external-code/?action=dlattach;attach=10583;image)
Probably not very interesting to play, but it's constructed by taking a planet in the "open nodes" list and finding a spot it can add a planet within a certain range and so that all wormhole links stay above 30 degrees with respect to other wormhole links. This planet then attempts to connect to others within range following the same rules and is pushed to the "open node" list.
Any planet with > 4 outbound links is removed from the "open node" list (or it an attempt to expand fails too many times)

My first foray into design, based loosely off Space Empires 4(?) galaxy construction.

(https://forums.arcengames.com/index.php?action=dlattach;topic=19644.0;attach=10586;image) (https://forums.arcengames.com/private-alpha-discussion/helping-out-with-external-code/?action=dlattach;attach=10585;image)
This one I was just kinda playing around. Not sure I'm happy with the tiny rings (mainly in how many of them there are, but I'm already 10% over budget on planets: you'll notice there are 88).  Crossing wormhole links are intentional, although kept to a minimum.

(https://forums.arcengames.com/index.php?action=dlattach;topic=19644.0;attach=10588;image) (https://forums.arcengames.com/private-alpha-discussion/helping-out-with-external-code/?action=dlattach;attach=10587;image)
This one is based off of the mechanics that produce spiral arm galaxies in the real world:
(https://upload.wikimedia.org/wikipedia/commons/thumb/8/8a/Spiral_galaxy_arms_diagram.svg/240px-Spiral_galaxy_arms_diagram.svg.png)
Works better with more planets.

(https://forums.arcengames.com/index.php?action=dlattach;topic=19644.0;attach=10590;image) (https://forums.arcengames.com/private-alpha-discussion/helping-out-with-external-code/?action=dlattach;attach=10589;image)
Like Mini-clusters except that all of the clusters are circular "bubbles" linked in a ring. Rings are largely connected via MST, although very nearby bubbles will link up additionally (looks very foamy when they're clumped tightly).
: Re: Helping out with External Code
: TheVampire100 June 16, 2017, 09:35:41 PM
These look amazing. Especially swirl, very true to a real solar system.
Bubbles also look very nice.
: Re: Helping out with External Code
: Draco18s June 16, 2017, 10:51:52 PM
Yeah, I'm pretty happy with Swirl :D
I'd like to make it feel even more like the celestial boonies, but I can't actually remove planets once they've been added.
: Re: Helping out with External Code
: Pumpkin July 06, 2017, 07:28:03 AM
Woah! I just get out of my AIW slumber and find this. Awesome!

I don't have time to get my hands dirty, right now (and I never touched C# before ; I know C++ and I'll be fine with the code, but the toolchain is really alien for a linux+vim+gcc guy like me) but... Nobody looked at this (https://forums.arcengames.com/ai-war-classic-mods-modding/i'm-having-fun-with-graphviz/)? My algorithms are only written in Perl and use an external untangler (graphviz), so I'll need some work to turn them into an actual mod. I focused only on links and not on positions, essentially because it's easier, but also because the gameplay cares only about wormhole links (beside the nearest neighbors links of the nomad planets in AIWC). I can't wait to implement and play on a cube or a torus!

TL;DR:
GG, guys! I'll catch up with you later.
: Re: Helping out with External Code
: Draco18s July 06, 2017, 08:54:01 AM
Shouldn't be too hard to do some of those, Pumpkin. Badger has an example gen method set up and I did a couple.

As for why we didn't, because we forgot. ;)
: Re: Helping out with External Code
: BadgerBadger July 15, 2017, 12:37:16 PM
I've tidied up the code a bit for the map generators, to make them less verbose (all printouts are silent by default, but you can turn them on with a boolean when coding). Also, I've improved a number of my maps by having the default planet placement be in a rectangle instead of in a big circle. This reduces the amount of scrolling required to get a full picture of what's happening on the map.

I've also improved the notes for the Tutorial map.

This includes Tadrinth's latest changes to the Octopus map, and the Ellipse point generator that Draco wrote.

You should be able to drop this code into the base game without it causing obvious problems.
: Re: Helping out with External Code
: BadgerBadger August 01, 2017, 11:50:20 AM
This new version of the C# code quiets all build warnings (no functional changes)
: Re: Helping out with External Code
: Draco18s August 01, 2017, 02:56:42 PM
I apparently never attached my own code.

The code directly refers to the bitmap by filename (I am not aware of how to handle that via UI or XML config), but the image itself could be almost anything.
: Re: Helping out with External Code
: BadgerBadger August 01, 2017, 06:44:12 PM
Nice work Draco!