2012-07-14 08:12:03

hello everybody, I made a sound rts random map generator
here, are its falts:
goldmines are placed randomly, and with a random quantyty. so you got about 50 lines saying goldmines 263 b6.
Same with woods.
Starting_squares, starting_units and starting_resources need some human modifications
but it also has some things I think are prytty good, hope you'll think to! (:d)
good map structure, it creates nice maps what paths and meadows go.
Good guessing, it'll guess the nb_players_max value based on some numbers
I'm to lazy to upload this to dropbox, so here is the code:
begin of code:
#include "logger.bgt";
logger map;
string[] letters={"a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t"};
int[] numbers={1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20};
void main() {
map.add_entry("title "+input_box("sound rts random map creator","enter the sounds where the title will be made of. For example: 5004 5005"));
map.add_entry("objective "+input_box("sound rts random map creator","good. now enter the objective sounds you will hear on the beginning of the map. For example 145 88, will be neutralized enemy"));
map.add_entry("square_width "+random(3,21));
int columns, lines;
columns=random(2,20);
lines=random(2,20);
map.add_entry("nb_columns "+columns);
letters.resize(columns);
map.add_entry("nb_lines "+lines);
numbers.resize(lines);
string data;
int b=random(1,2);
if(b==1)
data="west_east_paths ";
if(b==2)
data="west_east_bridges ";
for(int counter=0; counter<letters.length()-1; counter++) {
for(int counter2=0; counter2<numbers.length(); counter2++) {
int doit=random(1,10);
if(doit!=10) {
data+=letters[counter]+numbers[counter2]+" ";
}}}
map.add_entry(string_trim_right(data,1));
b=random(1,2);
if(b==1)
data="south_north_paths ";
if(b==2)
data="south_north_bridges ";
for(int counter=0; counter<letters.length(); counter++) {
for(int counter2=0; counter2<numbers.length()-1; counter2++) {
int doit=random(1,10);
if(doit!=10) {
data+=letters[counter]+numbers[counter2]+" ";
}}}
map.add_entry(string_trim_right(data,1));
int gwnum=random(0,85);
for(int counter=0; counter<gwnum; counter++) {
map.add_entry("goldmines "+random(10,300)+" "+letters[random(0,letters.length()-1)]+numbers[random(0,numbers.length()-1)]);
}
gwnum=random(0,65);
for(int counter=0; counter<gwnum; counter++) {
map.add_entry("woods "+random(10,300)+" "+letters[random(0,letters.length()-1)]+numbers[random(0,numbers.length()-1)]);
}
map.add_entry("nb_meadows_by_square "+random(1,10));
gwnum=random(0,20);
for(int counter=0; counter<gwnum; counter++) {
map.add_entry("additional_meadows "+letters[random(0,letters.length()-1)]+numbers[random(0,numbers.length()-1)]);
}
gwnum=random(0,15);
for(int counter=0; counter<gwnum; counter++) {
map.add_entry("remove_meadows "+letters[random(0,letters.length()-1)]+numbers[random(0,numbers.length()-1)]);
}
map.add_entry("nb_players_min 2");
double maxplayers=(columns+lines)/4;
round(maxplayers,0);
if(maxplayers<2) maxplayers=2;
map.add_entry("nb_players_max "+maxplayers);
data="starting_squares ";
for(int counter=0; counter<maxplayers; counter++) {
data+=letters[random(0,letters.length()-1)]+numbers[random(0,numbers.length()-1)]+" ";
}
map.add_entry(string_trim_right(data,1));
data="starting_units ";
data+="townhall farm peasant";
int rand=random(1,3);
string rand2;
rand2="";
if(rand==2) rand2=" farm";
if(rand==3) rand2=" "+random(1,4)+" farm";
data+=rand2;
rand2="";
rand=random(1,6);
if(rand==3) rand2=" barracks ";
if(rand==4) rand2=" "+random(2,3)+" barracks";
data+=rand2;
rand2="";
rand=random(2,9);
rand2=" "+rand+" peasant";
data+=rand2;
map.add_entry(data);
map.add_entry("starting_resources "+random(50,750)+" "+random(50,500));
map.add_entry("global_food_limit "+random(80,1000));
map.write(input_box("sound rts random map creator","ok. now enter the file name the map will be having. for example roelsmap.txt"),true);
alert("done!","map has bin created! congrats!");
}
end of code.
I hope you'll like it!

Roel
golfing in the kitchen

2012-07-20 08:42:31

This sounds great. I'm gonna check it out now.

It is better to remain silent and be thought a fool, than to open your mouth and remove all doubt. -Abraham Lincoln