<!DOCTYPE html>
<html>
<!-- Default style for pretty-print of text files -->
<head><title>program.rb</title>
<style type="text/css">
pre {margin-left: 6ex;}
pre span {counter-increment: linenum; text-align: right; position: relative;}
pre span:before {
    position: absolute; right: 0px;
    background: #ddd; text-align: right; padding: 0 0.2ex;
    width: 5.5ex; margin-right: 0.5ex;
    content: counter(linenum) ":";
}
</style>
</head>
<body>
<p>[[ <a href="?showattc+article_m+120+raw">RAW TEXT</a>(DOWNLOAD here) ]]</p>
<pre lang="en">
<span></span>#!/usr/bin/env ruby
<span></span># -*- coding: utf-8 -*-
<span></span>
<span></span>#初期設定
<span></span>
<span></span>require &apos;curses&apos;
<span></span>include Curses
<span></span>
<span></span>init_screen
<span></span>cbreak
<span></span>noecho
<span></span>
<span></span>rt = []
<span></span>
<span></span>begin
<span></span>  sleep(0)
<span></span>
<span></span>  10.times do
<span></span>    system(&quot;display -geometry +0+0 before.jpg&amp;&quot;)
<span></span>    sleep(2)
<span></span>    system(&apos;pkill magick -U &#096;whoami&#096;&apos;)
<span></span>    srand
<span></span>    i = rand(3)+1
<span></span>    if i == 1
<span></span>      system(&quot;display -geometry +0+0 after1.jpg&amp;&quot;)
<span></span>    elsif i == 2
<span></span>      system(&quot;display -geometry +0+0 after2.jpg&amp;&quot;)
<span></span>    elsif i == 3
<span></span>      system(&quot;display -geometry +0+0 after3.jpg&amp;&quot;)
<span></span>    end
<span></span>    setpos(0,0)
<span></span>    addstr(&quot;\n 1:安全 2:危険&quot;)
<span></span>    refresh
<span></span>    start = Time.now
<span></span>    answer = getch
<span></span>    stop = Time.now
<span></span>    rt &lt;&lt; [i,answer,stop.to_f - start.to_f]
<span></span>    refresh
<span></span>
<span></span>    system(&apos;pkill magick -U &#096;whoami&#096;&apos;)
<span></span>    setpos(0,0)
<span></span>    addstr(&quot;\n &quot;)
<span></span>    refresh
<span></span>    sleep(2)
<span></span>  end
<span></span>
<span></span>  correct = 0
<span></span>  total = 0
<span></span>  for j in rt
<span></span>    total += j[2]
<span></span>    if (j[0] == 1 &amp;&amp; j[1] == &quot;1&quot;) || (j[0] != 1 &amp;&amp; j[1] == &quot;2&quot;)
<span></span>      correct += 1
<span></span>    end
<span></span>  end
<span></span>
<span></span>ensure
<span></span>  close_screen
<span></span>end
<span></span>
<span></span>printf(&quot;正答%d回　　反応時間%5.3f秒\n&quot;, correct, total/10)

</pre>
</body>
</html>
