Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Synopsis tic tac toe
1. Title:Tic Tac Toe
A Project Report for Summer Industrial Training
Submitted by:
1.>ARBAAZ ASLAM (NARULA INSTITUTE OF TECHNOLOGY),
2.>JUNAID AHSAN (BPPIMT, KOLKATA) and
3.>SYED HOZAIFA ALI (BPPIMT, KOLKATA).
In partial fulfillment for the award of the degree of
Summer Industrial Training 2017
At
Ogma TechLab Pvt. Ltd.
June-July 2017
2. Ogma TechLab Pvt. Ltd
BONAFIDE CERTIFICATE
Certified that this project work was carried out under my supervision
“Tic Tac Toe” is the bona fide work of
Name of the student: SYED HOZAIFA ALI Signature:
Name of the student: JUNAID ASHSAAN Signature:
Name of the student: ARBAAZ ASLAM Signature:
PROJECT MENTOR:AMAR BANERJEE
SIGNATURE:
OgmaTech Lab Original Seal:
3. Acknowledgement
I take this opportunity to express my deep gratitude and
sincerest thank you to my project mentor, Mr Amar Banerjee for
giving most valuable suggestion, helpful guidance and
encouragement in the execution of this project work.
I will like to give a special mention to my colleagues. Last but
not the least I am grateful to all the faculty members of OGMA
TECH LAB Pvt. Ltd. for their support.
4. INDEX
Table of Contents Page No
• Abstract
• Introduction of the Project
• Objectives
• Tools/Platform, Hardware and Software Requirement
specifications Goals of Implementation.
• Overview.
• Codes (Manifest codes, xml codes).
DFD.
• Use Case Diagram.
Future scope and further enhancement of the Project.
• Testing.
• Conclusion.
ABSTRACTION
Tic-tac-toe
5. A completed game of Tic-tac-toe
Genre(s) Paper-and-pencil game
Players 2
Setup time Minimal
Playing time ~1 minute
Random chance None
Skill(s) required Strategy, tactics, observation
Synonym(s) Naught and crosses
Xs and Os
Tic-tac-toe (also known as naughtand crossesor Xs and Os) is a paper-and-pencil game for two players, X and O, who take turns marking the spaces in a 3×3
grid. The play er who succeeds in placing three of their marks in a horizontal, vertical, or diagonal row wins the game.
The f ollowing example gameis won by thefirst player, X:
Play ers soon discover that best play from both parties leads to a draw. Hence, tic-tac-toe is most often played by youngchildren.
INTRODUCTION
Because of the simplicity of tic-tac-toe, it is often used as a pedagogical tool for teaching the concepts of
good sportsmanship and the branch of artificial intelligence that deals with the searching of game trees. It
is straightforward to write a computer program to play tic-tac-toe perfectly, to enumerate the 765
6. essentially different positions (the state space complexity), or the 26,830 possible games up to rotations
and reflections (the game tree complexity) on this space.
The game can be generalized to an m, n, k-game in which two players alternate placing stones of their
own color on an m ×n board, with the goal of getting k of their own color in a row. Tic-tac-toe is the
(3,3,3)-game. Harary's generalized tic-tac-toe is an even broader generalization of tic tac toe. It can also
be generalized as nd game. Tic-tac-toe is the game where n equals 3 and d equals 2. If played properly,
the game will end in a draw making tic-tac-toe a futile game.
OBJECTIVES:
An app which can fulfill your gaming requirements.
Forget about papers and pencil, thus environmental friendly.
Fun is a portable story with this type of app.
With less space on your hard disk install and play instantly.
Tools/Platform, Hardwareand Software Requirement
specifications.
Tools
• Android Studio(Software)
• Android Phone
Platform
Windows 7/8/10
Hardware Requirement Specification
Criterion Description
Disk Space 500 MB diskspace for
Android Studio,atleast
1.5 GB for AndroidSDK,
emulatorsystem
images,andcaches
RAM 3 GB RAM minimum, 8
7. GB RAMrecommended;
plus1 GB for the
AndroidEmulator
Java Version Java DevelopmentKit(JDK) 8
Software Requirement Specification
• Java -> Java SE
• Android SDK -> Android Studio and SDK Tools
OVERVIEW
• The project is aimed at creating efficiency of the students forthose who have no basic idea about
the game “tic tac toe” and thus this android application will help the students to learn according to their
time and polish their skill.
• The idea is to increase efficiency and reduce the learning time in most effective way for the
students.This would make the learners to use mobile phone and polish their skills in programming
languages in this era of technology advancement.
CODES
package com.example.junaidahsan.tictactoe;
import android.graphics.Color;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;
public class Act1 extends AppCompatActivity implements View.OnClickListener {
int turn_count = 0;
Button[] bArray = null;
Button a1, a2, a3, b1, b2, b3, c1, c2, c3;
boolean turn=true;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_act1);
a1 = (Button) findViewById(R.id.A1);
b1 = (Button) findViewById(R.id.B1);
c1 = (Button) findViewById(R.id.C1);
a2 = (Button) findViewById(R.id.A2);
b2 = (Button) findViewById(R.id.B2);
8. c2 = (Button) findViewById(R.id.C2);
a3 = (Button) findViewById(R.id.A3);
b3 = (Button) findViewById(R.id.B3);
c3 = (Button) findViewById(R.id.C3);
bArray = new Button[] { a1, a2, a3, b1, b2, b3, c1, c2, c3 };
for (Button b : bArray)
b.setOnClickListener(this);
Button bnew = (Button) findViewById(R.id.button1);
bnew.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
turn = true;
turn_count = 0;
enableOrDisable(true);
}
});
}
@Override
public void onClick(View v) {
// just to be clear. as no other views are registered YET,
// it is safe to assume that only
// the 9 buttons call this on click
buttonClicked(v);
}
private void buttonClicked(View v) {
Button b = (Button) v;
if (turn) {
// X's turn
b.setText("X");
} else {
// O's turn
b.setText("O");
}
turn_count++;
b.setClickable(false);
b.setBackgroundColor(Color.LTGRAY);
turn = !turn;
checkForWinner();
}
private void checkForWinner() {
// NOOB TECHNIQUE...
// if used repeatedly, causes several mental injuries
// dont try this at home
boolean there_is_a_winner = false;
// horizontal:
if (a1.getText() == a2.getText() && a2.getText() == a3.getText()
&& !a1.isClickable())
there_is_a_winner = true;
else if (b1.getText() == b2.getText() && b2.getText() == b3.getText()
&& !b1.isClickable())
there_is_a_winner = true;
else if (c1.getText() == c2.getText() && c2.getText() == c3.getText()
&& !c1.isClickable())
9. there_is_a_winner = true;
// vertical:
else if (a1.getText() == b1.getText() && b1.getText() == c1.getText()
&& !a1.isClickable())
there_is_a_winner = true;
else if (a2.getText() == b2.getText() && b2.getText() == c2.getText()
&& !b2.isClickable())
there_is_a_winner = true;
else if (a3.getText() == b3.getText() && b3.getText() == c3.getText()
&& !c3.isClickable())
there_is_a_winner = true;
// diagonal:
else if (a1.getText() == b2.getText() && b2.getText() == c3.getText()
&& !a1.isClickable())
there_is_a_winner = true;
else if (a3.getText() == b2.getText() && b2.getText() == c1.getText()
&& !b2.isClickable())
there_is_a_winner = true;
// i repeat.. DO NOT TRY THIS AT HOME
if (there_is_a_winner) {
if (!turn)
message("X wins");
else
message("O wins");
enableOrDisable(false);
} else if (turn_count == 9)
message("Draw!");
}
private void message(String text) {
Toast.makeText(getApplicationContext(), text, Toast.LENGTH_SHORT)
.show();
}
private void enableOrDisable(boolean enable) {
for (Button b : bArray) {
b.setText("");
b.setClickable(enable);
if (enable) {
b.setBackgroundColor(Color.parseColor("#33b5e5"));
} else {
b.setBackgroundColor(Color.LTGRAY);
}
}
}
}
package com.example.user.login;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.PopupMenu;
import android.widget.TextView;
10. import android.widget.Toast;
public class Act2 extends AppCompatActivity {
TextView editText;
Button btn;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_act2);
btn=(Button)findViewById(R.id.btn);
editText=(TextView)findViewById(R.id.editText);
Bundle b=getIntent().getExtras();
String Username=b.getString("username");
String Password=b.getString("password");
editText.setText("Username is :"+Username+"and Password is :"+Password);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu);
getMenuInflater().inflate(R.menu.menu,menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()){
case R.id.menu1:
Toast toast=Toast.makeText(getApplicationContext(),"MENU 1 IS
sELECTED",Toast.LENGTH_LONG);
toast.show();
return true;
case R.id.menu2:
Toast toast1=Toast.makeText(getApplicationContext(),"MENU 1 IS
sELECTED",Toast.LENGTH_LONG);
toast1.show();
return true;
case R.id.menu3:
Toast toast2=Toast.makeText(getApplicationContext(),"MENU 1 IS
sELECTED",Toast.LENGTH_LONG);
toast2.show();
return true;
default:return super.onOptionsItemSelected(item);
}
}
public void popup(View view){
PopupMenu popupMenu = new PopupMenu(Act2.this,btn);
popupMenu.getMenuInflater().inflate(R.menu.popup,popup(););
}
}
MANIFEST codes:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
14. USE CASE DIAGRAM
FURTHER ENHANCEMENT
Using the code
The solution has three projects - TicTacToeLib is the main project and it contains all the gamelogic is the test project, and TicTacToe is a Windows Forms project to
display the game, but it can easily be replaced by any other GUI project type (WPF, Web, etc).
15. Two classes handle thegamelogic - Boardand Field. Boardis a container of Fields.
The Fieldclass' only purpose is to keep information about its status. It can be EMPTY, which is the default value,or PLAYER1/PLAYER2.
Whenever status is changed, the FieldStatusChangedevent is fired.
public class Field
{
private FIELD_STATUS _fieldStatus;
public event EventHandler FieldStatusChanged;
// some code omitted
public FIELD_STATUS FieldStatus
{
get
{
return _fieldStatus;
}
set
{
if (value != _fieldStatus)
{
_fieldStatus = value;
OnFieldStatusChanged();
}
}
The Boardclass listens to FieldStatusChanged events from its Fieldscollection and checks for end game conditions. Event handlers
are created after fieldsfor each field in the Boardclass.
Hide Copy Code
private void AddFieldEventListeners()
{
for (int i = 0; i < _fields.GetLength(0); i++)
{
for (int j = 0; j < _fields.GetLength(1); j++)
{
_fields[i, j].FieldStatusChanged += Board_FieldStatusChanged;
}
}
16. }
From game rules we can definefive end gameconditions:
Win condition when all fields in the same row belong to one player. In code terms, all field status inPLAYER1or PLAYER2are in the same row.
Win condition when all fields in the same column belong to one player
Win condition when all fields in the main diagonal belong to one player
Win condition when all fields are in anti-diagonal belonging to one player
Tie condition when all fields have a value other than EMPTY, but no win conditions apply.
Whenever status in any field changes, the CheckWinConditionmethod is invoked in the Boardclass. If any win condition or tie is applicable,
board fires the GameEndevent. As a parameter, event sends the GameStatusclass which is a simple two enum collection withinformation about the
winning player and the win condition. The caller should handle it appropriately - in this example, theWindows Form disablesall controls used to display fields,
displays the game result, and highlights the winning row, column, or diagonal.
And finally testing. Since classes Fieldand GameStatusare simple, only the Boardclass is covered with tests. There arenine testsin
the BoardTests class. First three check if the Board class throws exceptions with a bad constructor parameter.
[TestMethod]
[ExpectedException(typeof(ArgumentNullException))]
17. public void TestConstructorFieldNull()
{
Board board = new Board(null);
}
[TestMethod]
[ExpectedException(typeof(ArgumentException))]
public void TestConstructorFieldNotSquareMatrix()
{
Field[,] fields = new Field[2, 3];
fields[0, 0] = new Field();
fields[0, 1] = new Field();
fields[0, 2] = new Field();
fields[1, 0] = new Field();
fields[1, 1] = new Field();
fields[1, 2] = new Field();
Board board = new Board(fields);
}
[TestMethod]
[ExpectedException(typeof(ArgumentNullException))]
public void TestConstructorNullFieldsInMatrix()
{
Field[,] fields = new Field[3, 3];
fields[0, 0] = new Field();
fields[0, 1] = new Field();
fields[0, 2] = new Field();
fields[1, 0] = new Field();
fields[1, 1] = null;
fields[1, 2] = new Field();
fields[2, 0] = new Field();
fields[2, 1] = new Field();
fields[2, 2] = new Field();
Board board = new Board(fields);
}
The forth test tests if the Fieldscollection is successfully set as theclass Fieldsproperty.
Hide Copy Code
[TestMethod]
public void TestConstructorRegularCase()
{
Field[,] fields = new Field[3, 3];
fields[0, 0] = new Field();
fields[0, 1] = new Field();
fields[0, 2] = new Field();
fields[1, 0] = new Field();
fields[1, 1] = new Field();
fields[1, 2] = new Field();
fields[2, 0] = new Field();
fields[2, 1] = new Field();
fields[2, 2] = new Field();
Board board = new Board(fields);
18. Assert.AreEqual(fields.GetLength(0), board.Fields.GetLength(0));
Assert.AreEqual(fields.GetLength(1), board.Fields.GetLength(1));
}
The last five tests simulate and test win conditions. All testshave threeparts,first the Boardobject construction:
Hide Copy Code
[TestMethod]
public void TestAllFieldsInRowWinCondition()
{
Field[,] fields = new Field[3, 3];
fields[0, 0] = new Field() { FieldStatus = FIELD_STATUS.EMPTY };
fields[0, 1] = new Field() { FieldStatus = FIELD_STATUS.EMPTY };
fields[0, 2] = new Field() { FieldStatus = FIELD_STATUS.EMPTY };
fields[1, 0] = new Field() { FieldStatus = FIELD_STATUS.EMPTY };
fields[1, 1] = new Field() { FieldStatus = FIELD_STATUS.EMPTY };
fields[1, 2] = new Field() { FieldStatus = FIELD_STATUS.EMPTY };
fields[2, 0] = new Field() { FieldStatus = FIELD_STATUS.EMPTY };
fields[2, 1] = new Field() { FieldStatus = FIELD_STATUS.EMPTY };
fields[2, 2] = new Field() { FieldStatus = FIELD_STATUS.EMPTY };
Board board = new Board(fields);
Second, the event handler is created for the Board GameEnd event. When the event is fired, it will assert if the board returned the correct win
parameters:
Hide Copy Code
board.GameEnd += (sender, e) =>
{
Assert.AreEqual(GAME_STATUS.PLAYER_ONE_WON, e.GameProgress);
Assert.AreEqual(WIN_CONDITION.ROW, e.WinCondition);
Assert.AreEqual(0, e.WinRowOrColumn);
};
Third, the game is simulated by changing the board field status:
Hide Copy Code
fields[0, 0].FieldStatus = FIELD_STATUS.PLAYER1;
// [X] [ ] [ ]
// [ ] [ ] [ ]
// [ ] [ ] [ ]
fields[1, 1].FieldStatus = FIELD_STATUS.PLAYER2;
// [X] [ ] [ ]
// [ ] [0] [ ]
// [ ] [ ] [ ]
fields[0, 1].FieldStatus = FIELD_STATUS.PLAYER1;
// [X] [X] [ ]
// [ ] [0] [ ]
// [ ] [ ] [ ]
fields[2, 2].FieldStatus = FIELD_STATUS.PLAYER2;
// [X] [X] [ ]
// [ ] [0] [ ]
// [ ] [ ] [0]
fields[0, 2].FieldStatus = FIELD_STATUS.PLAYER1;
// [X] [X] [X]
// [ ] [0] [ ]
19. // [ ] [ ] [ ]
TESTING
. Testing
Team Interaction
The following describes the level of team interaction necessary to have a successful product.
The Test Team will work closely with the Development Team to achieve a high quality design and user
interface specifications based on customer requirements. The Test Teamis responsible for visualizing test cases
and raising quality issues and concerns during meetings to address issues early enough in the development
cycle.
The Test Team will work closely with Development Team to determine whether or not the application meets
standards for completeness. If an area is not acceptable for testing, the code complete date will be pushed out,
giving the developers additional time to stabilize the area.
Since the application interacts with a back-end system component, the Test Teamwill need to include a plan for
integration testing. Integration testing must be executed successfully prior to systemtesting.
Test Objective
The objective our test plan is to find and report as many bugs as possible to improve the integrity of our program.
Conclusion:
Gaming becomes modern when played on tabs, mobiles etc .Enjoy with your friend , anytime and anyplace.