Last active
August 29, 2015 14:12
-
-
Save KWKdesign/86c91f73dae49c3beb7b to your computer and use it in GitHub Desktop.
SV Circle Map Creation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- while ( select count(1) from planet ) < ( select count(1) from player ) * 1.05 loop | |
while ( select count(1) from planet ) < 2000 loop | |
for new_planet in | |
select nextval( 'planet_id_seq' ) as id, | |
case ( random() * 11 )::integer % 12 | |
when 0 then 'Aethra_' || generate_series | |
when 1 then 'Mony_' || generate_series | |
when 2 then 'Semper_' || generate_series | |
when 3 then 'Voit_' || generate_series | |
when 4 then 'Lester_' || generate_series | |
when 5 then 'Rio_' || generate_series | |
when 6 then 'Zergon_' || generate_series | |
when 7 then 'Cannibalon_' || generate_series | |
when 8 then 'Omicron Persei_' || generate_series | |
when 9 then 'Urectum_' || generate_series | |
when 10 then 'Wormulon_' || generate_series | |
when 11 then 'Kepler_' || generate_series | |
end as name, | |
greatest( ( random() * 100 )::integer, 30 ) as mine_limit, | |
greatest( ( random() * 1000000000 )::integer, 100000000 ) as fuel, | |
greatest( ( random() * 10 )::integer , 2 ) as difficulty, | |
null::point as location | |
from generate_series( 1, 500 ) | |
loop | |
<<location>> | |
while 1=1 loop | |
new_planet.location := point( | |
case ( random() * 1 )::integer % 2 | |
when 0 then ( random() * get_numeric_variable( upper( 'universe_creator' ) ) )::integer | |
when 1 then ( random() * get_numeric_variable( upper( 'universe_creator' ) ) * -1 )::integer | |
end, | |
case ( random() * 1 )::integer % 2 | |
when 0 then ( random() * get_numeric_variable( upper( 'universe_creator' ) ) )::integer | |
when 1 then ( random() * get_numeric_variable( upper( 'universe_creator' ) ) * -1 )::integer | |
end | |
); | |
exit location when 1=1 | |
and new_planet.location <@ circle( point( 0, 0 ), get_numeric_variable( upper( 'universe_creator' ) ) ) | |
and not exists ( select 1 from planet where ( location <-> new_planet.location ) <= 3000 ) | |
; | |
end loop; | |
insert into planet ( id, name, mine_limit, difficulty, fuel, location, location_x, location_y ) | |
values( new_planet.id, new_planet.name, new_planet.mine_limit, new_planet.difficulty, new_planet.fuel, new_planet.location, new_planet.location[0], new_planet.location[1] ); | |
end loop; | |
end loop; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment