0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

robloxでassistant その7

Posted at

概要

robloxでassistantやってみた。

質問

zundokoを教えて

回答

zundokoは、日本の伝統的な遊びの一つです。以下はLuaでzundokoを実装する例です。

local zundoko = {"ズン", "ドコ"}

local function checkZundoko(sequence)
	local n = #sequence
	if n < 5 then
		return false
	end
	
	for i = 1, n - 4 do
		if sequence[i] == "ズン" and sequence[i+1] == "ズン" and sequence[i+2] == "ズン" and sequence[i+3] == "ズン" and sequence[i+4] == "ドコ" then
			return true
		end
	end
	
	return false
end

local sequence = {}

while not checkZundoko(sequence) do
	local randomIndex = math.random(1, 2)
	table.insert(sequence, zundoko[randomIndex])
	print(zundoko[randomIndex])
end

print("キ・ヨ・シ!")

このコードをRoblox Studioのスクリプトに追加して実行すると、ズンドコキヨシの遊びが再現されます。プログラムはランダムに"ズン"と"ドコ"を出力し、"ズンズンズンズンドコ"の並びが現れるまで続きます。最後に"キ・ヨ・シ!"と出力されます。

以上。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?