Created
December 5, 2016 04:17
-
-
Save ChunChunMorning/bc222f20a0b0d0036e7cd14023126c3f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 中略 | |
threads << Thread.new { | |
loop { | |
message = parent.gets(); | |
if (message.nil?()) | |
break; | |
end | |
puts("parent: #{message}"); | |
args = message.chop().split(","); | |
if (args[0] == "move") | |
parent.write("parent," + args[1] + "\n"); | |
child.write("parent," + args[1] + "\n"); | |
elsif (args[0] == "goal") | |
parent.write("goal\n"); | |
child.write("goal\n"); | |
end | |
} | |
} | |
threads << Thread.new { | |
loop { | |
message = child.gets(); | |
if (message.nil?()) | |
break; | |
end | |
puts("child: #{message}"); | |
args = message.split(","); | |
if (args[0] == "move") | |
parent.write("child," + args[1]); | |
child.write("child," + args[1]); | |
end | |
} | |
} | |
# 中略 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment