chiark / gitweb /
Limit gems to 25 per leg 6.4
authorIan Jackson <ian@liberator.relativity.greenend.org.uk>
Fri, 25 Dec 2009 19:19:34 +0000 (19:19 +0000)
committerIan Jackson <ian@liberator.relativity.greenend.org.uk>
Fri, 25 Dec 2009 19:19:34 +0000 (19:19 +0000)
yarrg/Commods.pm
yarrg/web/routetrade

index af03a64..bce9a8e 100644 (file)
@@ -222,7 +222,7 @@ sub parse_info1 ($$$) {
                    $ordval= $1;
                    $ordval =~ s/^(\d+)\+$/ $1 + $lnoix * 10 /e;
                } elsif ($prop =~ m/^\!([a-z]+)$/) {
-                   $c->{Flags} .= $prop;
+                   $c->{Flags} .= $1;
                } else {
                    die "unknown property $prop for $ucname";
                }
index 21f4711..9e9256a 100644 (file)
@@ -49,6 +49,7 @@ $quri
 my $loss_per_league= defined $routeparams->{LossPerLeaguePct}
        ? $routeparams->{LossPerLeaguePct}*0.01 : 1e-7;
 my $loss_per_delay_slot= 1e-8;
+my $max_gems= 25;
 
 my $minprofit= $routeparams->{MinProfit} || 0;
 
@@ -147,6 +148,7 @@ my $stmt= "
                commods.ordval                                  ordval,
                commods.posinclass                              posinclass,
                commods.commodclassid                           commodclassid,
+               commods.flags                                   flags,
                dist                                            dist,
                buy.price - sell.price                          unitprofit
        FROM commods
@@ -526,6 +528,14 @@ foreach my $ci (0..($#islandids-1)) {
        $applylimit->('mass',    sub { $_[0]{'unitmass'}  *1e-3 });
        $applylimit->('volume',  sub { $_[0]{'unitvolume'}*1e-3 });
        $applylimit->('capital', sub { $_[0]{'org_price'}       });
+
+       my @gem_subflows= grep { $_->{Flow}{flags} =~ m/g/ } @rel_subflows;
+       if (@gem_subflows) {
+               $cplex .= "
+   ". sprintf("%-10s","gems_$ci:")." ".
+               join(" + ", map { $_->{Var} } @gem_subflows). " <= $max_gems";
+       }
+
        $cplex.= "\n";
 }