Freitag, 26. September 2008

EE5805 Java 傷心小棧-Wiki

EE3206/EE5805 Java Programming and Applications

The following wiki information on "傷心小棧" is excerpted from:

http://zh.wikipedia.org/wiki/傷心小棧

紅心大戰是一項四人的撲克牌遊戲。這個遊戲的目標是要在遊戲中拿到最少的分數。

如何玩

開始玩
要玩紅心,只是需要:

四名玩家
一副撲克牌
紙筆以記錄分數
在不同數量的玩家有不同的玩法,請參看「變化」部分。


[編輯] 牌面
玩紅心是需要一副52張的撲克牌,這與橋牌的版面相同,牌面大小由大至小的順序為A、K、Q、J、10、9、8、7、6、5、4、3和2。並且沒有皇牌。


[編輯] 目標
紅心的主要要點就是避免取得分數;當一位玩家的分數到了指定的點數(通常是100分),遊戲便會結束。而得到最少分數的玩家便會成為該次遊戲的優勝者。


[編輯] 遊玩概要
紅心是依照回合進行的,每一局都會發牌,與玩家交換卡牌,捨牌,以及計分四部分。遊戲會持續地進行,直到遊戲完結為止。

[編輯] 發牌
在捨牌時沒有特別的效果,多數發牌者會按次按左移動。

[編輯] 交換卡牌
在多數回合裡,每一名玩家會與其他三名玩家交換卡牌,並由其他玩家中取得三張牌。玩家在取得交換卡牌前必須先將卡牌交予另一位玩家。

每一局都會按照這個順序來交換卡牌:

第(4的倍數+1)局:傳左
第(4的倍數+2)局:傳右
第(4的倍數+3)局:對傳
第(4的倍數)局:保留所有牌;不交換任何牌

[編輯] 捨牌
所有的紅心牌和Q♠都是有分的卡牌。

首輪:首先由有2♣的玩家開始首輪捨牌,規定一定要出2♣,其他玩家依照順時鐘選牌丟出有相同花色的牌,若是沒有,則可以出其他花牌, 惟獨不能出有計分的牌(紅心牌和Q♠)。除了與首位出牌者不同花色的玩家之外,由點數大者贏得此次的捨牌。

第二輪之後:由上一輪贏者出牌,除了紅心牌其他花色皆可出,除非手中只剩下紅心牌而無其他花色,或是上幾輪中心碎(見下解釋),方可出紅心牌。 其他玩家依序丟出相同花色的牌,若是沒有,則可以出其他花牌,亦可以出有計分的牌。首次丟出紅心牌稱作心碎,下一輪之後出牌者皆可以出紅心牌。

[編輯] 計分
在每一回合完結時,有分數的牌會合計起來,每一張紅心牌有1分,而Q♠有13分,在一個回合中,總其有26分。但是如果其中一名玩家全取所有的紅心牌以及Q♠的話,那就會成為「豬羊變色」,這位玩家無需增加任何的分數,而另外三位便要加上26分;又或者某些玩家直接地減去該名玩家26分,但兩者的分數計法分別無關,只會將遊玩的時間加長。

最後,當任何一位玩家的分數起過了一個指定的分數,遊戲便算結束了。



EE5805 Java 傷心小棧遊戲過程

EE3206/EE5805 Java Programming and Applications

The following information on "傷心小棧遊戲過程" is excerpted from:

http://www.csps.kh.edu.tw/stu/stu89/right/course/brokeheart.html

傷心小棧遊戲過程:

一、傷心小棧的牌局一開始,首先每一位遊戲者需要選三張牌換給左邊下家的遊戲者(除了第四、八等四倍數的牌局例外)。

二、如何選牌,其操作方式如下所示:

 1在欲選的牌上按一下滑鼠左鍵,突出該張牌,即表示選擇此牌。

 2在突出的牌上按一下滑鼠左鍵,即可取消選擇此牌。

 3傷心小棧的玩法是比誰拿到的紅心牌少,即分數愈低愈好,所以在換牌時,儘量將一些高點數的牌換出丟,例如:穿衣服的Q、K和A。

三、在選擇好交換的三張牌後,按「向左轉」鈕換給下一家,同時您也會收到上一家換來的三張牌。

四、請按「確定」鈕接下換來的三張牌,等到全部遊戲者都換好牌後,手握梅花2的遊戲者必須先出牌,出牌的方法如下:

 1在欲出的牌上,用滑鼠左鍵按一下即可出牌。

 2在突出的牌上,用滑鼠左鍵按一下即可取消選擇此牌。

五、遊戲規則:

 1按順時鐘方向出牌,等到每家都出一張牌後,我們稱為「一墩」。

 2在同一墩的出牌時,每一位下家的遊戲者需出相同花色的牌,除非您手上沒有此花色的牌,才可以出別花色的牌。

 3等到出完一墩牌後,點數最高者必需收取此墩的牌,其中若有分數的牌,便是您的得分,同時得到下一墩的出牌權。

 4第一墩不能去出紅心和黑桃Q。

 5遊戲每一墩不能先出紅心,除非有遊戲者因無紅心牌,才可以出過紅心牌。

 6紅心和黑桃Q都是有分數的,因為是比誰的分數少,請儘量不要拿到這些牌。

六、等到所有遊戲者的牌都出完後,就算完成一局,可以看到這一局每位遊戲者所得的分數和名次。分數愈低,名次愈高,當莊家按下「確定」鈕後,就會進入下一局的牌局,這個牌局會持續進行直到某位遊戲者超100分。

七、計分方式:

 1紅心牌一張1分,黑桃Q一張13分。

 2如果一局有人拿到所有紅心牌和黑桃Q,稱為「博大」,拿到的遊戲者可得0分,其它遊戲者都得26分的處罰分數。

八、結束傷心小棧:如果想結束傷心小棧的遊戲,因為是網路上的牌局,將因參與遊戲的角色不同而有差異。

 1莊家結束遊戲,就會結束此牌局,其它遊戲者都會看到「傷心小棧即將結束」的警告訊息。

 2如果只是加入遊戲者結束遊戲,將不會影響牌局,其位置會被電腦取代。


Reference:

http://zh.wikipedia.org/wiki/傷心小棧
http://www.csps.kh.edu.tw/stu/stu89/right/course/brokeheart.html

Donnerstag, 25. September 2008

EE5805 Java Hearts Images

EE3206/EE5805 Java Programming and Applications

Hearts Game project

There are 52 card images from wiki:

SCROLL down. You can also find the unicode and html codes.

http://en.wikipedia.org/wiki/Hearts_(suit)

http://en.wikipedia.org/wiki/Diamonds_(suit)

http://en.wikipedia.org/wiki/Clubs_(suit)

http://en.wikipedia.org/wiki/Spades_(suit)

http://en.wikipedia.org/wiki/Suit_(cards)

The images are published under the GNU Free Documentation License.



Montag, 22. September 2008

EE5805 Java Programming (3)

EE3206 or EE5805 Java Programming and Applications

Tutorial 3 – Programming with Objects and Classes

Submission Required (Question 4--Due on 24 Sept 08)

1. Create a project “JTutor03”. Write a Java class SimpleBankAccount with a public
data field balance.

Write your own main method to create an object of
SimpleBankAccount. Test the object by reading from and writing to the balance.

2. The bank requires that a minimum balanace should be $100 upon creation of an
account. For this purpose, create another class DefaultBankAccount in the same
project.

It has a public data field balance and a no-arg constructor to initialize the
balance. Test the object by reading from and writing to the balance.

3. The DefaultBankAccount is not well protected as its balance is a public field.
Rewrite the class by changing its balance field to private and providing getters and
setters as suggested below.

Save the class as ProtectedBankAccount. You must
make sure the balance is enough for transaction. Test the object by using the
getters and setters to access the balance.

Method Headers:

-public double getBalance() // return balance
-public boolean withdraw(double amount) // return true on success
-public boolean deposit(double amount) // return true on success

Sample Test Output:

My initial account balance is 100.0
After depositing $200:
My account balance is 300.0

After withdrawing $200:
My account balance is 100.0

After withdrawing $200 again:
My account balance is 100.0

4. Create another class RealBankAccount by renaming the ProtectedBankAccount.
Write an instance method transfer based on the given header and static version
below. The instance method transfers money from its own account to another
account.

Method Header

-public boolean transfer(RealBankAccount to, double amount)
-Static Method - transfer

-public static boolean transfer(RealBankAccount from, RealBankAccount to, double amount) {
if(amount <= from.getBalance() && -amount <= to.getBalance())
{
from.withdraw(amount);
to.deposit(amount);
return true;
} // end if
else
return false;
}

Write a main method in RealBankAccount to test the class. The main method takes
three arguments from command line: balance of account A, balance of account B,
transferred amount. Demonstrate your result to the tutor during the tutorial class.

Example 1: java RealBankAccount 200 300 100
Account A balance is 200.0
Account B balance is 300.0

After transferring $100.0 from A to B:
Account A balance is 100.0
Account B balance is 400.0


Example 2: java RealBankAccount 300 400 500
Account A balance is 300.0
Account B balance is 400.0

After transferring $500.0 from A to B:
Account A balance is 300.0
Account B balance is 400.0


You have just progressively built up your bank account program. You may find that
each revision is just done by adding some extra features to the existing one, with most
of the class properties being same.

However, you have to redefine the same things in a new class every time. This is inconvenient and may cause errors when you copy and
paste the code. What even worse is that you are now maintaining multiple pieces of
code.

For example, you are asked to change the type and name of the balance in all
these four classes.

This could be a disaster when you have a fundamental change in
the base class of a big project that have hundreds of classes.
In the next lesson, you will see how we handle this problem.

- END -



Samstag, 20. September 2008

EE5805 Java-Use Cases Notes

EE5805 Java Programming and Applications

The following notes on Use Cases are excerpted from Fowler's "UML Distilled":

1. Use cases are a technique for capturing the functional requirements of a system.

2. Use cases work by describing the typical interactions between the users of a system the system itself. It provides a narrative of how a system is used.

3. A scenario is a sequence of steps describing an interaction between a user and a system.

4. Therefore, a use case is a set of scenarios tied together by a common user goal.

5. An actor isa role that a user plays in the system.

6. But almost all the value of use cases lies in the textual content, and the diagram is of rather limited value.


Content of Use Case



EE5805 Java -UML Tutorial

EE3206/EE5805 Java Programming and Applications

As we need to desgin the "Hearts" game using UML, there is a good tutorial on UML.

http://atlas.kennesaw.edu/~dbraun/csis4650/A&D/UML_tutorial/index.htm


Also, a good brief introduction is Fowler's "UML Distilled"



Freitag, 19. September 2008

EE5805 Hearts Project (Python)

There is an open source game named "Hearts" written in python.

What is "Python"? It is the language which the first version of the BT software was written.

You need to install python nand pygame in order to play the game.

http://www.python.org


http://www.pygame.org/projects/23/362/?release_id=636

But, Pygame (a game development website in using python) is blockd by the the CityU firewall system.



EE5805 Java Project-Hearts-1

EE3206/EE5805 Java Programming and Applications

Project Part I – Problem Analysis

Background

CitySoft is a software company and the leading solution provider in the market. You
are working in the Java team to develop Java-based applications and systems. Your
team has just received a new project about a popular card game named Hearts that is
also a widespread computer game as packaged in Microsoft Windows XP.

Basically,the client wants to make a Java clone of MS Windows Hearts with a few additional features and modifications.

Figure 1. Microsoft Windows XP Hearts

1. Rename the players as East, North, West and South according to their position.
2. Enable both graphical and text mode display.
3. Enable following cheat codes:

Cheat code syntax (case insensitive) Example Remarks
a) set [east/south/west/north] [score] set east 30 Change players’ scores.
b) void [spade/heart/diamond/club] void diamond Remove a suit from human player by
exchanging with other players’ cards
on hand randomly.
c) shootmoon shootmoon Human player incurs all point cards of
preceding tricks.
d) visible [true/false] visible true Turn over all players’ cards.


Requirement Analysis

Now, you are asked to analyze this card game system and document the system
requirements with the following things:

1. A brief summary of the game play

- For ease of reading, you should list out the steps or instructions in point form
with short sentences. You may also divide the game play into different sections
based on the game states if it is too long.

2. Use Cases and Use Case Diagrams

- Draw use case diagram(s) to demonstrate the functional requirements as well as
any entities involved.
- Use cases should be detailed with a sequence of actions and responses between
the actor and system. Alternative flows, if any, should also be shown. You may
tabulate the actions and responses in each use case for ease of reading.

Submission

Upload your document to Blackboard before 8pm in 1st October 2008. Your document
should be well-formatted based on the guidelines below:

1. Filename
- Since all students upload to the same pool, please rename your file as
Hearts_Group_NN.doc (e.g. Hearts_Group_05.doc).

2. Cover page
- Show your Name, Student ID, Group Number, Course Code and Last
Modification Dates.

3. UML tools
- Do not use the MS Word built-in drawing tools for the UML diagrams. You
should use some specialized drawing or modeling tools. Some of them are
available for free (see references). Others like Visio and Poseidon for UML are
also good but costly.

References

Wikipedia, Hearts (Window) - http://en.wikipedia.org/wiki/Hearts_(Windows)

Videocast, How to play Hearts - http://www.utipu.com/app/tip/id/398

JUDE Community Edition - https://jude.change-vision.com/jude-web/index.html

UMLet - http://www.umlet.com/




Samstag, 13. September 2008

The Rise of British Idealism

I have noticed that there are signs for the rise of British Idealism. There is a phenomenlogical turn in British philosophy. Many papers are "produced" on the Hussurlian context.


That means British philosophy is declining from the Empirical tradition.

May be the term "Postivist" or "Empiricist" sounds out-dated. Use "inter-subjectivity", "Meditiation: Descarte's way".


Is there any "new" Russell or Moore? Not to mention "new" Frege or "new "Wittgenstein.

羅時憲-唯識方隅

羅時憲-<<唯識方隅>>

http://www.dhalbi.org/publ/publ_law.htm

第一、 二卷:《八千頌般若經論對讀》上、下

第三卷:《般若波羅蜜多心經講錄》、 全文下載:(繁體) / (简体)

《能斷金剛般若波羅密多經纂釋》全文下載:(繁體) / (简体)

第四卷:《解深密經圓測疏節要》全文下載:(繁體9M) / (简体10M)

第五、六卷:《瑜伽師地論纂釋》一、二

六卷:《攝大乘論疏》、《大乘掌中論略疏》

第七-九卷:《成唯識論述記刪注》一 至 三 全文下載:(繁體50M)

第十卷:《唯識方隅》全文下載:(繁體3.3M及 索引) / (简体5.0M及 索引)

第十一卷:《學術論文集》

第十二卷:《詩文聯語遺照墨跡》



http://www.dhalbi.org/publ/publ_law.htm

Freitag, 12. September 2008

No pygame at cityu

You cannot access www.pygame.org at City University of Hong Kong.

The site http://www.pygame.org is blocked by the Computing Centre.

But you can access python. That means you can wrtite python but cannot write games in python at cityu.

python game rescources: At HERE

Donnerstag, 11. September 2008

Pygame programming

You can use pygme to write Games.

When you go to 7-11 ot OK shop, we see on-line games written on Windows.

Why there aren't open source games? Anyone think of writing on-line games with python, pygame and the python twisted framework?

Anyone want to implement this project?


University and IVE game design courses won't teach you. They need to fit the industry with the proprietry software.

EeePc as NDS

Asus 's EeePc is a paradigm shift to the PC market.
The Linux O/S can have a market share which is legitmately dominated by Microsoft Windows.

Also, with its portability and affordable price about HK$4700, it can be a portable multimedia device.

It can also be a game console same as NDS but the former is a PC.

Skype + EeePC = Mobile phone

Mittwoch, 10. September 2008

EE5805 Java Programming (2)

EE5805 Java Programming and Applications
http://www.ee.cityu.edu.hk/

The Tutorial notes of EE5805 or EE3206 Java Programming and Application is shown as follows:

EE3206 or EE5805: Tutorial 2 – Developing Java Applications with NetBeans


1. Read the online training below and follow the steps to familiarize yourself with
the NetBeans development tools.

Before generating Javadoc, do add some Javadoc style comments for the acrostic method (e.g. @param, @return, @see, etc.) and see the Javadoc output.

