LoginSignup
6
3

More than 3 years have passed since last update.

pythonでムード値を求める(リケ恋)

Last updated at Posted at 2020-01-09

はじめに

リケ恋を読んでいてどうしてもムード値の計算プログラムを作りたい衝動に駆られたのでつくってみました.

ムード値とは理系が恋に落ちたので証明してみた。3巻に出てくるムードを数値化したものである.

ムード値の定義式

(リケクマの理ア充用語解説コーナーより)

ムード値を以下のように定義する

M = P_1 + P_2 + P_3 + P_4 + P_5\quad(-∞<M\leqq100)

・P1(美しさ指数)=x1(その場の美しさ,おしゃれさを表す点数平均)

x_1=\frac{1}{n}\sum_{i=1}^{n}\frac{1}{5}a_i\quad(-∞<a_1\leqq100,nは評価者の人数)

・P2(第三者指数)
   こちらに注目する人間の数をx2とすると

\begin{align}
&x_2=0 のとき P_2=20\\
&x_2>0 のとき P_2=-10000x_2  となる.
\end{align}

・P3(照度指数)
   x3 = その場の照度(ルクス)

P_3 = \frac{1}{5}{104-2(\frac{x_3}{20}+\frac{20}{x_3})}

・P4(静けさ指数)
   その場の騒音値[db]をx4とすると

\begin{align}
&0\leqq x_4 < 20 のとき t=100\\
&20\leqq x_4 <70 のとき t=100-2(x_4-20)\\
&70\leqq x_4    のとき P_4=-∞
\end{align}

・P5(見つめ合い指数)
   沈黙見つめ合い秒数をx5とすると

\begin{align}
&0<x_5<30 のとき S=\frac{100}{30}x_5\\
&30\leqq x_5 \leqq60 のとき S=100\\
&60<x_5    のとき S = 100-5(x_5-60)
\end{align}

プログラム

ムード値.py
# M = P1+P2+P3+P4+P5 (-∞<M<=100)

# P1

# P1 = x1

n = int(input('評価者の人数:'))
m = 1
a = 0

for _ in range(n):
    ai = int(input(str(m) + '人目の評価:'))
    m += 1
    a = a + ai

x1 = (a / 5) / n

P1 = x1


# P2
x2 = int(input('こちらに注目する人間の数:'))

if x2 == 0:
    P2 = 20

else:
    P2 = -10000 * x2

# P3

x3 = float(input('その場の照度(lux):'))

P3 = (104 - 2 * (x3 / 20 + 20 / x3)) / 5

# P4

x4 = float(input('その場の騒音値[db]:'))

if 0 <= x4 < 20:
    t = 100
    M = None

elif 20 <= x4 < 70:
    t = 100 - 2 * (x4 - 20)
    M = None

else:
    M = '-∞'

if not M == '-∞':
    P4 = 30 - 1000 / t

else:
    pass

# P5

x5 = float(input('沈黙見つめ合い秒数:'))

if 0 < x5 < 30:
    S = 100 * x5 / 30

elif 30 <= x5 <= 60:
    S = 100

else:
    S = 100 - 5 * (x5 - 60)

P5 = S / 5

# M

if M == '-∞':
    pass

else:
    M = P1 + P2 + P3 + P4 + P5

print('ムード値=' + str(M) + 'md')

追記

P1を求めるのは以下のプログラムのほうが美しい気がする

# P1

#P1 = x1

n = int(input('評価者の人数:'))

a = []

for m in range(n):

    ai = int(input(str(m + 1) + '人目の評価:'))
    a.append(ai)

x1 = sum(a) / 5 / n

P1 = x1

終わりに

リケ恋面白いのでぜひ読んでみてください.
アニメも1/10から始まるのでぜひ!!!

6
3
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
6
3