chiark
/
gitweb
/
~ianmdlvl
/
reprap-play.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
air-hockey-puck: wip
[reprap-play.git]
/
quacks-ingredients-counts
diff --git
a/quacks-ingredients-counts
b/quacks-ingredients-counts
index 15e6bd8c52ad5325d053964c85a90375de365c02..5377cbcb1d53e18e982b95d4bddbbe898d3e5ed5 100755
(executable)
--- a/
quacks-ingredients-counts
+++ b/
quacks-ingredients-counts
@@
-11,7
+11,7
@@
sub xdata ($) {
my ($cb) = @_;
return unless $which eq 'Base';
foreach my $count (qw(1 2 3)) {
my ($cb) = @_;
return unless $which eq 'Base';
foreach my $count (qw(1 2 3)) {
- foreach my $nspots (qw(1 2 3 4)) {
+ foreach my $nspots (qw(
0
1 2 3 4)) {
$_ = $cb->($count,$nspots)."\t".$_;
}
}
$_ = $cb->($count,$nspots)."\t".$_;
}
}
@@
-20,13
+20,13
@@
sub xdata ($) {
$_=<DATA>; chomp or die;
xdata sub {
my ($xcount,$xnspots) = @_;
$_=<DATA>; chomp or die;
xdata sub {
my ($xcount,$xnspots) = @_;
- "${xcount}x". (qw(
X
One Two Three Four)[$xnspots]);
+ "${xcount}x". (qw(
Zero
One Two Three Four)[$xnspots]);
};
our @names = split /\t/, $_;
our %count;
};
our @names = split /\t/, $_;
our %count;
-foreach my $nspots (qw(1 2 3 4)) {
+foreach my $nspots (qw(1 2 3 4
0
)) {
$_=<DATA>; chomp or die;
xdata sub {
my ($xcount,$xnspots) = @_;
$_=<DATA>; chomp or die;
xdata sub {
my ($xcount,$xnspots) = @_;
@@
-36,10
+36,10
@@
foreach my $nspots (qw(1 2 3 4)) {
foreach my $i (0..$#names) {
$_ = $l[$i] || '0+0';
$_ ||= 0;
foreach my $i (0..$#names) {
$_ = $l[$i] || '0+0';
$_ ||= 0;
- m/\+/;
+ m/\+/
or die "$which $nspots ?"
;
$count{$names[$i]}{$nspots} =
$count{$names[$i]}{$nspots} =
- $which eq '
Both'
? $` + $' :
+ $which eq '
All'
? $` + $' :
$which eq 'Base' ? $` :
$which eq 'Witches' ? $' :
die "$which ?";
$which eq 'Base' ? $` :
$which eq 'Witches' ? $' :
die "$which ?";
@@
-57,9
+57,10
@@
our $max_nrows=0;
our $max_rowsz=0;
sub wrtoplevel () {
our $max_rowsz=0;
sub wrtoplevel () {
- print "module $name(){ ////toplevel\n";
my $cs = $count{$name};
my $total = 0; $total += $_ foreach values %$cs;
my $cs = $count{$name};
my $total = 0; $total += $_ foreach values %$cs;
+ return unless $total;
+ print "module ${which}_$name(){ ////toplevel\n";
my $rowsz = ceil(sqrt($total));
my $nrows = ceil($total / $rowsz);
$total_count += $total;
my $rowsz = ceil(sqrt($total));
my $nrows = ceil($total / $rowsz);
$total_count += $total;
@@
-67,8
+68,8
@@
sub wrtoplevel () {
$max_nrows = $nrows if $nrows > $max_nrows;
$max_rowsz = $rowsz if $rowsz > $max_rowsz;
my $ix = 0;
$max_nrows = $nrows if $nrows > $max_nrows;
$max_rowsz = $rowsz if $rowsz > $max_rowsz;
my $ix = 0;
- printf "// %-10s total=%2d rowsz=$rowsz nrows=$nrows\n",
- "$name", $total;
+ printf "// %
s %
-10s total=%2d rowsz=$rowsz nrows=$nrows\n",
+
$which,
"$name", $total;
foreach my $nspots (sort keys %$cs) {
my $c = $cs->{$nspots};
print <<END;
foreach my $nspots (sort keys %$cs) {
my $c = $cs->{$nspots};
print <<END;
@@
-95,15
+96,16
@@
foreach $name (sort keys %count) {
}
print <<END;
}
print <<END;
-// total_count=$total_count total_real_count=$total_real_count
-// max_rowsz=$max_rowsz max_nrows=$max_nrows
+//
$which
total_count=$total_count total_real_count=$total_real_count
+//
$which
max_rowsz=$max_rowsz max_nrows=$max_nrows
END
STDOUT->error and die $!;
__DATA__
END
STDOUT->error and die $!;
__DATA__
-White Green Blue Red Yellow Purple Black Orange
-2
0+6 15+10 14+8 12+6 13+6 15+8 18+8 20+12
-8+3 10+5 10+5 8+5 6+5
-4+2
+White Green Blue Red Yellow Purple Black Orange
Orange6 Loco WhiteSpare
+2
1+6 15+10 14+8 12+6 13+6 15+8 18+8 20+12 1+0
+9+3 10+5 10+5 8+5 6+5 1+0
+5+2 1+0
13+5 10+5 10+5 10+5
13+5 10+5 10+5 10+5
+ 0+20 0+25