Introduction to Developing General Java Applications

http://www.netbeans.org/kb/60/java/javase-intro.html


2. Create a project “JTutor02”. Write a Java class “Circle” and complete its method of the following header.

Test the class by writing a main method to show the area of circles with radii ranging from 10 to 100, with increment of 10.

static double circleArea(double radius);


3. Computer programs commonly need to process numerical data and characters.
Each character has a unique Unicode between 0 and FFFF in hexadecimal (65535
in decimal).

To generate a random character is to generate a random integer
between 0 and 65535.

Now write a class to generate random characters. A template, as shown in Code 1, is provided for you. You have to write a driver to
test your class.


4. Using the RandomCharacter class, write another program to generate 100
lowercase letters randomly and assign to an array of characters. Count the
occurrence of each letter and display to the screen.

Code 1 – Template of RandomCharacter.java

// RandomCharacter.java: Generate random characters

public class RandomCharacter {

/** Generate a random character between ch1 and ch2 */

public static char getRandomCharacter(char ch1, char ch2)
{
// write your code here
}

/** Generate a random lowercase letter */
public static char getRandomLowerCaseLetter()
{
// write your code here
}

/** Generate a random uppercase letter */
public static char getRandomUpperCaseLetter()
{
// write your code here
}

/** Generate a random digit character */
public static char getRandomDigitCharacter()
{
// write your code here
}

/** Generate a random character */
public static char getRandomCharacter()
{
// write your code here
}
}

- END -
http://www.cityu.edu.hk/arro/catalogue/course_EE.htm

EE5805 Java Programming (1)

EE5805 Java Programming and Applications
http://www.ee.cityu.edu.hk/

The Tutorial notes of EE5805 or EE3206 is shown as follows:

EE3206 or EE5805 Tutorial 1 – Java Programming Environments

The programming exercises in this course require the following software to be installedon your system:

JDK 6 (or latest stable version), http://java.sun.com/javase/downloads/index.jsp

NetBeans 6.1 (or latest stable version), http://www.netbeans.org/


1. Read the online training below and follow the steps to create your first “Hello World”program.

NetBeans IDE Java Quick Start Tutorial
http://www.netbeans.org/kb/60/java/quickstart.html


2. To compile and run your program using the command-line tools of JDK:

1). Choose [Run…] from the Start Menu of your Windows. Type in “cmd” and
then click [OK] to open a DOS command prompt.
2). Enter “path” to display your current path setting.
3). Add the path, if necessary, of the JDK compiler (javac.exe) by typing “set
path=%path%;BIN_PATH” where BIN_PATH is the location of the
compiler (usually as C:\Program Files\Java\jdkx.y.z\bin).

4). Go to the source directory of your project folder by entering “cd SRC_PATH”
where SRC_PATH is the actual path in your system.
5). Type “javac HelloWorldApp.java” to compile your program source.
Type “dir” and see if the class file is correctly generated.
6). Run the class file by entering “java HelloWorldApp”.


3. Under the project folder, the IDE tool created a JAR (Java Archive) file in the
“dist” subdirectory. The JAR file is in a ZIP-compatible format.

To explore the content of a JAR, you may use any ZIP programs (e.g. WinZip) to extract it or use the command-line tool (jar.exe) with this command “jar xfv yourjarfile.jar”.

Write down what you find inside the JAR file.


4. For each of the following code fragments, decide whether it can be compiled. If yes,determine the value of x after the execution of the code. If no, explain why.

a) byte x = 0;
x++;
b) byte x = 127;
c) byte x = 128;

d) char x = '0';
x = x + 1;
e) char x = '0' + 1;
f) char y = '0';
char x = y + 1;

g) final char y = '0';
char x = y + 1;
h) int x = 3f * 4;
i) int x = (int) 3f * 4;
j) int x = (int) 3f * 4f;
k) int x = 'f' * 4;

l) float x = 1.0;
m) float x;
x = 1.0;
n) double x;
x = 1f;

5. For each of the following code fragments, decide whether it can be compiled.
If yes,determine the output display of the execution of the code. If no, explain why.

a) int x = 1, y = 2, z = 3;
if (x > y) if (z > y)
System.out.println(“y is the smallest”);
else
System.out.println(“y is not the smallest”);

b.) boolean t = true, f = false;
if (t && f)
System.out.println(“t && f”);
if (t && !f)
System.out.println(“t && !f”);
if (t || f)
System.out.println(“t || f”);
if (!!t & !f)
System.out.println(“!!t & !f”);


c.) int x = 0, y = 0, z = 0;
switch (x) {
case 0:
y = 1;
z = 2;
break;
case 1:
y = 2;
break;
z = 1;
default:
}
System.out.println(y);
System.out.println(z);


d.) for (int i=0; i<10; i++)
for (int j=0; j<10; j++)
if (j == 5)
break;
System.out.print(i * j + “ ”);

e.) for (int i=0; i<10; i++) {
for (int j=0; j<10; j++) {
if (j == 5)
continue;
System.out.print(i * j + “ ”);
}
}

f.) for (int i=0; i<10; i++) {
for (int j=0; j<10; j++) {
if (i == 5)
break;
System.out.print(i * j + “ ”);
}
}

g.) for (int i=0; i<10; i++) {
for (int j=0; j<10; j++) {
if (i == 5)
continue;
System.out.print(i * j + ' ');
}
}


6. Create a project “JTutor01”. Write a class “PrintPyramid” that prompts the user toenter an integer ranging from 1 to 15 and displays a digit-pyramid.

For example, if the input integer is 12, the output is shown below.


- END -

芒果酥皮拿破崙: Mango Mille-feuille

美味DIY - 芒果酥皮拿破崙Mango Mille-feuille

http://www.rthk.org.hk/elearning/dessert/cake_mangomf.htm

Other Desserts

http://www.rthk.org.hk/elearning/dessert/cake.htm

(Flash)

Dienstag, 9. September 2008

EE5808 Engineering Techniques for Computer Graphics

For EE5808 Engineering Techniques for Computer Graphics, the required textbook is:

Hearn and Baker (2004). Computer Graphics with OpenGL. PH.

To do list:

1. Use VC++2005 to do OpenGL programming (with GLUT)
2. PPT presentations in tutorial
3. Create a character (Individual project)
4. Animate the characterin a story (Group Proj)
5. Usual assignments/ exercises

For the opensource alternative, you may use wx-Dev C++. It claims it is compatible with VC++2005.

There are 6 parts:

1. Database Traversal
2. Modelling Transform
3. Viewing Transform
4. Lighting
5. Rasterization
6. Display

Reference:

http://www.cgvisual.com/links/html/CGVlinks_hk1.htm

各位有志投身cg業的畢業生找到工作未??

Freitag, 5. September 2008

Fitting the Industry

We learn tools to fit the Industry. Tools that are proprietry are stable for the Industry.

Expect the expected?

Python/Ruby cannnot fit the Industry. Then why there are people still using it?

6.1261: In logic process and result are equivalent. (Hence the absence of surprise.)

CHANGE CHANGE CHANGE

Expect the unexpected in using oss tools.

The concept of generativity is embeded in oss tools which can give you a new way of thinking.

Donnerstag, 4. September 2008

Leisure time is very expensive

Russell 's essay "In Praise of Idleness" talks about leisure time.

"Leisure" How much is it?

EE5806 Digital Image Processing

There is a very good Flash-powered ebook written by Professor Hong Yan for EE5806 Digital Image Processing.

http://www.spl.it.cityu.edu.hk/~ebook


Username: student
Password: image

Montag, 1. September 2008

印順法師佛學著作集

印順法師佛學著作集

http://www.yinshun.org.tw/books/

Anscombe 's Glossary

The Glossary of Anscombe 's book: An Introduction to Wittgenstein's Tractatus is very good in understanding the symbols in the Tractatus.

5.1361 We cannot infer the events of the future from those of the present.
Superstition is nothing but belief in the causal nexus.


5.1362 The freedom of the will consists in the impossibility of knowing actions that still lie in the future. We could know them only if causality were an inner necessity like that of logical inference. ---The connexion between knowledge and what is known is that of logical necessity.
('A knows that p is the case' has no sense if p is a tautology.)