Skip to content

Commit

Permalink
Removed unnecessary imports
Browse files Browse the repository at this point in the history
  • Loading branch information
sfbahr committed May 1, 2014
2 parents d3b9121 + 2c2bfe0 commit 6e3e607
Show file tree
Hide file tree
Showing 19 changed files with 100 additions and 5 deletions.
Binary file modified Project Files/bin/UltimateTic.apk
Binary file not shown.
Binary file modified Project Files/bin/classes.dex
Binary file not shown.
Binary file modified Project Files/bin/classes/cs2114/ultimatetic/AIGrid.class
Binary file not shown.
Binary file modified Project Files/bin/classes/cs2114/ultimatetic/AIGridTest.class
Binary file not shown.
Binary file modified Project Files/bin/classes/cs2114/ultimatetic/Grid.class
Binary file not shown.
Binary file modified Project Files/bin/classes/cs2114/ultimatetic/GridTest.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified Project Files/bin/resources.ap_
Binary file not shown.
26 changes: 26 additions & 0 deletions Project Files/src/cs2114/ultimatetic/AIGrid.java
Original file line number Diff line number Diff line change
Expand Up @@ -1333,4 +1333,30 @@ public boolean playOppositeCorner()
}


public boolean playEmptyCorner()
{
if (this.getCell(board[0], board[1]) == Cell.EMPTY)
{
super.setCell(board[0], board[1]);
return true;
}
if (this.getCell(board[0] + 2, board[1]) == Cell.EMPTY)
{
super.setCell(board[0] + 2, board[1]);
return true;
}
if (this.getCell(board[0], board[1] + 2) == Cell.EMPTY)
{
super.setCell(board[0], board[1] + 2);
return true;
}
if (this.getCell(board[0] + 2, board[1] + 2) == Cell.EMPTY)
{
super.setCell(board[0] + 2, board[1] + 2);
return true;
}
return false;

}

}
23 changes: 23 additions & 0 deletions Project Files/src/cs2114/ultimatetic/AIGridTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -824,4 +824,27 @@ public void testPlayOppositeCorner()
assertTrue(AI.playOppositeCorner());
}

public void testEmptyCorner()
{
String grid = "BEBEEEBEE";
AI.getBoard(2, 2).fromString(grid);
AI.whichIsPlayable();
assertTrue(AI.playEmptyCorner());

String grid1 = "BEBEEEEEB";
AI.getBoard(2, 2).fromString(grid1);
AI.whichIsPlayable();
assertTrue(AI.playEmptyCorner());

String grid2 = "BEEEEEBEB";
AI.getBoard(2, 2).fromString(grid2);
AI.whichIsPlayable();
assertTrue(AI.playEmptyCorner());

String grid3 = "EEBEEEBEB";
AI.getBoard(2, 2).fromString(grid3);
AI.whichIsPlayable();
assertTrue(AI.playEmptyCorner());
}

}
7 changes: 4 additions & 3 deletions Project Files/src/cs2114/ultimatetic/Grid.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package cs2114.ultimatetic;

import java.util.Random;
import sofia.util.Random;
import java.util.Stack;

// -------------------------------------------------------------------------
Expand All @@ -19,6 +19,7 @@ public class Grid

private Cell turn;
private Stack<int[]> moves;
private static Random random = sofia.util.Random.generator();


/**
Expand Down Expand Up @@ -483,8 +484,8 @@ public int[] playRandom()
|| !this.getBoard(x / 3, y / 3).getIsPlayable())
&& this.getWhoHasWon() == Cell.EMPTY)
{
x = new Random().nextInt(9);
y = new Random().nextInt(9);
x = random.nextInt(9);
y = random.nextInt(9);
}
int[] coords = { x, y };
return coords;
Expand Down
14 changes: 14 additions & 0 deletions Project Files/src/cs2114/ultimatetic/GridTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package cs2114.ultimatetic;

import sofia.util.Random;
import junit.framework.TestCase;

// -------------------------------------------------------------------------
Expand Down Expand Up @@ -552,4 +553,17 @@ public void testUndoMove()


}

// ----------------------------------------------------------
/**
* Tests playRandom()
*/
public void testPlayRandom()
{
int[] ints = new int[] {0, 0};
Random.setNextInts(0, 0);
int[] ints2 = g1.playRandom();
assertEquals(ints[0], ints2[0]);
assertEquals(ints[1], ints2[1]);
}
}
33 changes: 33 additions & 0 deletions Project Files/src/cs2114/ultimatetic/RandomAIGridTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package cs2114.ultimatetic;

import student.TestCase;

public class RandomAIGridTest extends TestCase
{

RandomAIGrid random;

/*public RandomAIGridTest()
{
// TODO Auto-generated constructor stub
}
*/

public void setUp()
{
random = new RandomAIGrid();
}

public void testSetCell()
{
assertTrue(random.setCell(0, 0));
}

public void testUndoMove()
{
assertFalse(random.undoMove());
random.setCell(0, 0);
assertTrue(random.undoMove());
}

}
2 changes: 0 additions & 2 deletions Project Files/src/cs2114/ultimatetic/TacGameScreenTests.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package cs2114.ultimatetic;

import android.widget.Button;
import sofia.app.Screen;
import sofia.graphics.ShapeView;

/**
Expand Down

0 comments on commit 6e3e607

Please sign in to comment.