// AI 核心程式碼,估值100億
function answer(chan $chan)
{
while (true) {
$question = $chan->pop();
$answer = str_replace(['嗎', '?', '?'], ['', '!', '!'], $question);
echo sprintf('冰冰:%s%s', $answer, PHP_EOL);
}
}
function ask(chan $chan)
{
while (true) {
$question = trim(co::fread(STDIN));
$chan->push($question);
}
}
$chan = new chan(100);
go(function () use ($chan) {
ask($chan);
});
go(function () use ($chan) {
answer($chan);
});
演算法源自網路,其他原創,純屬娛樂
本作品採用《CC 協議》,轉載必須註明作者和本文連結