Mad Report1-5-28

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 24

ABSTRACT

The Dice Roll mobile game is a captivating and entertaining application developed for
both iOS and Android platforms. It offers users a virtual dice-rolling experience, combining luck
and strategy in an addictive gameplay environment. The game features a user-friendly interface,
allowing players to easily navigate and enjoy the virtual dice-rolling experience. The objective is
to accumulate the highest score by strategically rolling the dice and making optimal decisions
based on the rolled numbers. we will be building a Dice Game Project using Java and XML in
Android. The Dice Game is based on a three-player game. The players roll the dice and the player
who gets the highest phase value will win the game. There will be a single activity in this
application. This activity will show the three player’s name and their dice. The result will be
displayed on the top and there will be a roll button at the bottom.

ii
CONTENTS

ACKNOWLEDGEMENT i
ABSTRACT ii
CHAPTER PAGE NO

1. INTRODUCTION 01-02
ABOUT THE MINI PROJECT
.SCOPE AND APPLICATION OF MINI PROJECT
2. HISTORICAL REVIEW 03
3 . REQUIREMENT SPECIFICATION 04-05

SYSTEM REQUIREMENTS
HARDWARE REQUIREMENTS
SOFTWARE REQUIREMENTS
FUNCTIONAL REQUIREMENTS
DEVLOPMENT TASKS
4 . SYSTEM DESIGN 06-08
FLOW CHART
SYSTEM DESIGN
LOGICAL DESIGN
PHYSICAL DESIGN
5. SYSTEM IMPLEMENTATION 09-16
XML CODE
JAVA CODE
6. TESTING 17
7. OUTPUT 18-20
8. CONCLUSION 21
9. REFERENCES 22
Dice Game 2022-23

CHAPTER 1

INTRODUCTION
A dice game is a game that involves the use of one or more dice as the primary element
for gameplay. Dice games have been played for centuries and come in a wide variety of formats,
ranging from simple to complex. The basic premise of a dice game is that players rollone or
more dice and the outcome of the roll determines the outcome of the game. The numberof dice
used, the rules of the game, and the objectives can vary greatly depending on the specificgame
being played. Dice games are often associated with gambling and are commonly found in
casinos, but they can also be played for fun or educational purposes. They can be played with
friends and family or in organized tournaments. One popular dice game is "Craps," where
players bet on the outcome of the roll or a series of rolls of two dice. Another well-known dice
game is "Yahtzee," which involves rolling five dice with the objective of achieving specific
combinations to score points. Dice games can be based purely on chance, where the outcome
is determined solely by the roll of the dice, or they can involve a combination of luck and
strategy, where players make decisions based on the probabilities of certain outcomes. Overall,
dice games provide an entertaining way to engage with probability and chance, and they can
be enjoyed by people of all ages and skill levels.

The dice game is a popular game that involves rolling one or more dice and making decisions
or calculations based on the outcome of the roll. It is commonly played for fun or as a gambling
game.

About Android

Android is the Linux-based open-source operating system for mobile devices like
smartphones & tablets. However, nowadays, many other devices are incorporating android
in them to turn them into smart devices such as Smart TVs, Smart car interface for GPS,
electrical appliances, etc. This software was unveiled in 2007 & the first Android Device was
launched in September 2008. Since then Google, the sponsor of Android has been releasing its
software updates, versions almost every year.

Android also offers several features:


1. NFC (Near Field Communications): NFC Allows electric devices to easily Interact
across short distances.
2. Alternate keywords: It supports multiple keyboards & makes them easy to install.
Dept. of CSE,CIT,GUBBI Page 1
Dice Game 2022-23

3. Beautiful and Interactive UI

4. Storage: SQLite a lightweight relational DB is used for data storage.

5. Multi lang: Supports single direction & Bi-Directional.

Android offers a unified approach to application development for mobile devices which
means developers need only develop for Android, and their applications should be able
to run on different devices powered by Android.The source code for Android is available
under free and open source software licenses. Google publishes most of the codeunder the
Apache License version 2.0 and the rest, Linux kernel changes, under the GNU General
Public License version 2.

Scope and application of mini project

