8.21.2018

Python - Initializing Multiple Lists/Line

This is terribly ugly:
psData = []
nsData = []
msData = []
ckData = []
mAData = []
RData = []
pData = []
Is there a way to declare these variables on a single line?

Ans:down voteaccepted
alist, blist, clist, dlist, elist = ([] for i in range(5))

8.03.2018

嘸蝦米輸入法的灰色免費方案 for Windows 10

簡單說就是rime + 無蝦米設定檔:
1. Download and install rime
2. Go to https://github.com/amoshyc/myliu and download all files
3. 將 repo 中除了 README.md 外的所有檔案放至C:\Program Files (x86)\Rime\weasel-0.11.1\data 中。
(Linux 設定法,可參考https://amoshyc.github.io/blog/2018/install-liu-with-rime.html)
4. 在右下角rime 按滑鼠右鍵打開選單 -> 輸入法設定 -> 勾選 嘸蝦米 -> 中 -> 中
5. Ctrl + ` 切換輸入法

舊的Windows可參考:

嘸蝦米輸入法的三個灰色免費方案 for Windows


4.24.2018

UVa 465 - Overflow這題似乎有點詭異

不知為什麼,我的465 - Overflow這題,Accepted被拿掉了,
因此,我再次挑戰這題,發現同樣的程式邏輯用到__builtin_add_overflow
或者 __builtin_mul_overflow,會得到W.A.
另外,如果檢查strtol的errno == ERANGE,一樣會得到W.A.
最後Google別人的AC code,他是用sscanf來轉換char *,
我跟著用,才得到A.C. 慚愧…

3.27.2018

Enable Fedora 27 Icons on Desktop

Install Gnome Tweak Tool on Fedora 27

1. sudo dnf makecache
2. sudo dnf install gnome-tweak-tool
3. Tweaks ->  Desktop -> Icons on Desktop

2.17.2018

AQ vs Leela vs RN with Windows 10 version

測試環境:
OS: Windows 10 x64
Go GUI: Sabaki
AQ 2.1.1
Leela 0.11.0
RN 4.32

GPU: Nvidia GTX 960M
CPG: i7-6700HQ

AQ 2.1.1:
下載回來Windows版後,修改aq_config.txt:
-komi =6.5

Leela 0.11.0:
使用參數 --gtp

RN 4.32:
下載回來Windows版後,直接使用

Sabaki:
使用預設的開局 (komi = 6.5)

測試結果:
首先 AQ 2.1.1 vs Leela 0.11.0
AQ 兩次執黑勝 Leea
AQ 兩次執白也勝 Leea

認為棋力 AQ 2.1.1 > Leela 0.11.0

由於 RN 4.32執黑 AQ 2.1.1執白在我的電腦會有問題,
所以 RN 4.32執白 vs AQ 2.1.1執黑,
測試一場,結果AQ 2.1.1勝利。

接下來測試,
RN 4.32 執黑 vs Leela 0.11.0執白,
結果 Leela 0.11.0勝利。

推測棋力 AQ 2.1.1 > Leela 0.11.0 > RN 4.32
但是網路上大都評論說 RN 比 Zen6 甚或 Leela 強上很多,
只是有人實測也是RN輸給Leela (參數和版本跟我測的不見得相同)
參:兩個圍棋AI引擎的自動對奕-RN vs. Leela


有一點值得注意的是,若是AQ 2.1.1的-use pondering =off
則對決Leela 0.11.0測了兩場皆輸 (忘了執黑還是執白),
所以pondering一定要開,才能發揮AQ的實力。

2.09.2018

Android 2D Game Tutorial for Beginners (轉貼)

Android 2D Game Tutorial for Beginners


This document is based on:
  • Android Studio 1.5

Target of the document is help you to become acquainted with a few simple techniques in  programming Android Game 2D. Include:
  • Use SuffaceView
  • Drawing on a Canvas
  • The motion of the game character.
  • Interactions with the player's gestures
In this document, I will guide you step by step, therefore, you need to read and practice up to down. We will write each version of the game from 1 to the final version.

2- Create a Game Project

Note that you're creating a 2D game on Android, so the interface of the game must be drawn by you, so you do not need aactivity_main.xml file.
OK, your Project was created.

3- Preparing Images and sounds

You need a few images
  • chibi1.png


  • chibi2.png



  • explosion.png





The Audio file of the explosion.
Background sound:
Copy these images to the drawable folder of project. Create raw folder, and copy explosion.wav & background.mp3 to this folder.

4- Setting fullscreen (Version:1)

With games, you need to set the background image and an important thing is that you need to set FullScreen mode.
Your MainActivity class must extends from the Activity class .
MainActivity.java (Version: 1)
?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
package org.o7planning.androidgame2d;
import android.app.Activity;
import android.os.Bundle;
import android.view.Window;
import android.view.WindowManager;
public class MainActivity extends Activity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // Set fullscreen
        this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                WindowManager.LayoutParams.FLAG_FULLSCREEN);
        // Set No Title
        this.requestWindowFeature(Window.FEATURE_NO_TITLE);
    }
}
Running apps: