Add truth-machine example, and fix the '0' bugs it exposed.
catseye
12 years ago
84 | 84 | } until $playfield->{data}[$x][$y] eq '(' and ((not defined($playfield->{data}[$x][$y-1])) or $playfield->{data}[$x][$y-1] eq ' ' or $y == 0); |
85 | 85 | my $x2 = $x; |
86 | 86 | do { $x2++ } until $playfield->{data}[$x2][$y] eq ')'; |
87 | return [$x+1, $y+1, ($x2-$x)-1, int((($x2-$x)-1)/2), $playfield->{data}[$x2-1][$y]]; | |
87 | my $wild = $playfield->{data}[$x2-1][$y]; | |
88 | $wild = ' ' if not defined($wild); | |
89 | return [$x+1, $y+1, ($x2-$x)-1, int((($x2-$x)-1)/2), $wild]; | |
88 | 90 | } |
89 | 91 | |
90 | 92 | sub apply_rule_randomly($$) |
112 | 114 | { |
113 | 115 | for($j = $y; $j < $y + $h; $j++) |
114 | 116 | { |
115 | my $q1 = $playfield->{data}[$i][$j] || ' '; | |
116 | my $q2 = $playfield->{data}[$i+$dx][$j+$dy] || ' '; | |
117 | my $q1 = $playfield->{data}[$i][$j]; | |
118 | $q1 = ' ' if not defined($q1); | |
119 | my $q2 = $playfield->{data}[$i+$dx][$j+$dy]; | |
120 | $q2 = ' ' if not defined($q2); | |
117 | 121 | if ($q1 eq $wild and $wild ne ' ') |
118 | 122 | { |
119 | 123 | } |
131 | 135 | for($j = $y; $j < $y + $h; $j++) |
132 | 136 | { |
133 | 137 | my $q1 = $playfield->{data}[$i][$j]; |
138 | $q1 = ' ' if not defined($q1); | |
134 | 139 | if ($q1 eq $wild and $wild ne ' ') |
135 | 140 | { |
136 | 141 | } else |
186 | 191 | { |
187 | 192 | for($i = 0; $i <= $maxx; $i++) |
188 | 193 | { |
189 | display($playfield->{data}[$i][$j] || ' '); | |
194 | if (defined $playfield->{data}[$i][$j]) { | |
195 | display($playfield->{data}[$i][$j]); | |
196 | } else { | |
197 | display(' '); | |
198 | } | |
190 | 199 | } |
191 | 200 | gotoxy(1, $j+3); |
192 | 201 | } |