This document contains the slides from a talk given by Konrad Malawski on the "Tao/Zen of Programming" using Akka. Some of the key points discussed include:
- Actors are meant to work together and each actor should focus on a single responsibility. Having only one actor limits its capabilities.
- Actors should be structured in a hierarchy with parent-child relationships to allow for supervision. Actors should also be named meaningfully based on their purpose.
- Blocking operations can starve other actors by monopolizing shared resources. Blocking code needs to be isolated on dedicated dispatchers.
- Messages should be processed asynchronously using for/flatMap instead of awaiting futures to avoid blocking
This document contains the slides from a talk given by Konrad Malawski on the "Tao/Zen of Programming" using Akka. Some of the key points discussed include:
- Actors are meant to work together and each actor should focus on a single responsibility. Having only one actor limits its capabilities.
- Actors should be structured in a hierarchy with parent-child relationships to allow for supervision. Actors should also be named meaningfully based on their purpose.
- Blocking operations can starve other actors by monopolizing shared resources. Blocking code needs to be isolated on dedicated dispatchers.
- Messages should be processed asynchronously using for/flatMap instead of awaiting futures to avoid blocking
About GStreamer 1.0 application development for beginnersShota TAMURA
Written in Japanese
This slides that was made for me to speak.
so, description in slides may not enough.
Agenda
- Overview
- Data structure
- The basic steps of gstreamer application development
- Tips...
About GStreamer 1.0 application development for beginnersShota TAMURA
Written in Japanese
This slides that was made for me to speak.
so, description in slides may not enough.
Agenda
- Overview
- Data structure
- The basic steps of gstreamer application development
- Tips...
1. ソリティア カップル アルゴリズム解説
2020年8月19日
嘉村 しょう
ソリティア カップル アルゴリズム解説
Commentary on Solitaire ‘Couple’ algorithm
■ Abstract
This paper aims at building knowledge, designing and coding skills in Java.
I make a commentary on the algorithm implemented in Solitaire ‘Couple’.
Although player has multiple strategies, win rate depends on initial status,
which 52 cards are randomly placed in 13 rows and 4 columns. I exclude player
strategies and simplify the rule. Based on the simplified rule, I drew a flowchart,
hand simulation and Java codes.
Keywords:Algorithm Design, Game, Solitaire, Couple, Java, Coding
■ サマリー
アルゴリズム理解、設計、コーディング・スキル強化を目的に、トランプ・ゲーム
カップルを解説する。本稿では、プレイヤーの選択を考慮せず、ルールを単純化
し、フロー・チャート、ハンド・シュミレーション、Javaコードを作成した。
■ ソリティアとは
ソリティアは、一人で遊べるカード・ゲームの総称である。スパイダーや四つ葉の
クローバーが有名で、カップルもソリティアに分類される。ソリティアは、初期状
態、選択余地、クリア可能性の3つで分類される。[1]
初期状態 (Initial Statues)
ゲーム開始時の状態を指す。ゲーム毎に異なる。
選択 (Strategy)
プレーヤーによる選択有無を指す。
クリア可能性 (Win Rate)
ゲームのクリア可能性を指す。クリア出来ないゲームも存在する。
■ カップルのルールと変更点
ジョーカーを取り除いた52枚のカードを13行4列に並べ、上下・左右・左右斜め上
下を見渡し、同じ数のペアを探し、場から取り除く。取り除いた後は、カードを詰
める。全てのカードがなくなればクリア、カードが残っていてもペアが見つからな
ければ、終了(クリア不能)となる。[2] [3] 本稿では、以下2点を、現行ルールから変
更した。
● 1行1列目から探索
実際のゲームでは、プレイヤーは、どのカードからでもペアを探せるが、本稿
では1行1列目から探索を開始する仕様とした。
● 上下・左右・斜め順での探索
複数方向でペアが成立する場合、プレイヤーは方向を選択できるが、本稿では
上下・左右・斜め順で探索する仕様とした。
1
5. ソリティア カップル アルゴリズム解説
2020年8月19日
嘉村 しょう
■ ハンド・シュミレーション
1. If i == i - 4 // 上カードとの比較
delete i, i - 4
Else If i != i - 4
go to 7.
Else i - 4 NOT EXISTS
go to 7.
2. If i == i + 4 // 下カードとの比較
delete i, i + 4
Else If i != i + 4
go to 8.
Else i + 4 NOT EXISTS
go to 8.
3. If i == i - 1 // 左カードとの比較
delete i, i - 1
Else If i != i - 1
go to 9.
Else i - 1 NOT EXISTS
go to 9.
4. If i == i + 1 // 右カードとの比較
delete i, i + 1
Else If i != i + 1
go to 10.
Else i + 1 NOT EXISTS
go to 10.
5. If i == i - 5 // 左上カードとの比較
delete i, i = 5
Else If i != i - 5
go to 11.
Else i - 5 NOT EXISTS
go to 11.
6. If i == i - 3 // 右上カードとの比較
delete i, i = 3
Else If i != i - 3
go to 12.
Else i - 3 NOT EXISTS
go to 12.
7. If i == i + 3 // 左下カードとの比較
delete i, i + 3
Else If i != i + 3
go to 13.
Else i + 3 NOT EXISTS
go to 13.
5
6. ソリティア カップル アルゴリズム解説
2020年8月19日
嘉村 しょう
8. If i == i + 5 // 右下カードとの比較
delete i, i + 5
Else If i != i + 5
go to 15.
Else i + 5 NOT EXISTS
go to 15.
15. If array isEmpty || NO PAIR
stop iteration
Else
i = i + 1
■ Javaコード
フロー・チャート、ハンド・シュミレーションを元に、Javaコード化した。
● リストの採用
当初、多次元配列を定義し、行・列で要素を格納したが、ペア成立後、定義し
た領域を削除する必要がある為、要素の増減操作が楽なリストを採用した。[4]
● If 〜 Else If文の採用
当初、Switch文での実装を考えたが、上下・左右・斜めの複数方向でペア成立
する可能性を考慮し、If 〜 Else If文を採用した。
● カード略記
各スートの頭文字を略記とした。つまり、SpadeはS、HeartはH、ClubはC、
DiamondはDとし、10はX、JackはJ、QueenはQ、KingはKとした。
● 要素番号の反映
Javaのインデックスを反映し、要素は0開始とした。
// //はコメントを表す
import java.util.List; // util.Listパッケージをインポート
import java.util.ArrayList; // util.ArrayListパッケージをインポート
// 文字型リストcardsを定義する
List<String> cards = Arrays.asList
(
S1, S2, S3, S4, S5, S6, S7, S8, S9, SX, SJ, SQ, SK,
H1, H2, H3, H4, H5, H6, H7, H8, H9, HX, HJ, HQ, HK,
C1, C2, C3, C4, C5, C6, C7, C8, C9, CX, CJ, CQ, CK,
D1, D2, D3, D4, D5, D6, D7, D8, D9, DX, DJ, DQ, DK
);
Collections.shuffle(cards); // cardsの要素をシャッフルする [5]
cards = cards.substring(0, 2); // 最右の文字のみ抽出する [6]
int i = 0; // 整数型ポインターiを定義する
for(int i : cards) // リストに対して、以下を繰り返す
6