プログラミング雑談 in HIKIKO http://life.2ch.net/test/read.cgi/hikky/1007603962/ プログラミング雑談 in HIKIKO.Ver2β http://life.2ch.net/test/read.cgi/hikky/1015650483/ プログラミング雑談 in HIKIKO.Ver3.1.5 http://life.2ch.net/test/read.cgi/hikky/1022078381/ プログラミング雑談 in HIKIKO.Ver3.1MME http://etc.2ch.net/test/read.cgi/hikky/1041739928/ プログラミング雑談 in HIKIKO.Ver5 http://life6.2ch.net/test/read.cgi/hikky/1055966909/ プログラミング雑談 in HIKIKO.Ver6 http://life7.2ch.net/test/read.cgi/hikky/1099059132/ プログラミング雑談 in HIKIKO.Ver7 http://life7.2ch.net/test/read.cgi/hikky/1122517110/ スレタイ:プログラミング雑談 in HIKIKO.Ver8 http://life7.2ch.net/test/read.cgi/hikky/1138879912/ プログラミング雑談 in HIKIKO.Ver9.0 http://mamono.2ch.net/test/read.cgi/hikky/1164602644/ プログラミング雑談 in HIKIKO.Ver9.1 http://mamono.2ch.net/test/read.cgi/hikky/1197855043/ プログラミング雑談 2008 http://love6.2ch.net/test/read.cgi/hikky/1214448977/
class Hiki def seizou(esa) case esa when "ごはん" "" when "ズリネタ" "ザーメン" end end end hiki = Hiki.new loop do esa = ( case rand(2) when 0 "ごはん" when 1 "ズリネタ" end ) kuso = hiki.seizou(esa) puts "#{esa} -> #{kuso}" sleep 1 end
13 :
class Hiki def seizou(esa) case esa when "ごはん" "" when "ズリネタ" "ザーメン" end end end hiki = Hiki.new loop do esa = case rand(2) when 0 "ごはん" when 1 "ズリネタ" end kuso = hiki.seizou(esa) puts "#{esa} -> #{kuso}" sleep 1 end
14 :
class Hiki @@esa2kuso = {"ごはん" => "", "ズリネタ" => "ザーメン"}
def seizou(esa) @@esa2kuso[esa] end end esa_list = ["ごはん", "ズリネタ"] hiki = Hiki.new loop do esa = esa_list[rand(2)] kuso = hiki.seizou(esa) puts "#{esa} -> #{kuso}" sleep 1 end
alias :okiru :onanii alias :nityan :onanii alias :neru :onanii end def mainichi hiki = Hiki.new loop do yield hiki sleep 1 end end mainichi {|hiki| hiki.okiru hiki.nityan hiki.onanii hiki.neru }
require 'stringio' class Fixnum def zen_head?; (0x81 <= self && self <= 0x9f) || (0xe0 <= self && self <= 0xfc); end end class String def to_t t = Table.new StringIO.open(self) {|io| io.each {|l| t << [] StringIO.open(l.chomp) {|io| until io.eof?; ch = io.getc if ch.zen_head?; t.last << ZenHead.new(ch); t.last << ZenTail.new(io.getc) else t.last << Cell.new(ch); end end } }}; t end end class Cell attr_reader :ch def initialize(ch); @ch = ch; end def zen_head?; false; end def zen_tail?; false; end end class ZenHead < Cell; def zen_head?; true; end; end class ZenTail < Cell; def zen_tail?; true; end; end class Table < Array @@spc = Cell.new(?\s); @@alp = ?# def initialize(w = nil, h = nil) return if h.nil?
47 :
h.times { self << []; w.times { self.last << @@spc }} end def to_s s = ""; self.each {|l| l.each {|c| s << c.ch }; s << $/ }; s end def draw_t(x, y, t) for yy in 0 ... t.length; for xx in 0 ... t[yy].length draw_c x + xx, y + yy, t[yy][xx] end; end end def draw_c(x, y, c) return if (y < 0 || y >= self.length) || (x < 0 || x >= self[y].length) || c.ch == @@alp cc = self[y][x]; if cc.zen_head?; self[y][x + 1] = @@spc; elsif cc.zen_tail?; self[y][x - 1] = @@spc; end if (x == self[y].length - 1 && c.zen_head?) || (x == 0 && c.zen_tail?); self[y][x] = @@spc else self[y][x] = c; end end end class Painter def initialize(mld, max, rat, plo) @mld = mld; @max = max; @rat = rat; @plo = plo
48 :
end def draw_all_to(c) @max.times { draw_one_to c if rand(nil) < @rat } end def draw_one_to(c) x, y = @plo.plot(c, @mld); c.draw_t x, y, @mld end end class BgPlotter @@ins = BgPlotter.new def self.ins; @@ins; end def plot(c, m) [rand(c.first.length + m.first.length - 2) - m.first.length + 1, rand(c.length - m.length)] end end class ActPlotter @@ins = ActPlotter.new def self.ins; @@ins; end def plot(c, m) [rand(c.first.length - m.first.length), rand(c.length - m.length)] end end def_inv = 1.0; def_wd = 79; def_ht = 25 abort "usage: ruby hikinetarium.rb [interval=#{def_inv}] [width=#{def_wd}] [height=#{def_ht}]" if ARGV.length > 3 inv = def_inv; inv = ARGV[0].to_f if ARGV.length >= 1 wd = def_wd; wd = ARGV[1].to_i if ARGV.length >= 2 ht = def_ht; ht = ARGV[2].to_i if ARGV.length >= 3 cnt = (wd * ht) * 3 / (def_wd * def_ht) pais = []
49 :
pais << Painter.new((<<EOS #::::## ::;;::: ##::::# EOS ).to_t, 3 * cnt, 0.3, BgPlotter.ins) pais << Painter.new((<<EOS .#.゜゜・。゜######################################## ###:#:.゜゜。゜..################################### ####.#:゜.゜。・゜゜.############################### ######::.゜。#゜・。゜゜..#.########################## ##########::.゜#゜#゜゜・゜.######################## ###########.:#:.゜゜゜・############################ ##############.:.゜゜。・。゜.゜..#################### #################::.゜。#゜・。゜゜..##.############## #####################:.゜#゜#゜゜・。゜..############ ######################::.゜。#゜・゜.#..#.########### #########################:#:.゜##゜゜゜゜..######## ############################::.゜。#゜・。゜#.##.##### ##############################::.゜#゜#゜゜・。゜.### ###################################::.゜。#゜゜..#.# ######################################:#:.゜#゜゜.. ##########################################::.・。゜.# EOS ).to_t, 1 * cnt, 0.3, BgPlotter.ins) pais << Painter.new((<<EOS ###################################################。##,゚.。゚.##゚.### #############################################。##*##.゚##+##。☆##゚。。# ###########################################.##o##゚,##。*,##o##。.###### #########################################o##。゚.##,゚##。##+##。##。,゚
50 :
#######################################.##゚。,##☆##*##。゚.##o.゚####### ####################################゚##,##。.##o##。*##。##.##o.###### ################################.゚o##。##*.##。##..##☆##.##+.###### #############################。##゚。,##☆##゚.##+##。##゚##,############ #########################*##。.##,##。゚##+.##。*。##゚.################# ####################。゚.##。*##。,##´。.####☆。。.##゚。+############# ###############。####゚##゚。##。,##.。o##☆##+##,゚。##*################# #########.゚##゚####。゚##+##。.##+。##*##。゚。゚.,##,+#################### ###+゚`,##o。。.゚*。゚##。.゚##。##☆+。。゚.##°######################### 。,##.゚。##+##☆。,゚.##o。#。+##。゚.,####.############################# #o##*##。゚。゚.。゚。+゚##。##。##゚。#゚################################## #゚##.゚.##゚.##.##゚####.####゚############################################ EOS ).to_t, 1 * cnt, 0.3, BgPlotter.ins) pais << Painter.new(".".to_t, 20 * cnt, 0.3, ActPlotter.ins) pais << Painter.new("`".to_t, 20 * cnt, 0.3, ActPlotter.ins) pais << Painter.new("'".to_t, 20 * cnt, 0.3, ActPlotter.ins) pais << Painter.new(":".to_t, 20 * cnt, 0.3, ActPlotter.ins) pais << Painter.new(";".to_t, 20 * cnt, 0.3, ActPlotter.ins) pais << Painter.new(".".to_t, 20 * cnt, 0.3, ActPlotter.ins)
51 :
pais << Painter.new("+".to_t, 20 * cnt, 0.3, ActPlotter.ins) pais << Painter.new("o".to_t, 20 * cnt, 0.3, ActPlotter.ins) pais << Painter.new("*".to_t, 20 * cnt, 0.3, ActPlotter.ins) pais << Painter.new("‘".to_t, 5 * cnt, 0.3, ActPlotter.ins) pais << Painter.new("+".to_t, 5 * cnt, 0.3, ActPlotter.ins) pais << Painter.new("○".to_t, 5 * cnt, 0.3, ActPlotter.ins) pais << Painter.new("☆".to_t, 5 * cnt, 0.3, ActPlotter.ins) pais << Painter.new((<<EOS #,i、_ `l´ EOS ).to_t, 2 * cnt, 0.2, ActPlotter.ins) pais << Painter.new((<<EOS _,i、# `!´ EOS ).to_t, 2 * cnt, 0.2, ActPlotter.ins) pais << Painter.new((<<EOS #,i、_ `l´ EOS ).to_t, 2 * cnt, 0.2, ActPlotter.ins) pais << Painter.new((<<EOS ##人## < > ##V## EOS ).to_t, 2 * cnt, 0.2, ActPlotter.ins) pais << Painter.new("☆彡".to_t, 2 * cnt, 0.2, ActPlotter.ins) pais << Painter.new((<<EOS
52 :
####/ ##/## ☆#### EOS ).to_t, 2 * cnt, 0.2, ActPlotter.ins) pais << Painter.new((<<EOS \## ##☆ EOS ).to_t, 2 * cnt, 0.2, ActPlotter.ins) pais << Painter.new((<<EOS ,// ☆'## EOS ).to_t, 2 * cnt, 0.2, ActPlotter.ins) pais << Painter.new("・:☆".to_t, 2 * cnt, 0.2, ActPlotter.ins) pais << Painter.new((<<EOS ,;/ ゚### EOS ).to_t, 2 * cnt, 0.2, ActPlotter.ins) pais << Painter.new((<<EOS ,;/ *''# EOS ).to_t, 2 * cnt, 0.2, ActPlotter.ins) pais << Painter.new((<<EOS *- - -*############# #ヽ#####ヽ############ ###ヽ#####ヽ##########