Condition = Struct.new :row_position, :column_position
Conditions = [
Condition.new(3, 1), # 横に並んだ時
Condition.new(0, 3), # 次の段の一つ前の列
Condition.new(4, 4), # 次の段の同じ列 # row_position 4 の下記否定チェックはい>つも成功する
Condition.new(3, 5), # 次の段の次の列
]
def deck.check(i)
Conditions.each do |c|
if (i % 4 != c.row_position) and self[i].like(self[i + c.column_position])
return [i, i + c.column_position]
end # if (i % 4 != c.row_position) and self[i].like
end # Conditions.each do |c|
false
end # def deck.check(i)
i = 0
while i < deck.size do
#puts i
if ij = deck.check(i) then
puts ij.map{ |k| '%d: %s' % [k, deck[k]] }.join(', ')
deck[ij[0]], deck[ij[1]] = nil, nil
deck.compact!
deck.display; "\n\n".display
i = 0
else# if ij = deck.check(i)
i += 1
end # if ij = deck.check(i)
end # while i < deck.size do
deck.display; "\n\n".display
handler = Proc.new() do |req, res|
if res['content-type'] =~ %r!text/html!
body = res.body
if res.header["content-encoding"] == "gzip"
Zlib::GzipReader.wrap(StringIO.new(res.body,'rb')){|gz| body = gz.read}
res.header.delete("content-encoding")
res.header.delete("content-length")
end
utf_str = body.toutf8
utf_str.gsub!(/think/, 'XXXXX')
code = Kconv.guess(body)
res.body = utf_str.kconv(code, Kconv::UTF8)
end
end
s = WEBrick::HTTPProxyServer.new(
:Port => 8080,
:ProxyContentHandler => handler
)