This site works best with JavaScript enabled. Please enable JavaScript to get the best experience from this site.
* The choice of buildings to put in the city needs to be weighted randomly, so some buildings are more common (houses, trees, etc) and some buildings are less common (graveyards, statues, etc).
weightPoorHouse = 10;
weightRichHouse = 5;
weightTrees = 3;
weightStatues = 2;
weightGraveyard = 1;
weightEmpty = 1;
[...]
weightPoorHouse = weightPoorHouse + ( seed % 8 ) - 4; // Will add from -4 to +4
weightRichHouse = weightRichHouse + ( seed % 6 ) - 3;
weightTrees = weightTrees + ( seed % 4 ) - 2;
[...]
And so on, and so forth...
using System;
using System.Linq;
using System.Diagnostics;
namespace ConsoleApplication1
{
class Program
{
static Random rand = new Random();
static void Main(string[] args)
{
string[] strText = new string[] { "*****", "****", "***", "**", "*" };
int[] intChance = new int[] { 81, 27, 9, 3, 1 };
for (int a = 0; a < 50; a++)
Console.WriteLine(strText[RandomWeightedItemFromArray(intChance)]);
Console.WriteLine("Press any key to exit");
Console.ReadKey();
}
private static int RandomWeightedItemFromArray(int[] intWeights)
{
int intMax = 0;
int intChoice = rand.Next(intWeights.Sum());
for (int intItem = 0; intItem <= intWeights.GetUpperBound(0); intItem++)
{
intMax += intWeights[intItem];
if (intMax > intChoice)
{
return intItem;
}
}
Debug.Assert(false);
return 0;
}
}
}
Several things are done: Creating a path layout throughout the city, like this. Putting as many possible buildings into each rectangle as possible. Loading buildings from one world and putting them into the generated world. About eight buildings.
All of this is quite basic so far and will be improved before V1.4 is released and then in the future as well. My main things to do before V1.4 is released are:
* The choice of buildings to put in the city needs to be weighted randomly, so some builidngs are more common (houses, trees, etc) and some buildings are less common (graveyards, statues, etc).
* Make lots more buildings.
* Random elements of buildings (signs, etc).
I'm doing overtime both days on the weekend and then out in the evenings, so unfortunately progress is going very slowly at the moment
@Golgrinn The sewer is originally created as a maze, then I add loops and remove dead-ends to make it a lot easier to navigate. Personally I find mazes to be fairly boring in computer games, although they can be nice to look at.
I think I might just get rid of the underground, because once I finish Mace I'd like to move onto an underground terrain generator. Once that's created I could then incorporate it into Mace. I think this would work nicely and it would allow me to focus on the main purpose of Mace (created a city, rather than an underground).
@Commander Keen Haha that is actually fairly accurate! There is indeed a Maze.cs file
@chica666 Thanks chica666, I'll have a look when I get home.
@almosteeen57 *salutes* HELLO I AM DAVE! YOGNAUGHT
@Drazong Light sources inside buildings is definitely being done
You said you load the buildings from a world : so, if I understand well, there'll be a world downloaded with the application where we can see the base buildings ? Will we be able to add out buildings ?
->Take a first logic weight for each building, and then add or subtract a little with a seed ( a modulo, for example ).
For example :
( This code might be false ^^ )
Then you calculate the sum of the weights, and go generating :biggrin.gif:
I won't be able to release any new versions this week, but here's a screenshot showing the progress towards V1.4.
I have fixed the bug with chopped buildings. It looks like I was storing too much data in memory, so now I save the world data every-so-often, which clears the memory and then everything works perfectly. Thank you to everyone for your bug reports on this and especially to ratobaraj for his e-mail.
@chica666 Wow! Loving the buildings. That is seriously impressive stuff.
@SoNick That sounds good to me. The Video Game Name generator has a similar setup, which can be seen in the words list. It uses ^ to ensure the first word doesn't get matched to inappropriate words later.
@xNightmare It's called Mace
@adamxelite Thank you! Glad you like it
@tigerman6333 Are you going to say that when I release every version?
@Lokomo Cool
@Curufea I have - it looks very interesting. I will definitely have a play with the pistons and see how they could be incorporated into Mace.
@Molecyle Thanks for letting me know and providing the screenshot. This is fixed and will all be working normally in V1.4
@Commander Keen Sure thing. I'm planning to make the light-sources on the outside walls selectable (random, fire, torches, nothing) and an option to include/exclude the beacons. This'll probably be in V1.5, but don't hold me to that!
@Golgrinn That's correct, from V1.4 Mace will include a MineCraft world that contains the buildings. It will be possible to edit the buildings in V1.4 and then a later version will allow for adding more buildings yourself.
I scribbled up a generic random weighted function the other day:
@KingAzeem Thank you, your highness!
@Golgrinn That's a great idea! I temporarily hacked that in yesterday and took a screenshot, which I'll upload later. I've removed the code for now, but I might write that in properly for a future update. (Edit: here it is!)
@Justin8 Thanks! You could speak to jaquadro, to see if Substrate can be used with Java.
@barakfrieman I no longer have the city from the screenshot, but similar ones can be generated by running Mace V1.0 from the usual download page. If you can't run Mace because you're on OSX/Linux, let me know and I'll make a few worlds from V1.3 for you. At some point in the future I'm going to try running Mace in Mono, which will hopefully allow OSX/Linux users to run Mace.
* Rewrote the path layout code, to divide the city into rectangles
* Random buildings are imported into the city. They are chosen by weighted randomness (so more houses and trees, rather than statues and graveyards)
* Buildings are stored in the Mace world (in the Resources folder), which can be edited in MineCraft
* Building data is stored in buildings.xml, which means it is possible to add and remove buildings, or change how frequently they appear
* Made about twenty buildings
* Added main roads going through the city, which link the north/south entrance and the east/west entrance. They are slightly wider and have street lights
* Removed the sewer. I want to focus development time on the city
* Wheat farms are now covered in glass, to stop spiders destroying them. Thanks to Curufea for letting me know about that.
* Added flowers/grass between buildings and farms
* Outside light sources will now be fires or torches. This can be specified before generating
* Beacons are now optional
* Wrote name generators for the taverns, brothels, gravestones, bakery, library, statue and churches
* Added two city emblems
* Added mushroom farms
* Added street names
* City size now aligns with chunk size, to make the edges a little better
Screenshots can be found on the the project page.
Thanks for your comments Sammmiii, Commander Keen, and SteelersMan7
Thanks for this nice app. I have generate a small city and it works.
Greetings Addabas
Edit: Got "The city of Summersummer". What do I win?
I'll try to make some alternative worlds, like "skyscraper", "goblin city" or "ruined town".
Great job Robson_ !
City of Summersummer is (was) pretty awesome. The addition of main roads and different buildings really adds to the great feeling, though finding three or four brothels or taverns right next to each other was a pretty common sight. Also, all houses oriented in one direction does not help either.
I love the random signs, but there should be limits how many times can each word/sentence be used. That way we won't find things like three houses of pain close together or a graveyard with three Israphel graves (the townsfolk really are prepared for him).
@Commander Keen You win forty days of sun
I have a couple of plans to fix rare buildings spawning next to each other. The first is to simply make more buildings, so there will be less repetition. The second is to limit each "very rare" building (graveyard, brothel, statue) to once per quarter of the city. I will probably limit each "rare" building (tavern, church, warehouse, crafting hut, fountain, bakery, library) to a maximum of two per quarter.
Most of the code for building rotation is written already. I just need to account for entities (doors, chests, signs, etc) and make it rotate to the nearest path.
My plan for the signs is similar to the buildings - I'll be adding more available names, to reduce repetition. I'll also be using some existing code to avoid duplicates. For some buildings this will be at a city wide level (bakeries, churches, road signs, etc) and for some it will be specific to that instance of the building (for example: graveyards should have unique gravestones, but I don't have enough gravestones to do this on a city wide level).
I'm aiming to have all of this in V1.5.
@Golgrinn That would be awesome! You can run the city through Teeth of Time to ruin it
And you have just advertised me again. Thanks! I think I'll have to do it too. Right now.
Awesome!
-Pikapika5
The lanterns can not stand right and left by the wayside?
In the middle of the main routes it looks a bit silly.
Greetings Addabas