Skip to content

Instantly share code, notes, and snippets.

@grimrose
Created June 2, 2012 17:35
Show Gist options
  • Save grimrose/2859293 to your computer and use it in GitHub Desktop.
Save grimrose/2859293 to your computer and use it in GitHub Desktop.
amida
T1 = '| '
T2 = '|---'
width = 5
if ARGV[0] != nil
number = ARGV[0].to_i
if number > 52
number = 52
end
width = number
end
p 'player number is ' + width.to_s
max = width - 1
# header
array = ("A" .. "Z").to_a
size = array.size
header = " "
width.times.map{ |i| array[i % size] }.each_with_index{ |elem, index|
cell = ""
cell << elem
if (index / size) == 1
cell << "'"
else
cell << " "
end
if index < max
cell << " "
else
cell << " "
end
header << cell
}
p header
# body
height = 10
height.times{
line = " "
before = ""
max.times {
cell =""
if before == T2
cell = T1
else
cell = [T1, T2].sample
end
before = cell
line << cell
}
line << '| '
p line
}
# footer
footer = ""
point = Random.rand(width)
width.times{ |k|
if k == point
footer << "!!! "
else
footer << " "
end
}
p footer
"player number is 5"
" A B C D E "
" |---| | | | "
" |---| | | | "
" |---| | | | "
" |---| | |---| "
" |---| | |---| "
" |---| | | | "
" |---| | |---| "
" |---| | | | "
" | |---| |---| "
" |---| |---| | "
" !!! "
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment