Copyright Manish Shrestha , email:- sth.pratik@gmail.com

eyelashesnectarineΛογισμικό & κατασκευή λογ/κού

3 Νοε 2013 (πριν από 3 χρόνια και 7 μήνες)

108 εμφανίσεις

Copyright Manish Shrestha , email:
-

sth.pratik@gmail.com


1

|
P a g e


ABSTRACT




So through this
report

we will show you the realm of what can be done in

order to make the game
working. This includes various phases and even diagrammatic flowcharts. In very brief out game is
based on Object Oriented
Programming paradigm.
So
enjoy
reading!


















Copyright Manish Shrestha , email:
-

sth.pratik@gmail.com


2

|
P a g e


1

INTRODUCTION


1.1

Background

Most of we Nepalese are familiar with our ancient national game called “Baag Chal” in Nepali. We
love this game for its simple logics but hard tactics. Now it’s time to take this game into court of t
he
world. And for this the best means would of course be computers that have made turned the world into
a small village through its large webs of Network. There are various programming languages but only a
few can compete with the multiplatform nature of J
ava.


1.2

Purpose

The purpose of this project will be to have a clear cut understanding of Graphical User Interface
programming in JAVA. The project will be entirely done in Object Oriented Programming paradigm.

We members of this project will be trying to de
monstrate all the concepts such as data abstraction, data
encapsulation, modularity, inheritance (Hierarchy) and polymorphism.


Beside our project “Ba
gChal” will serve us by making us play this ancient and national game on
computers, preferably on networks

as we have planned.


1.3

Objectives

1.

To develop a BagChal game.

2.

Learn
java
programming

and its uses
.

3.

Learn about graphical manipulations
.

4.

Learn and implement Artific
i
al Intelligence.

5.

Study the scope of machine learning

Copyright Manish Shrestha , email:
-

sth.pratik@gmail.com


3

|
P a g e


1.4

Problem

The main problem in this project
is graphical manipulations and implementation of Artificial
Intelligence
.

Before using the modern tools, we need to make sure we how to use the tools and which tools are used
for which tasks. Thus, delay in direct implementation of project shall be one of
our major
problems
.
Getting accused with new tools will take a bit more time, as we will step into the world of OOP.

1.5

Tools Used

Throughout

this
project
we used

in JAVA programming language

and:
-

1.

Java Development Kit 1.0 ( i.e. jdk1.6.0 update 13)

2.

Java Runt
ime Environment 6 ( jre6)

As we know the Java Bytecode (or .class file) when compiled is platform independent so the project is
obviously compatible to both Windows as well as Linux operating system as well as Macintosh. This
aids to the virtual machine th
at loads on these operating systems which interprets the compiled
Bytecode. Thus there are no boundaries of operating system related requirements and if there are some
we shall not use such objects.

For writing the codes, we group members will use IDE's s
uch as Netbeans 6.5, Kawa pro and Jcreator
as suitable to each of us.

GUI programming via swing programming after importing the package “javax.swing” from the
standard set of packages provided by the sun itself.

Swing is a java user interface toolkit. It w
as developed during the life of SDK 1.1 and now is a part
core API in Java 2 (jdk 1.2). It provides us classes representing interface items like windows, buttons,
combo boxes, trees , grids, and menus


everything we need to build a user interface for our

Java
application.

Swing is a part of larger collection of software called the Java Foundation Classes (JFC). JFC includes
the following API's:

1.

The Abstract Window toolkit, (AWT) the original user interface toolkit.

Copyright Manish Shrestha , email:
-

sth.pratik@gmail.com


4

|
P a g e


2.

Swing, the new user interface toolkit. (
Will make the menus, buttons, frames, boundaries etc.
for GUI)

3.

Accessibility, which provides tools for integrating nonstandard input and output devices into
your user interfaces. (Will include the mouse events used for playing)

4.

The 2D AP, a comprehensive s
et of classes for high
-
quality drawing. (Can be useful for drawing
the board )

5.

Drag and Drop, and API that supports the drag and drop metaphor. ( Can be useful for placing
lions and goats in the game)

After designing the basic board setup will objects like

goats and lions, we will work for logics for
developing logics for computer player or will be working with the socket programming that will
incorporate multilayer human vs. human on the network.



1.6

Scope and Limitations












Copyright Manish Shrestha , email:
-

sth.pratik@gmail.com


5

|
P a g e


2

Design

2.1

DFD Design











Copyright Manish Shrestha , email:
-

sth.pratik@gmail.com


6

|
P a g e



2.2

User Interface Design



Above fig is the GUI of the board. Initially when game starts tiger is placed on four corner of the
boards.
Gradually goat is placed in the intersection point.After goat is placed the tiger need to move.

There is a option of
changing themes.One can change the background and icon of tiger and goat if the
person doesn’t likes one for it there is the tab called themes in menu from which user can choose.

Copyright Manish Shrestha , email:
-

sth.pratik@gmail.com


7

|
P a g e






This is actual board its coordinates and size. The board is of size 750
on breadth and 550 on height.It is
divided in 13 parts.

4 part breadth wise is for score board. 8 part breadthwise and heightwise is for
game
-
board.Similarly for menu 3 part of 13 is given.










Copyright Manish Shrestha , email:
-

sth.pratik@gmail.com


8

|
P a g e



2.3


Functional Analysis















Copyright Manish Shrestha , email:
-

sth.pratik@gmail.com


9

|
P a g e


3

Implementation & Tes
ting


3.1

Product Description

Bagchal is a nepali innovation i.e it is the game originated in Nepal
.This is a computerized version of
the game.In this game one can play with human or computer.For playing with computer artificial
intelligence have been develop
ed.



3.2

Functional Implementation

private class MouseClickHandler extends MouseAdapter

This class is created for handling mouse events.It extends the class MouseAdapter which is used for
sensing mouse
behavior


public void mouseClicked(MouseEvent event)

Thi
s function is called whenever mouse is clicked.


public void openFile()

This function

is created so that one get chance to open a file.



public void saveFile()

This function called when ever user wants to save the game.


public void paint(Graphics g)

This

a
function normally program call
itself. Whenever

we repaint the board this method is called itself.

Copyright Manish Shrestha , email:
-

sth.pratik@gmail.com


10

|
P a g e


This method contains the code for board and various themes address. This method control the display
of the games.


private int checkN(int a,int b)

This is

a one of the main function of the board.Whenever user clicks on the board the coordinates of
postion where user clicked is passed as arguments
.Thus on acquiring arguments it convert the position
on fixed variable on the basis of which we calculate the di
stance between tiger and goat.


private void checkhungry(int i,int j)

Here the positon of tiger is passed and checked whether there is any goat near eat which tiger can eat.


public void searchtiger()

The function of this method is that it searches the tig
er. And stores the postion of tiger and passed it to
checkhungry method for further analyzing.


private void game(int a)

When ever user click on the board this method is called.It encapsulate all other methods.This functions
checks whether its goat or tige
r turn and call the method of tiger if its tiger turn else methods of goat.


private void loadGame()

When game is starting this method is called it puts 4 goats on the board and removes all other goats
which is placed in the board in previous game.


publi
c void graphics()

This is method used for animations i.e to show movements of tiger and goat
.It further call graph
method for putting tiger and goat.

Copyright Manish Shrestha , email:
-

sth.pratik@gmail.com


11

|
P a g e


void graph()

This method when called put the tiger on board if its tiger turn else goat if its goat turn.


void artintelligence()


This is the method called when we are playing with computer. It encapsulated two other method
art(int
a)

and
intelligence
().


void art(int a)

This method moves the tiger according to the tiger asked to move if there is no goat whic
h it can eat
and there is no position on board on moving where tiger can eat goat.


void intelligence()

It checks the tiger and goat postions and finds out the postions on moving where tiger can eat the goat.


void wincond()

This method checks whether the

game is over or not i.e checks whether tiger wins or goat wins.


public void Client()

This method is crated for connecting client to server.


public void Server()

This activates the port and listen if any client wants to connect or not


public void send_
msgtoClient(String message)

Copyright Manish Shrestha , email:
-

sth.pratik@gmail.com


12

|
P a g e


This is called by server to send message to the client and listen message from the clients.


public void send_msgtoServer(String message)

4

This is called by client to send message to the server and listen message from the server.

4.1

Testing

Difference 9 combinations






Difference 11 combinations

(0,9),(9,0)









(0,11),(11,0)

(1,10),(10,1)









(1,12),(12,1)



,(2,11),(11,2)









(2,13),(13,2)


(3,12),(12,3)









(3,14),(14,3)

……………









………………..

(5,14),(10,19)









(4,15),(15,4)

……………









…………….

(15,24),(15,24)








(9,20),(20,9)


Similary all combinations are list out and removes the exceptions

Diffrence 8 exceptions :
-

(24,16),(16,24),(6,14),(14,6)

Diffrence 6 exceptions:
-

(4,10),(10,4),(9,15),(15,9)(14,
20),(20,14)

Diffrence 4 exceptions :
-

(0,4)(4,0)(5,9)(9,5)(10,14)(14,10)(15,19)(19,15)(20,24)(24,20)

Diffrence 7 exceptions :
-

(3,10)….(4,11)…(8,15)….(9,16)…..(13,20)….(14,21)….(16,23)…(17,24)

Diffrence 12 exceptions:
-

(4,16)(16,4)(8,20)(20,8)

Copyright Manish Shrestha , email:
-

sth.pratik@gmail.com


13

|
P a g e


Diffrence 3
exceptions :
-

(3,
0)…
.(4,1
)…
(8,
5)…
.(9,
6)…
..(13,1
0)…
.(14,1
1)…
.(15
,
18
)…
(16,29
)
..(20,23)…(21,24)



5

Recommendation and Conclusion




This is a very nice project for learning programming language.On developing this game on get exposed
approximately ev
e
ry field o
f java. i.e developer will have knowledge of handling java language and can
use pretty well in future.Here developer will be exposed to graphical manipulations, networking,string
handling,,artificial intelligence,and also file handling.
Thus it is a pretty
good project for starting.



The project can be success not only just for us but for all the Nepalese who love this ancient national
game. We can also take this game in the world eyes through the Internet. At first the game was made
using C by the Sagrila
software, our seniors did it in C# and we are doing it in Java, known for its
platform independence nature, from browsers to mobile and from Linux to Macs.


So the project is of great value if done accordingly.







Copyright Manish Shrestha , email:
-

sth.pratik@gmail.com


14

|
P a g e








1

INTRODUCTION

--------------------------------
--------------------------------
-------------------------------

2

1.1

Background

--------------------------------
--------------------------------
--------------------------------
-

2

1.2

Purpose

--------------------------------
--------------------------------
--------------------------------
------

2

1.3

Objectives

--------------------------------
--------------------------------
--------------------------------
---

2

1.4

Problem

--------------------------------
--------------------------------
--------------------------------
------

3

1.5

Tools Used

--------------------------------
--------------------------------
--------------------------------
--

3

1.6

Sco
pe and Limitations

--------------------------------
--------------------------------
---------------------

4

2

Design

--------------------------------
--------------------------------
--------------------------------
-------------

5

2.1

DFD Design

--------------------------------
--------------------------------
--------------------------------
-

5

2.2

User Interf
ace Design
--------------------------------
--------------------------------
----------------------

6

2.3

Functional Analysis

--------------------------------
--------------------------------
------------------------

8

3

Implementation & Testing

--------------------------------
--------------------------------
----------------------

9

3.1

Product Description

--------------------------------
--------------------------------
------------------------

9

3.2

Functional Implementation

--------------------------------
--------------------------------
---------------

9

4.1

Testing

--------------------------------
--------------------------------
--------------------------------
------

12

5

Recommendation and Conclusion

--------------------------------
--------------------------------
------------

13





Copyright Manish Shrestha , email:
-

sth.pratik@gmail.com


15

|
P a g e