Our Scope is to evolve several Tic-tac-toe strategies which never lose (meaning
a draw or a win by the computer). This makes the problem to have a single objective of
minimizing the number of losses. The evaluation of fitness of any strategy is done by first
allowing it to play all possible games it could play, both as a first player and as a second player.
For example, note from Figure 5 that there are two possible ways a game can move for the first
player from level 1 to level 2, depending on whether the opponent made the left or the right
side move . Our evaluation procedure considers all such intermediate possibilities an opponent
can have and count the total number of possible games resulting in wins, draws and losses. This
is continued for the above strategy to be played as the second player. The total number ofgames
lost in both cases as a first player and a second player is calculated.

Dept. of CSE,CIT,GUBBI Page 2


Dice Game 2022-23

CHAPTER 2
HISTORICAL REVIEW
Dice games have a long and rich history that spans across cultures and civilizations.
They have been played for entertainment, gambling, and even religious purposes. Let's explore
a historical review of dice games. Dice games can be traced back to ancient civilizations. The
earliest evidence of dice dates back over 5,000 years to Mesopotamia (modern-day Iraq).
Excavations have uncovered dice-like objects made from various materials such as bone, ivory,
and stone. These early dice were often marked with symbols instead of numbers. The ancient
Egyptians also played dice games. They used dice made from bone, wood, or precious stones.
Dice were commonly found in tombs, indicating their significance in the afterlife. The game
"Senet" was particularly popular, involving a board and dice. It held symbolic meaning and
was believed to represent the journey of the soul through the underworld. The Romans were
enthusiastic dice players. They had a variety of dice games, including "Tesserae" and "Tali."
Tesserae used six-sided dice and was similar to modern-day backgammon. Tali used four-sided
dice with different numbered sides, and players would throw them together to achieve specific
combinations. Dice games continued to evolve during the Middle Ages. Gambling with dice
became prevalent, often associated with taverns and inns. Games like "Hazard" gained
popularity, involving complex betting rules and strategies. Gambling with dice faced
opposition from religious authorities but remained widely enjoyed. Dice games were also
prominent in Asian cultures. Ancient Chinese dice games like "Bian He" and "Siu Fa" date
back to the Han Dynasty (206 BCE - 220 CE). These games were often played for divination
purposes as well. In Japan, "Sugoroku" was a popular dice game played during the Heian period
(794-1185 CE) and influenced the development of backgammon. Dice games continued to
evolve over time, adapting to changing cultural and social contexts. Traditional dice games like
Yahtzee, Farkle, and Liar's Dice gained popularity in the 20th century and remain enjoyed
today. In addition to physical dice games, the digital era has given rise to virtual dice games
played on computers and mobile devices.Dice games have a fascinating history that spans
thousands of years and numerous civilizations. They have served as forms of entertainment,
gambling, divination, and cultural expression. From ancient Mesopotamia to modern-day
gaming, dice games have remained a timeless source of enjoyment and intrigue for people
around the world.

Dept. of CSE,CIT,GUBBI Page 3


Dice Game 2022-23

CHAPTER 3

REQUIREMENT SPECIFICATION

SYSTEM REQUIREMENTS

Hardware Requirements

• Processor: Intel core Duo 2.0GHz or more

• RAM: 6GB or more.

• Hard disk: 80GB or more

• Monitor: 15” CRT or LCD monitor

• Keyboard: Normal or Multimedia

• Mouse: Compatible mouse

Software Requirements

• Operating system: Windows® Vista 64-Bit / Windows® 7 64-Bit / Windows® 8 64-

Bit / Windows® 8.1 64-Bit.

• Java JDK 11.0.12(recommended)

• Android SDK: Android Studio and SDK tool

Functional Requirements

These requirements are implicit to the system and may be so fundamental that

actor/gamer/relevant people does not explicitly state them .Their absence will be a

cause for dissatisfaction.

1. Develop system within limited cost.

2. Maximum high definition.

3. Minimum hardware requirements which is relevant for this game.

4. Design whole system with efficient manner.

Dept. of CSE,CIT,GUBBI Page 4


Dice Game 2022-23

Development Tasks

1. Android Studio will bring all of the following codes together to create the game.

It will also handle AI and physics routines.

2. Graphics engine will be responsible for rendering text, 2D images, and 3D models

