tanasinnの謎は深まるばかりだ……

Windowsでの動作報告希望。

import sys
import pygame
import random
import math as m
from pygame.locals import *

pygame.init()
clock = pygame.time.Clock()
SCREENWIDTH = 288
SCREENHEIGHT = 512
surf = pygame.display.set_mode((SCREENWIDTH, SCREENHEIGHT), pygame.SCALED | pygame.FULLSCREEN)
pygame.display.set_caption('*tanasinn*')

val = -1.0
# print('*** tanasinn == -1 ***')

BAI = 64

VAL = 777
VAL = -1.0

myfont = pygame.font.SysFont("Arial", 32)

def painttxt(str):
  global surf, label, myfont
  label = myfont.render(str, 1, (255,255,0))
  surf.blit(label, (0, 0))

DEFY = 256
lines = []

class CLine:
  def __init__(self, x, y, x2, y2):
    self.x = x
    self.y = y
    self.x2 = x2
    self.y2 = y2
    
def make_lines():
  global lines
  lines.clear()
  oldx = 0
  olda = 0
  for i in range(1, 280):
    xfog = i
    sinn = m.sin(xfog)
    if (sinn == 0.0):
      sinn = 0.0001
    tana = VAL / sinn
    p = tana
    a = m.atan(p)
    lines.append(CLine(oldx, olda, xfog, a))
    oldx = xfog
    olda = a

def drawit():
  for o in lines:
    pygame.draw.line(surf, (255, 255, 0), (o.x*10,o.y*BAI+DEFY), (o.x2*10, o.y2*BAI+DEFY))

while True:
    for ev in pygame.event.get():
        if ev.type == QUIT:
            pygame.quit()
    clock.tick(10)
    make_lines()
    surf.fill((0, 0, 0))
    VAL += random.uniform(-0.1, 0.1)
    if VAL == 0.0:
      VAL = 0.0000001
    drawit()
    painttxt('tanasinn...')
    pygame.display.flip()

f:id:kokarage:20200905015957j:plain

tanasinn == -1 とするコードを解き明かしたら

たいして面白くはなかった件。

import math as m
"""
tan(a)*sin(n) == -1.0
tan(a) == -1.0 / sin(n)
tan(a) == p
a == atan(p)
"""
print('*** tanasinn == -1 ***')
for i in range(1, 6):
  sinn = m.sin(i)
  tana = -1.0 / sinn
  p = tana
  a = m.atan(p)
  print ('n = ' + str(i))
  print(' tana == ' + str(tana))
  print(' sinn == ' + str(sinn))
  print(' tanasinn == '+ str(tana*sinn))
  print(' a == ' + str(a))

出力

*** tanasinn == -1 ***
n = 1
 tana == -1.1883951057781212
 sinn == 0.8414709848078965
 tanasinn == -1.0
 a == -0.871274682446377
n = 2
 tana == -1.0997501702946164
 sinn == 0.9092974268256817
 tanasinn == -1.0
 a == -0.8328682075004891
n = 3
 tana == -7.086167395737187
 sinn == 0.1411200080598672
 tanasinn == -1.0
 a == -1.4306020767668275

Pydroid3で画面回転を抑制する

 plyerをインストール後、

from plyer import orientation
orientation.set_portrait()

 と2行を入れるだけで、スマホ縦画面固定ができる。pygameと特にコンフリクトすることはないっぽい。
 追記:これできなくなってるっぽいんだが? (怒)

【成功】電話で変愚する話【ノーベル賞】

追記:
https://inajob.hatenablog.jp/entry/hengband-on-android
を超参考にしました。この方がノーベル賞です。

スマホでやってみたことリスト
環境
Androidのバージョンは9
仮想OSはUserLAndのDebian
sudo apt-get update
色々必要ツール(gccやncursesなど)を一通り
sudo apt-get install
そして
git clone
でソースまるごととってきて
./bootstrap
./configure --disable-japanese --without-x
make install
コンパイルエラー2ヶ所テキトーに直し、
コンパイルは完了する。
しかし
/hengband/src/rumor.c:140: undefined reference to `msg_print'
のようなリンクエラーが1000個くらいドバーッと滝のように流れてきて結局ビルドができなかった。

ざんねん! わたしのでんわではだめなのかも!

追記:
やっぱできました。
メンテナさんのおかげです!
ありがとうございました。
f:id:kokarage:20200127214946j:plain
またあとで追記します。

追記の追記:
 実は自分の電話ではひどい表示になってしまうので、それをなおすため以下のようにmain-gcu.cを書き換えていました。ここ以外は特に書き換えていません。
 これがあの恐るべき「なぜかアリーナモードへ入るバグ」の原因かもしれません。

*** main-gcu.c.bak      Sun Feb  2 00:49:34 2020
--- main-gcu.c  Sun Feb  2 06:36:17 2020
***************
*** 1251,1256 ****
--- 1251,1264 ----
     /* Attempt to use customized colors */
     if (can_fix_color)
     {
+       for (i = 1; i <= 15;i++)
+       {
+               init_pair(i,i,0);
+               colortable[i] = COLOR_PAIR(i);
+               /* Prepare the "Angband Colors" */
+               Term_xtra_gcu_react();
+       }
+ #if 0
        /* Prepare the color pairs */
        for (i = 1; i <= 63; i++)
        {
***************
*** 1269,1274 ****
--- 1277,1283 ----
        /* Prepare the "Angband Colors" */
        Term_xtra_gcu_react();
        }
+ #endif
     }
     /* Attempt to use colors */
     else if (can_use_color)

恐るべきバグ。
f:id:kokarage:20200202203705p:plain

動作報告的なもの

f:id:kokarage:20200111215347j:plain
f:id:kokarage:20200111215403j:plain

 某犬犬さん(?)のが、アンドロイドスマホChromeでなんとか動いたのでその報告……となればよかったのに、画像が正常に読み込まれない感じでした。あとはおそらく非常に重い。
 キーボードはBluetoothのでなんとか操作できている感じ。そんな感じ。