より直接的な方法があるかもしれませんが、明示的であっても悪くないです。
追加するアイデアは、次に一致するものを追加する量を示す変数を導入します。
連続した複数の一致のためのより洗練された報酬の規模は、いくつかの変更を導入することができ
score = 0
matchPts = 1 // by default, we add 1
for (x,y) in zip(seqA,seqB):
if x == y:
score = score + matchPts
matchPts = 3
if x !=y :
score = score - 1
matchPts = 1
:他の人がこれを行っているのと同じように
score = 0
consecutiveMatches = 0
for (x,y) in zip(seqA,seqB):
if x == y:
consecutiveMatches += 1
reward = 1
if consecutiveMatches == 2:
reward = 3;
if consecutiveMatches > 2 :
reward = 5;
if consecutiveMatches > 5 :
reward = 100; // jackpot ;-)
// etc.
score += reward
else:
score -= 1
consecutiveMatches = 0
出典
2011-07-20 04:56:34
mjv
以前のANDと現在のペアがmatc彼は? – Hyperboreus
+3 +1に加えて、または+ 3の代わりに+3? –