on screen.

• Drawing models

• Drawing sprite

• Drawing text

• Texturing models

• Animation

3. Sound engine will be responsible for playing music and sound effects.

• Multithreading

• Playing sounds

4. Input engine will be responsible for transferring mouse and keyboard input upon

request

tothe game engine.

• Retrieving Input

5. Menu Engine will handle all menus in game.

Dept. of CSE,CIT,GUBBI Page 5


Dice Game 2022-23

CHAPTER 4

SYSTEM DESIGN

Flowchart

Start

Roll
the
Dice

The result is
determined
after every

Player 1 Player 2
Tie Player 3
wins wins
wins

Roll the dice for


more game play

End

Dept. of CSE,CIT,GUBBI Page 6


Dice Game 2022-23

Before getting to implement the game directly we’ll understand the files that we have created

for this application.

1. Dice Game. Through this, we manage the interface of the Android Application.

2. The next important file is the MainActivity.java file. This file makes the application

The first file that we have created is activity_main.xml, this file has the layout of the

actually work. It has all the methods that make functioning in the app possible.

SYSTEM DESIGN

System Design is the most creative and challenging phase in the system life cycle .Design is
the first step into the development phase for any engineered product or system. Design is a
creative process. A good design is the key to effective system. System design is a solution how
to approach the creation of a new system. System design transforms a logic representation of
what is required to do into the physical specification.

The specification is converted into physical reality during development.

Logical design

The logical flow of a system and define the boundaries of a system. It includes

the following steps:

• Reviews the current physical system – its data flows, file content, volumes, frequencies etc

.• Prepares output specifications – that is, determines the format, content and Frequency of
reports.

• Prepares input specifications – format, content and most of the input functions.

• Prepares edit, security and control specifications.

• Specifies the implementation plan.

• Prepares a logical design walk through of the information flow, output, input,

controls and implementation plan.

• Reviews benefits, costs, target dates and system constraints.

Dept. of CSE,CIT,GUBBI Page 7


Dice Game 2022-23

Physical design

Physical system produces the working systems by define the design specifications that tell the
programmers exactly what the candidate system must do. It includes the following steps.

• Design the physical system.

• Specify input and output media.

• Design the database and specify backup procedures.

• Design physical information flow through the system and a physical design Walk through.

• Plan system implementation.

• Prepare a conversion schedule and target date.

• Determine training procedures, courses and timetable.

• Devise a test and implementation plan and specify any new hardware/software

Dept. of CSE,CIT,GUBBI Page 8


Dice Game 2022-23

CHAPTER 5

SYSTEM IMPLEMENTATION

MAIN ACTIVITY XML CODE

<?xml version="1.0" encoding="utf-8"?>

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"

xmlns:app="http://schemas.android.com/apk/res-auto"

xmlns:tools="http://schemas.android.com/tools"

android:layout_width="match_parent"

android:layout_height="match_parent"

tools:context=".MainActivity">

<TextView

android:id="@+id/tvVar2"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_centerHorizontal="true"

android:layout_marginBottom="40dp"

android:fontFamily="sans-serif-black"

android:gravity="center"

android:text="Dice Game"

android:textSize="40dp"

android:textStyle="bold" />

Dept. of CSE,CIT,GUBBI Page 9


Dice Game 2022-23

<TextView

android:id="@+id/tvVar1"

android:layout_width="match_parent"

android:layout_height="60dp"

android:layout_below="@+id/tvVar2"

android:fontFamily="sans-serif-smallcaps"

android:gravity="center"

android:text="WINNER : Player 1"

android:textAlignment="center"

android:textColor="@color/gradStop"

android:textSize="35dp" />

<LinearLayout

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:layout_below="@+id/tvVar1"

android:layout_marginTop="40dp"

android:orientation="vertical">

<LinearLayout

android:layout_width="wrap_content"

android:layout_height="50dp"

android:layout_gravity="center"

android:layout_marginBottom="40dp"

android:orientation="horizontal">

Dept. of CSE,CIT,GUBBI Page 10


Dice Game 2022-23

<TextView

android:layout_width="140dp"

android:layout_height="50dp"

android:layout_gravity="center"

android:gravity="center"

android:padding="10dp"

