package GAMES::PBEM::Galaxy::YAGA::Utils; use strict; sub ship_calculator { my ($t)= @_; # # materials # free_units # res # d_tech - drive tech. # w_tech - weap. tech. # s_tech - shield tech. # c_tech - cargo tech. # drive # ammo # weapon # shield # cargo # # weight # weight_full_cargo # speed # speed_full_cargo # turns # number_per_turn # attack # # my $need_units= 0; my $need_mat= 0; $t->{weight}= $t->{drive} + $t->{weapon}/2*($t->{ammo}+1) + $t->{shield} + $t->{cargo}; $t->{weight_full_cargo}= $t->{weight} + $t->{c_tech} * ($t->{cargo} + ($t->{cargo} ** 2)/20); $need_mat+= $t->{weight} - $t->{materials}; if ($need_mat > 0){ $need_units+= $need_mat / $t->{res}; }; $need_units+= 10 * $t->{weight}; $t->{turns}= $need_units/$t->{free_units}; if (($t->{turns} - int ($t->{turns}))>0) {$t->{turns}= int($t->{turns})+1;} else{$t->{turns}= int($t->{turns})}; $t->{ships}= $t->{free_units}/$need_units; $t->{speed}= 20 * $t->{drive} * $t->{d_tech}/$t->{weight}; $t->{speed_full_cargo}= 20 * $t->{drive} * $t->{d_tech}/$t->{weight_full_cargo}; $t->{attack}= $t->{weapon} * $t->{w_tech}; $t->{effective_shield}= $t->{shield}*$t->{s_tech}*exp(log(30/$t->{weight})/3); if ($t->{attack} == 0) { $t->{probability_of_destruction} = 0; } elsif ($t->{effective_shield} == 0) { $t->{probability_of_destruction} = 1; } else { $t->{probability_of_destruction} = (1+log($t->{attack}/$t->{effective_shield})/log(4))/2; } $t->{probability_of_destruction} = 0 if $t->{probability_of_destruction} < 0; $t->{probability_of_destruction} = 1 if $t->{probability_of_destruction} > 1; $t->{power_of_bombing}= (sqrt($t->{attack})/10+1)*$t->{attack}*$t->{ammo}; } my %bla; $bla{materials}= 0; $bla{free_units}= 1000; $bla{res}= 10; $bla{d_tech}= 1.0; $bla{w_tech}= 1.0; $bla{s_tech}= 1.0; $bla{c_tech}= 1.0; # cd2s 20.70 1 1 2 1 # c6 12.50 1 1 2 1 # cz11 67 1 4 18 10 # cd4f 11.35 0 0 0 1 12.35 # cd4s 8.36 1 1 2 1 12.36 my %cd4f = (drive => 11.35, ammo => 0, weapon => 0, shield => 0, cargo => 1); my %cd4s = (drive => 8.36, ammo => 1, weapon => 1, shield => 2, cargo => 1); my %czd11 = (ammo=>1,weapon=>1,shield=>13.8, d_tech=>1.6, cargo=>5, free_units=>500, drive=>29.6); my %czh11 = (ammo=>1,weapon=>1,shield=>40, d_tech=>1.6, cargo=>9, free_units=>1000, drive=>49); my %cz11 = (ammo=>1,weapon=>4,shield=>18, d_tech=>1.2, cargo=>10, free_units=>1000, drive=>67); my %dh1f = (ammo=>1,weapon=>26.3,shield=>18.5, d_tech=>1.2, cargo=>1, free_units=>1000, drive=>53.2); my %faithful = (ammo=>0,weapon=>0,shield=>0, d_tech=>3.57, free_units=>1000, cargo=>15, drive=>34.5); my %merchant = (ammo=>7,weapon=>7,shield=>20, d_tech=>1.6,w_tech=>1,free_units=>1000, cargo=>1, drive=>50); my %ProtosOrophos = (ammo=>1,weapon=>4,shield=>11, d_tech=>2.1,free_units=>1000, cargo=>1, drive=>8.75); my %Terror = (ammo=>1,weapon=>3,shield=>3.5, d_tech=>1,free_units=>1000, cargo=>1, drive=>9); my %GoReliability = (ammo=>0,weapon=>0,shield=>0, d_tech=>3.6,free_units=>1000, cargo=>22, drive=>77); my %FromBig = (ammo=>0,weapon=>0,shield=>0, d_tech=>5.71,free_units=>1000, cargo=>26.5, drive=>72.5); my %Nagoya = (ammo=>0,weapon=>0,shield=>0, d_tech=>5.55,free_units=>1337.72,res=>3.39, cargo=>27.5, drive=>102.2); my %Yokogama = (ammo=>0,weapon=>0,shield=>0, d_tech=>3.57,free_units=>1000, cargo=>14, drive=>35.5); my %test1 = (ammo=>1,weapon=>2, d_tech=>1,free_units=>1000, cargo=>0, shield=>12, drive=>85); my %Microbe = (ammo=>3,weapon=>6.25, d_tech=>2.5,w_tech=>1.3,s_tech=>1.1,free_units=>500, cargo=>0, shield=>12, drive=>25); my %Plasmoid = (ammo=>8,weapon=>3.88, d_tech=>2.5,w_tech=>1.3,s_tech=>1.1,free_units=>499.17, cargo=>0, shield=>12, drive=>19.95); my %DanRouter = (ammo=>0,weapon=>0, d_tech=>2.8,free_units=>1000, cargo=>17, shield=>0, drive=>32.5); my %Support = ( d_tech=>1.6,w_tech=>1.0,s_tech=>1.0, drive=>56,ammo=>47,weapon=>1,shield=>18,cargo=>1); my %Pacifier = (ammo=>7,weapon=>6.8,shield=>20.8, d_tech=>2.5,w_tech=>3,s_tech=>1.2,free_units=>1000, cargo=>1, drive=>50); my %Bertha = (ammo=>1,weapon=>26,shield=>8, d_tech=>2.6,w_tech=>1.3,s_tech=>1.2, cargo=>1, free_units=>1000, drive=>64); my %Pillau = (d_tech=>1.8,w_tech=>1,s_tech=>1,free_units=>1000, drive=>50,ammo=>8,weapon=>8,shield=>12,cargo=>1, ); my %SwordPerf =(d_tech=>1.8,w_tech=>1.2,free_units=>1000, drive=>40,ammo=>60,weapon=>1,shield=>28.5,cargo=>0); my %SwordDanger =(d_tech=>1.6,w_tech=>1.2,free_units=>1000, drive=>31.15,ammo=>2,weapon=>18,shield=>40.85,cargo=>0); my %KwendiPerf =(d_tech=>2.8,w_tech=>1,free_units=>1000, drive=>33.62,ammo=>107,weapon=>1,shield=>10.69,cargo=>0); my %Babah =(d_tech=>2.3,w_tech=>1.3,s_tech=>1.1,free_units=>1000, drive=>48,ammo=>1,weapon=>40,shield=>11,cargo=>0); my %NoCanDo =(d_tech=>2,w_tech=>1,s_tech=>1,free_units=>1000, drive=>28.9,ammo=>1,weapon=>7,shield=>162.1,cargo=>0); my %Stonehendge =(d_tech=>2,w_tech=>1,s_tech=>1,free_units=>1000, drive=>100.5,ammo=>105,weapon=>1.5,shield=>18,cargo=>0); my %Prop = (d_tech=>2.5,w_tech=>1.3,s_tech=>1.1,free_units=>499.17, drive=>9,ammo=>63,weapon=>1.01,shield=>8,cargo=>0); my %Perf_45 = (d_tech=>2.7,w_tech=>1,s_tech=>1, drive => 20.5,ammo=>45,weapon=>1,shield=>6,cargo=>0); my %BumBox = (d_tech=>2.3,w_tech=>1,s_tech=>1, drive=>15.25,ammo=>1,weapon=>8,shield=>1.5,cargo=>0); my %Occupier = (ammo=>1,weapon=>1,shield=>0, d_tech=>5.71,w_tech=>2.2,free_units=>500, cargo=>1.25, drive=>6); my %Spark = (ammo=>16,weapon=>9,shield=>21, d_tech=>2.6,w_tech=>1.3,s_tech=>1.1,free_units=>1000, cargo=>1, drive=>99.5); my %Osaka = (ammo=>0,weapon=>0,shield=>0, d_tech=>4.14,free_units=>1000, cargo=>12.25, drive=>53.75); my %Prep =(d_tech=>3.08,w_tech=>1.3,s_tech=>1.1,free_units=>1000, drive=>49.5,ammo=>80,weapon=>1,shield=>9,cargo=>0); my %bratok=(d_tech=>3,w_tech=>1.7,s_tech=>1,free_units=>1000, drive => 5.1, ammo=>1, weapon=>1.8, shield=>3, cargo=>0); my %NaVshivost=(d_tech=>1,free_units=>1000, drive => 5, ammo=>0, weapon=>0, shield=>0, cargo=>0); my %Hamamatsu = (d_tech=>4.12,ammo=>0,weapon=>0,shield=>0, free_units=>973.25,res=>4.96, drive=>73.3, cargo=>22.05); my %e = (ammo=>1,weapon=>1,shield=>1, d_tech=>5.72,free_units=>1337.72,res=>3.39, cargo=>1, drive=>4.21); my %Minotaur = (ammo=>18,weapon=>10,shield=>33.7, d_tech=>5.79,w_tech=>3.67,s_tech=>4.07, free_units=>1337.72,res=>3.39, cargo=>1, drive=>130); my %Mantis = (ammo=>1,weapon=>33.5,shield=>15, d_tech=>5.79,w_tech=>3.67,s_tech=>4.07, free_units=>500, cargo=>1, drive=>49.5); my %Pentium = (ammo=>50,weapon=>1,shield=>13, d_tech=>5.79,w_tech=>3.67,s_tech=>4.07, free_units => 797.31, res => 9.61, cargo=>1, drive=>39.4); my %Stonehendge =( d_tech=>5.79,w_tech=>3.67,s_tech=>4.07, free_units=>1000, drive=>99,ammo=>105,weapon=>1.5,shield=>18.5,cargo=>1); my %Theseus = (ammo=>10,weapon=>8.89,shield=>20, d_tech=>5.79,w_tech=>3.67,s_tech=>4.39, free_units=>715.96,res=>5.04, cargo=>1, drive=>70.5); %bla = (%bla,%Theseus); ship_calculator(\%bla); print "weight= $bla{weight}\n"; print "weight_full_cargo= $bla{weight_full_cargo}\n"; print "speed= $bla{speed}\n"; print "speed_full_cargo= $bla{speed_full_cargo}\n"; print "ships= $bla{ships}\n"; print "turns= $bla{turns}\n"; print "attack= $bla{attack}\n"; print "probability_of_destruction= $bla{probability_of_destruction}\n"; print "effective_shield= $bla{effective_shield}\n"; print "power_of_bombing= $bla{power_of_bombing}\n"; __END__