scroggle Posted June 30, 2018 (edited) Hey, I recently found a bunch of my old Lego, and made a program that generates Lego castles by swapping out various elements in an LDR file for other assemblies or bricks. (plus doing pallete swaps - etc) I used sections of 7946: King's Castle, 7947: Prison Tower Rescue, 70404: King's Castle, 9468-1: Vampyre Castle, and Battle of Alamut, but I'm also adding bits from other models/assemblies. I haven't fully documented everything yet on how it works, but here is the latest working version: https://github.com/richardFirth/CastleGeneratorPublic [Last update - 3Jul18] To generate permutations of smaller sets (as seen in later posts), select it using "Spawn From Instruction (TEST)" dropdown SpawnDrawbridgeDefense.txt Spawn_whitecap_bay.txt SpwnAlamatGate.txt Spawn_RockTower.txt I also think it should be possible to do random rock faces/walls/trees in the same way. Here are some of the results. Edited July 4, 2018 by scroggle Share this post Link to post Share on other sites
JopieK Posted June 30, 2018 Looks neat @scroggle, how did you pull that off? What program(s) did you use and what (scripting) language?! Share this post Link to post Share on other sites
scroggle Posted June 30, 2018 (edited) I used Excel Visual Basic. https://github.com/richardFirth/CastleGeneratorPublic (Many features in second tab have no explanation/documentation at this time) The way that it works is I've created my own "Commands" that I embed into a bunch of LDR files. The Castle Generator takes these in and executes the commands to modify and spit out a processed LDR File. For example, in the file for trees, it has a table command, and color replacement commands, that the Program knows to preprocess before spitting out the tree. (see comments in code below) 0 FILE main.ldr 0 SCMD_TABLE // tells my processor that this is a table, so it will choose one of the below trees to be the tree 1 25 0 0 260 1 0 0 0 1 0 0 0 1 VillageTree.ldr 1 25 0 0 0 1 0 0 0 1 0 0 0 1 Tree_A.ldr 1 25 300 0 240 1 0 0 0 1 0 0 0 1 Tree_C.ldr 1 25 300 0 10 1 0 0 0 1 0 0 0 1 Tree_E.ldr 0 FILE VillageTree.ldr 0 RNDCOLOR 25 "2,10,288" ONE // replace each item with color 25 with one of the other three colors. Only recolor one part, and choose a new color for the next part 0 REPCOLOR 11 "A_GroundColor" ALL // replace all instances of color 11 with the "A_GroundColor" selected 1 15 40 -306.75 -40 -1 0 0 0 1 0 0 0 -1 3742.dat 1 25 0 -314.75 0 0 0 1 0 1 0 -1 0 0 2417.dat 1 70 0 -268 0 1 0 0 0 -1 0 0 0 -1 30374.dat 1 15 0 -306.75 40 -1 0 0 0 1 0 0 0 -1 3742.dat 1 70 10 -288 10 0 0 1 0 1 0 -1 0 0 2339.dat 1 25 0 -296 0 0 0 -1 0 1 0 1 0 0 2417.dat 1 70 0 -288 0 1 0 0 0 1 0 0 0 1 6143.dat Table of 4 trees shown below. Orange is color 25, so a procressed tree will have each orange element replaced with Green, Dark Green, or Bright green, giving each tree different coloration. Here are the results of spawning two different trees. Edited June 30, 2018 by scroggle Share this post Link to post Share on other sites
x105Black Posted July 1, 2018 This is awesome. Love the ingenuity required to pull it off, but even moreso, I love the results! All of these look like I am seeing official LEGO sets from an alternate reality. Really cool stuff! Keep adding new sections! Love it! Share this post Link to post Share on other sites
Aanchir Posted July 1, 2018 This is really cool and I love the variety you’ve been able to achieve! This program seems like it would be great for generating variations on an idea (color schemes, motifs, etc) to decide what you like best, which can be more tedious with IRL builds or even with some digital building software. Share this post Link to post Share on other sites
Lind Whisperer Posted July 1, 2018 On 6/29/2018 at 8:19 PM, scroggle said: Hey, I recently found a bunch of my old Lego, and made a program that generates Lego castles by swapping out various elements in an LDR file for other assemblies or bricks. (plus doing pallete swaps - etc) I used sections of 7946: King's Castle, 7947: Prison Tower Rescue, 70404: King's Castle, 9468-1: Vampyre Castle, and Battle of Alamut, but I'm also adding bits from other models/assemblies. These look incredible! I haven't fully documented everything yet on how it works, but I'm planning to eventually share it if people are interested in playing with it. I also think it should be possible to do random rock faces/walls/trees in the same way. Please do! Very interested! Question - is there anything preventing it from being possible to scale up the generation, and work with much bigger chunks(assuming you have bigger chunks pre-built, for it to work with)? Share this post Link to post Share on other sites
scroggle Posted July 1, 2018 (edited) 3 hours ago, Lind Whisperer said: Question - is there anything preventing it from being possible to scale up the generation, and work with much bigger chunks(assuming you have bigger chunks pre-built, for it to work with)? I'm assuming eventually it would crash if you tried to make it super super huge. it will also repeat itself a bunch. for example, here's a much larger castle with multiple throne rooms: Multiple Throne Rooms 6 hours ago, Aanchir said: This is really cool and I love the variety you’ve been able to achieve! This program seems like it would be great for generating variations on an idea (color schemes, motifs, etc) to decide what you like best, which can be more tedious with IRL builds or even with some digital building software. Yup :). it's also cool because sometimes it comes up with looks that I hadn't anticipated that look cool. I try to make the choices consistent throughout, so that that the castle looks like it comes from a particular "Faction". I have made it possible to select various options upfront, but I haven't gotten to the point of clearly documenting everything (since I keep changing stuff). Large Castle. Working on having a siege engine in front of the castle since many castles normally come with a member of the opposing faction with a siege engine. (See that the catapult wheels have the same faction colors as the flags - soon the catapults will have a different faction) White Cap Bay tower progress, with roof from Kingdoms joust on spawn1 Edited July 1, 2018 by scroggle Share this post Link to post Share on other sites
x105Black Posted July 2, 2018 (edited) Impressive images. I can see how duplication can be a problem in certain instances. I do like the variety displayed here, and the last part with the White Cap Bay towers is really interesting. It's cool to see how it comes up with alternate building techniques for the same build. For example, the corners of the tower in the second and third spawns, and the walls on the third are nice variations. Very interesting stuff. Also, I'm not sure which sets you're using at the moment, but consider adding sections of the following if you haven't already: 6086 Black Knight's Castle 7079 Drawbridge Defense 70402 The Gatehouse Raid 8799 Knights' Castle Wall 70806 Castle Cavalry (In it's Castle form) 10237 The Tower of Orthanc 9474 The Battle of Helm's Deep 79007 Battle at the Black Gate 75954 Hogwarts Great Hall (or other Hogwarts sets) 71040 Disney Castle There are also a lot of sets that are specifically siege engines or carts that you may want to consider, in a variety of themes. For example, you could add 41157 Rapunzel’s Traveling Caravan or something as simple as 5618 Troll Warrior. If I have any further set suggestions, I'll be sure to post them. I really like this project, and will definitely be coming back here to see more results. I'd be very interested to see what you could do with Forestmen type builds or village-based builds as well. But that's a whole new discussion! Keep up the good work! Edited July 2, 2018 by x105Black Share this post Link to post Share on other sites
scroggle Posted July 3, 2018 Drawbridge defense worked very well. Share this post Link to post Share on other sites
tawernaklockow Posted July 3, 2018 1. This is AMAZING! 2. So, can you normally open the result file in LDD or MLCad? 3. Are you planning on releasing this as a "standalone" app? Share this post Link to post Share on other sites
scroggle Posted July 3, 2018 (edited) 2 hours ago, tawernaklockow said: 1. This is AMAZING! 2. So, can you normally open the result file in LDD or MLCad? 3. Are you planning on releasing this as a "standalone" app? 1. Thanks :D 2. Yep. The result is an .LDR File. 3. I've edited the first post to have a link to the app. I haven't documented how to use many of the features, and it has some really quirky bits. I'm constantly updating it to be easier to use and have more features. my eventual goal is that it will be easy enough to use that interested people will be able to add permutations for various parts of the castle, (Or randomize something else if wanted) and then possibly Incorporate the designs back into the generator Edited July 3, 2018 by scroggle Share this post Link to post Share on other sites
Littleworlds Posted July 3, 2018 Wow! Now thats really cool! I have seen someone else procedually generating castle walls already, but this is even more impressive. The look is indeed very close to regular sets and the layouts are quite plausible too for a set. Great idea for sure! Share this post Link to post Share on other sites
scroggle Posted July 4, 2018 Tower from kings castle Siege added. Share this post Link to post Share on other sites
BrickJagger Posted July 4, 2018 This is an interesting idea. I never really even thought about how different pieces of castles could be mashed up and still look good. Well done @scroggle Share this post Link to post Share on other sites
x105Black Posted July 4, 2018 Nice work! I love the additions here. As always, the variations are a nice surprise! Share this post Link to post Share on other sites
scroggle Posted July 7, 2018 (edited) I've added some ways to generate automated rock faces. My current difficulty in developing this further is that it's getting tedious creating the variation tables for different permutations of different things, since the build rules work by substitution. Variation table for 2x2x3 rock below. Each 2x2x3 rock is replaces with a random item from the table below, and then each green is replaced with a color from my rock colors. (this is a .ldr file) Edited July 7, 2018 by scroggle Share this post Link to post Share on other sites
Littleworlds Posted July 7, 2018 I see. i am not a programmer, but I see the principle. Its astonishing what can be done this way really! Share this post Link to post Share on other sites
soccerkid6 Posted July 16, 2018 I'm amazed by how well you have gotten this to work! Looks like a fun way to easily experiment with castle layouts Share this post Link to post Share on other sites
peedeejay Posted July 20, 2018 This might be the nerdiest thing I‘ve seen in a while and this is exactly why it‘s so awesome. :D Share this post Link to post Share on other sites
Elostirion Posted December 31, 2018 Wow, this is impressive, the results are quite astonishing. Thank you for sharing. Share this post Link to post Share on other sites
rodiziorobs Posted January 7, 2019 Oh my, I saw this months ago but forgot to comment on it, and just now am seeing it again as if for the first time! I'll have to take look at the code you wrote when I'm at a PC. I'm shocked you did it with VBA--I'm kind of a noob at visual basic but I am trying to teach myself more, and I don't think I've ever seen anything like this. Really cool stuff you've put together here. Share this post Link to post Share on other sites
ControlAltBrick Posted January 7, 2019 Looks amazing! Does it need Excel? (or maybe work with openoffice too?) Share this post Link to post Share on other sites