android:text="Player 1"

android:textAlignment="center"

android:textColor="#000000"

android:textSize="25dp" />

<TextView

android:layout_width="140dp"

android:layout_height="50dp"

android:layout_gravity="center"

android:gravity="center"

android:padding="10dp"

android:text="Player 2"

android:textAlignment="center"

android:textColor="#000000"

android:textSize="25dp" />

Dept. of CSE,CIT,GUBBI Page 11


Dice Game 2022-23

<TextView

android:layout_width="140dp"

android:layout_height="50dp"

android:layout_gravity="center"

android:gravity="center"

android:padding="10dp"

android:text="Player 3"

android:textAlignment="center"

android:textColor="#000000"

android:textSize="25dp" />

</LinearLayout>

<LinearLayout

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_gravity="center"

android:orientation="horizontal">

<ImageView

android:id="@+id/ivVar1"

android:layout_width="140dp"

android:layout_height="140dp"

android:padding="10dp"

android:src="@drawable/dice6" />

Dept. of CSE,CIT,GUBBI Page 12


Dice Game 2022-23

<ImageView

android:id="@+id/ivVar2"

android:layout_width="140dp"

android:layout_height="140dp"

android:padding="10dp"

android:src="@drawable/dice6" />

<ImageView

android:id="@+id/ivVar3"

android:layout_width="140dp"

android:layout_height="140dp"

android:padding="10dp"

android:src="@drawable/dice6"

tools:ignore="ContentDescription" />

</LinearLayout>

<Button

android:id="@+id/btVar1"

android:layout_width="wrap_content"

android:layout_height="65dp"

android:layout_gravity="center"

android:layout_marginTop="60dp"

android:background="@drawable/btn_bg"

android:gravity="center"

android:padding="12dp"

Dept. of CSE,CIT,GUBBI Page 13


Dice Game 2022-23

android:text="Roll the Dice"

android:textAlignment="center"

android:textColor="#ffffff"

android:textSize="30dp" />

</LinearLayout>

</RelativeLayout>

MAIN ACTIVITY JAVA CODE

package com.example.dicegame;

import androidx.appcompat.app.AppCompatActivity;

import android.annotation.SuppressLint;

import android.os.Bundle;

import android.view.View;

import android.widget.Button;

import android.widget.ImageView;

import android.widget.TextView;

import java.util.Random;

public class MainActivity extends AppCompatActivity {

public static Button button;

public static TextView textView;

public static ImageView img1, img2, img3;

@SuppressLint("MissingInflatedId")

@Override

Dept. of CSE,CIT,GUBBI Page 14


Dice Game 2022-23

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main);

// array to store dice images

final int dice[] = {R.drawable.dice1, R.drawable.dice2, R.drawable.dice3,

R.drawable.dice4, R.drawable.dice5, R.drawable.dice6};

// linking the roll button from its id..

button = findViewById(R.id.btVar1);

// linking the result textview from its id..

textView = findViewById(R.id.tvVar1);

// linking both the imageView of

// the dice images from its id..

img1 = findViewById(R.id.ivVar1);

img2 = findViewById(R.id.ivVar2);

img3 = findViewById(R.id.ivVar3);

// call the on click function button.setOnClickListener(new

View.OnClickListener() {

@Override

public void onClick(View v) {

// generate two random numbers

// using Random function

Random random = new Random();

int num1 = random.nextInt(6);

Dept. of CSE,CIT,GUBBI Page 15


Dice Game 2022-23

Random random1 = new Random();

int num2 = random.nextInt(6);

Random random2 = new Random();

int num3 = random.nextInt(6);

// the bigger number will be displayed in the

// textView as the winner otherwise draw..

if ((num1 > num2) && (num1 > num3)) {

textView.setText("WINNER : Player 1");

} else if ((num2 > num3) && (num2 > num1)) {

textView.setText("WINNER : Player 2");

} else if((num3 > num1) && (num3 > num2)){

textView.setText("WINNER : Player 3");

} else {

textView.setText("RESULT : Draw");

// set the images from the array by the index

// position of the numbers generated

img1.setImageResource(dice[num1]);

img2.setImageResource(dice[num2]);

img3.setImageResource(dice[num3]);

});

Dept. of CSE,CIT,GUBBI Page 16


Dice Game 2022-23

CHAPTER 6

TESTING

Testing is a process of executing a program with the intent of finding an error.esting is a crucial
element of software quality assurance and presents ultimatereview of specification, design and
coding. System Testing is an important phase.Testing represents an interesting anomaly for the
software. A good test case is one that has a high probability of finding an as undiscovered error.

Test levels

The test approach is divided into three main phases: Module testing, integration testing and
system testing. In addition, the system testing includes two sub-phases:functional and usability
testing. These planned tests are explained briefly below.

1. Module testing will perform during coding by using debug messages to check that the
written code produces wanted results. An important requirement is that the code will compile
with zerobugs.

2. Integration testing will perform after finish module testing in order to validate if each
module can work fine with each other. Integration Test proves that system works as integrated
unit when all the fixes are complete.

3. System testing includes two phases: functional testing and usability testing. These will

perform after the product reaches its final version. During functional test phase,the tester will
test if the product meets the equirements.

4. Acceptance testing is a software testing technique used to determine whether a system meets

its specified requirements and is ready for deployment. It is the final phase of testing before a
software product is delivered to the end-users or stakeholders.

The purpose of acceptance testing is to evaluate the system's compliance with business
requirements and ensure that it functions as intended. It is typically performed by the end-users
or client representatives in a real-world environment, simulating real-world scenarios and
usage.

Dept. of CSE,CIT,GUBBI Page 17


Dice Game 2022-23

CHAPTER 7

OUTPUT

Fig 6.1:Three players getting same number

Fig 6.2:Two players getting same number

Dept. of CSE,CIT,GUBBI Page 18


Dice Game 2022-23

Fig 6.3:Player 2 win

Fig 6.4:Player 1 win

Dept. of CSE,CIT,GUBBI Page 19


Dice Game 2022-23

Fig 6.5:Player 3 win

Dept. of CSE,CIT,GUBBI Page 20


Dice Game 2022-23

CHAPTER 8

CONCLUSION
The outcome of a dice game heavily relies on chance and randomness. Each roll of the
dice is independent of the previous rolls, meaning that there is no way to predict or manipulate
the result. This aspect adds excitement and unpredictability to the game. The probability of
rolling a specific number or combination of numbers can be calculated based on the number of
sides on the dice and the total number of possible outcomes. This knowledge can be used to
develop strategies or make informed decisions during the game. While dice games are
predominantly governed by luck, certain strategies can be employed to maximize the chances
of winning. These strategies often involve analyzing the probabilities, managing risks, and
making optimal decisions based on the current game state. In summary, dice games provide a
balance between luck and strategy, offering an enjoyable and entertaining experience for
players. The element of randomness ensures that each game is unique and unpredictable, while
knowledge of probabilities and strategic decision-making can enhance the chances of success.
Ultimately, dice games continue to be a timeless and engaging form of entertainment for players
worldwide.

Dept. of CSE,CIT,GUBBI Page 21


Dice Game 2022-23

CHAPTER 9

REFERENCES

Book References

[1] Google Developer Training, "Android Developer Fundamentals Course concept


Reference”, Google Developer Training Team, 2017.

[2] Erik Hellman, “Android Programming – Pushing the Limits”, 1st Edition, Wiley India Pvt
Ltd, 2014. ISBN-13: 978-8126547197.

[3] Dawn Griffiths and David Griffiths, “Head First Android Development”, 1st Edition,
O’Reilly

[4] SPD Publishers, 2015. ISBN-13: 978-9352131341.

[5] Bill Phillips, Chris Stewart and Kristin Marsicano, “Android Programming: The Big Nerd

Ranch Guide”, 3rd Edition, Big Nerd Ranch Guides, 2017. ISBN-13: 978-0134706054.

Web References

[1] Android Developers https://developer.android.com/

[2] Android Tutorial https://www.tutorialspoint.com/android/index.htm

[3] Android Tutorial https://www.w3schools.in/category/android-tutorial/

[4] Java Tutorial https://www.javatpoint.com/java-tutorial

Java Tutorial https://www.w3schools.com/java

Dept. of CSE,CIT,GUBBI Page 22

You might also like