Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Play vs computer, splash page

  • Loading branch information...
commit 4a8104d773031cbb15802ac9dfd0fa7ad0e330ea 1 parent e808237
@Neugebauer Neugebauer authored
View
8 .classpath
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="src" path="gen"/>
+ <classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
+ <classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
+ <classpathentry kind="output" path="bin/classes"/>
+</classpath>
View
33 .project
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>ThreeBy3Activity</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>com.android.ide.eclipse.adt.ApkBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>com.android.ide.eclipse.adt.AndroidNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
View
5 .settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,5 @@
+#Mon Jan 30 20:33:04 EST 2012
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.source=1.5
View
16 AndroidManifest.xml
@@ -10,14 +10,20 @@
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
- android:name=".ThreeBy3Activity"
- android:label="@string/app_name" >
- <intent-filter>
+ android:name=".Splash"
+ android:label="@string/app_name">
+ <intent-filter >
<action android:name="android.intent.action.MAIN" />
-
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
+ <activity
+ android:name=".ThreeBy3Activity"
+ android:label="@string/app_name">
+ <intent-filter>
+ <action android:name="com.example.thor.threeby3.THREEBY3ACTIVITY" />
+ <category android:name="android.intent.category.DEFAULT" />
+ </intent-filter>
+ </activity>
</application>
-
</manifest>
View
BIN  res/drawable-hdpi/tttsplash.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
6 res/layout/main.xml
@@ -167,5 +167,11 @@
android:layout_gravity="center"
android:gravity = "center">
</TextView>
+
+ <CheckBox
+ android:id="@+id/checkBoxAI"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="Vs Computer" />
</TableLayout>
View
8 res/layout/splash.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="vertical"
+ android:background = "@drawable/tttsplash"
+ >
+</LinearLayout>
View
39 src/com/example/thor/threeby3/Splash.java
@@ -0,0 +1,39 @@
+package com.example.thor.threeby3;
+
+import android.app.Activity;
+import android.content.Intent;
+//import android.media.MediaPlayer;
+import android.os.Bundle;
+
+public class Splash extends Activity{
+
+// MediaPlayer ourSong;
+ @Override
+ protected void onCreate(Bundle TTTTime) {
+ super.onCreate(TTTTime);
+// ourSong = MediaPlayer.create(Splash.this, R.raw.tttsplash);
+// ourSong.start();
+ setContentView(R.layout.splash);
+ Thread timer = new Thread(){
+ public void run(){
+ try{
+ sleep(3000);
+ } catch(InterruptedException e) {
+ e.printStackTrace();
+ } finally {
+ Intent openStartingPoint = new Intent("com.example.thor.threeby3.THREEBY3ACTIVITY");
+ startActivity(openStartingPoint);
+ }
+ }
+ };
+ timer.start();
+ }
+
+// @Override
+// protected void onPause() {
+// // TODO Auto-generated method stub
+// super.onPause();
+// ourSong.release();
+// finish();
+// }
+}
View
556 src/com/example/thor/threeby3/ThreeBy3Activity.java
@@ -1,6 +1,9 @@
package com.example.thor.threeby3;
+import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
import android.app.Activity;
import android.graphics.LightingColorFilter;
import android.hardware.Sensor;
@@ -8,11 +11,14 @@
import android.hardware.SensorEventListener;
import android.hardware.SensorManager;
import android.os.Bundle;
+import android.util.Log;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
+import android.widget.CheckBox;
+import android.widget.CompoundButton;
import android.widget.TextView;
public class ThreeBy3Activity extends Activity implements SensorEventListener {
@@ -20,9 +26,11 @@
public String playername = "X", startingplayer = "X";
public int rows = 3, cols = 3, moves, xscore, oscore, tscore;
public int pointcount[] = new int[8]; //R1,R2,R3,C1,C2,C3,DD,DU
- public boolean gameover = false;
+ public boolean gameover = false, computeropponent = false;
+ public List<Integer> squares = new ArrayList<Integer>(Arrays.asList(0,1,2,3,4,5,6,7,8)); //TL,TM,TR,ML,MM,MR,BL,BM,BR
private SensorManager sensMgr;
private Sensor accelerometer;
+ //private static final String TAG = "MyActivity";
/** Called when the activity is first created. */
@Override
@@ -35,6 +43,17 @@ public void onCreate(Bundle savedInstanceState) {
tv.setText("Player " + playername + "'s turn");
TextView tvs = (TextView) findViewById(R.id.textViewScore);
tvs.setText("Score: X:0 O:0 Tie:0");
+ CheckBox cbAI =(CheckBox)findViewById(R.id.checkBoxAI);
+ cbAI.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
+ public void onCheckedChanged(CompoundButton arg0, boolean arg1) {
+ if (arg1) {
+ computeropponent = true;
+ }
+ else {
+ computeropponent = false;
+ }
+ }
+ });
}
protected void onResume() {
@@ -62,6 +81,8 @@ public void claimSquare(View view) {
}
else {
pvalue = 1;
+ if (computeropponent == true)
+ button.setTextColor(0xFFA4C639);
button.getBackground().setColorFilter(new LightingColorFilter(0xFFEEEEEE, 0xFF0000FF));
button.setText("O");
}
@@ -70,43 +91,52 @@ public void claimSquare(View view) {
pointcount[0] += pvalue; //R1
pointcount[3] += pvalue; //C1
pointcount[6] += pvalue; //DD
+ squares.remove(new Integer(0));
break;
case R.id.TopMiddle:
pointcount[0] += pvalue; //R1
pointcount[4] += pvalue; //C2
+ squares.remove(new Integer(1));
break;
case R.id.TopRight:
pointcount[0] += pvalue; //R1
pointcount[5] += pvalue; //C3
pointcount[7] += pvalue; //DU
+ squares.remove(new Integer(2));
break;
case R.id.MiddleLeft:
pointcount[1] += pvalue; //R2
pointcount[3] += pvalue; //C1
+ squares.remove(new Integer(3));
break;
case R.id.MiddleMiddle:
pointcount[1] += pvalue; //R2
pointcount[4] += pvalue; //C2
pointcount[6] += pvalue; //DD
pointcount[7] += pvalue; //DU
+ squares.remove(new Integer(4));
break;
case R.id.MiddleRight:
pointcount[1] += pvalue; //R2
pointcount[5] += pvalue; //C3
+ squares.remove(new Integer(5));
break;
case R.id.BottomLeft:
pointcount[2] += pvalue; //R3
pointcount[3] += pvalue; //C1
pointcount[7] += pvalue; //DU
+ squares.remove(new Integer(6));
break;
case R.id.BottomMiddle:
pointcount[2] += pvalue; //R3
pointcount[4] += pvalue; //C2
+ squares.remove(new Integer(7));
break;
case R.id.BottomRight:
pointcount[2] += pvalue; //R3
pointcount[5] += pvalue; //C3
pointcount[6] += pvalue; //DD
+ squares.remove(new Integer(8));
break;
default:
break;
@@ -135,6 +165,8 @@ public void claimSquare(View view) {
player = (player == R.string.you) ? R.string.me : R.string.you;
playername = (playername == "X") ? "O" : "X";
tv.setText("Player " + playername + "'s turn");
+ if (playername == "O" && computeropponent == true)
+ computerMove();
}
}
}
@@ -169,41 +201,53 @@ public boolean onOptionsItemSelected(MenuItem item) {
private void startOver() {
Button button = (Button) findViewById(R.id.TopLeft);
button.setText("");
+ button.setTextColor(0xFF000000);
button.getBackground().setColorFilter(new LightingColorFilter(0xFFF8F8F8, 0));
button = (Button) findViewById(R.id.TopMiddle);
button.setText("");
+ button.setTextColor(0xFF000000);
button.getBackground().setColorFilter(new LightingColorFilter(0xFFF8F8F8, 0));
button = (Button) findViewById(R.id.TopRight);
button.setText("");
+ button.setTextColor(0xFF000000);
button.getBackground().setColorFilter(new LightingColorFilter(0xFFF8F8F8, 0));
button = (Button) findViewById(R.id.MiddleLeft);
button.setText("");
+ button.setTextColor(0xFF000000);
button.getBackground().setColorFilter(new LightingColorFilter(0xFFF8F8F8, 0));
button = (Button) findViewById(R.id.MiddleMiddle);
button.setText("");
+ button.setTextColor(0xFF000000);
button.getBackground().setColorFilter(new LightingColorFilter(0xFFF8F8F8, 0));
button = (Button) findViewById(R.id.MiddleRight);
button.setText("");
+ button.setTextColor(0xFF000000);
button.getBackground().setColorFilter(new LightingColorFilter(0xFFF8F8F8, 0));
button = (Button) findViewById(R.id.BottomLeft);
button.setText("");
+ button.setTextColor(0xFF000000);
button.getBackground().setColorFilter(new LightingColorFilter(0xFFF8F8F8, 0));
button = (Button) findViewById(R.id.BottomMiddle);
button.setText("");
+ button.setTextColor(0xFF000000);
button.getBackground().setColorFilter(new LightingColorFilter(0xFFF8F8F8, 0));
button = (Button) findViewById(R.id.BottomRight);
button.setText("");
+ button.setTextColor(0xFF000000);
button.getBackground().setColorFilter(new LightingColorFilter(0xFFF8F8F8, 0));
gameover = false;
moves = 0;
Arrays.fill(pointcount, 0);
+ squares.clear();
+ Collections.addAll(squares, 0,1,2,3,4,5,6,7,8);
startingplayer = (startingplayer == "X") ? "O" : "X";
playername = startingplayer;
TextView tv = (TextView) findViewById(R.id.textView1);
tv.setText("Player " + playername + "'s turn");
TextView tvs = (TextView) findViewById(R.id.textViewScore);
tvs.setText("Score: X:" + xscore + " O:" + oscore + " Tie:" + tscore);
- this.player = R.string.you;
+ if (playername == "O" && computeropponent == true)
+ computerMove();
}
public void onAccuracyChanged(Sensor arg0, int arg1) {
@@ -217,6 +261,514 @@ public void onSensorChanged(SensorEvent event) {
return;
}
+ public void randomMove() {
+ Button button;
+ int randomsquare = (int) Math.ceil(Math.random() * (squares.size() - 1));
+ switch(squares.get(randomsquare)) {
+ case 0:
+ button = (Button) findViewById(R.id.TopLeft);
+ button.performClick();
+ break;
+ case 1:
+ button = (Button) findViewById(R.id.TopMiddle);
+ button.performClick();
+ break;
+ case 2:
+ button = (Button) findViewById(R.id.TopRight);
+ button.performClick();
+ break;
+ case 3:
+ button = (Button) findViewById(R.id.MiddleLeft);
+ button.performClick();
+ break;
+ case 4:
+ button = (Button) findViewById(R.id.MiddleMiddle);
+ button.performClick();
+ break;
+ case 5:
+ button = (Button) findViewById(R.id.MiddleRight);
+ button.performClick();
+ break;
+ case 6:
+ button = (Button) findViewById(R.id.BottomLeft);
+ button.performClick();
+ break;
+ case 7:
+ button = (Button) findViewById(R.id.BottomMiddle);
+ button.performClick();
+ break;
+ case 8:
+ button = (Button) findViewById(R.id.BottomRight);
+ button.performClick();
+ break;
+ default:
+ break;
+ }
+ }
+
+ public void computerMove() {
+ Button button;
+ //alternate between easy mode and hard mode depending on who's winning
+ if (oscore >= xscore) {
+ //dumb AI - random selection
+ randomMove();
+ return;
+ }
+ else {
+ //smart AI
+ if (squares.size() == 9) {
+ button = (Button) findViewById(R.id.MiddleMiddle);
+ button.performClick();
+ return;
+ }
+ else {
+ for (int q = 0; q < 8; q++) { //look for O about to win and complete
+ if (pointcount[q] == 2) {
+ switch(q) {
+ case 0: //R1
+ System.out.println("Row1 Check");
+ button = (Button) findViewById(R.id.TopLeft);
+ if (button.getText() == "") {
+ button.performClick();
+ return;
+ }
+ button = (Button) findViewById(R.id.TopMiddle);
+ if (button.getText() == "") {
+ button.performClick();
+ return;
+ }
+ button = (Button) findViewById(R.id.TopRight);
+ if (button.getText() == "") {
+ button.performClick();
+ return;
+ }
+ break;
+ case 1: //R2
+ button = (Button) findViewById(R.id.MiddleLeft);
+ if (button.getText() == "") {
+ button.performClick();
+ return;
+ }
+ button = (Button) findViewById(R.id.MiddleMiddle);
+ if (button.getText() == "") {
+ button.performClick();
+ return;
+ }
+ button = (Button) findViewById(R.id.MiddleRight);
+ if (button.getText() == "") {
+ button.performClick();
+ return;
+ }
+ break;
+ case 2: //R3
+ button = (Button) findViewById(R.id.BottomLeft);
+ if (button.getText() == "") {
+ button.performClick();
+ return;
+ }
+ button = (Button) findViewById(R.id.BottomMiddle);
+ if (button.getText() == "") {
+ button.performClick();
+ return;
+ }
+ button = (Button) findViewById(R.id.BottomRight);
+ if (button.getText() == "") {
+ button.performClick();
+ return;
+ }
+ break;
+ case 3: //C1
+ button = (Button) findViewById(R.id.TopLeft);
+ if (button.getText() == "") {
+ button.performClick();
+ return;
+ }
+ button = (Button) findViewById(R.id.MiddleLeft);
+ if (button.getText() == "") {
+ button.performClick();
+ return;
+ }
+ button = (Button) findViewById(R.id.BottomLeft);
+ if (button.getText() == "") {
+ button.performClick();
+ return;
+ }
+ break;
+ case 4: //C2
+ button = (Button) findViewById(R.id.TopMiddle);
+ if (button.getText() == "") {
+ button.performClick();
+ return;
+ }
+ button = (Button) findViewById(R.id.MiddleMiddle);
+ if (button.getText() == "") {
+ button.performClick();
+ return;
+ }
+ button = (Button) findViewById(R.id.BottomMiddle);
+ if (button.getText() == "") {
+ button.performClick();
+ return;
+ }
+ break;
+ case 5: //C3
+ button = (Button) findViewById(R.id.TopRight);
+ if (button.getText() == "") {
+ button.performClick();
+ return;
+ }
+ button = (Button) findViewById(R.id.MiddleRight);
+ if (button.getText() == "") {
+ button.performClick();
+ return;
+ }
+ button = (Button) findViewById(R.id.BottomRight);
+ if (button.getText() == "") {
+ button.performClick();
+ return;
+ }
+ break;
+ case 6: //DD
+ button = (Button) findViewById(R.id.TopLeft);
+ if (button.getText() == "") {
+ button.performClick();
+ return;
+ }
+ button = (Button) findViewById(R.id.MiddleMiddle);
+ if (button.getText() == "") {
+ button.performClick();
+ return;
+ }
+ button = (Button) findViewById(R.id.BottomRight);
+ if (button.getText() == "") {
+ button.performClick();
+ return;
+ }
+ break;
+ case 7: //DU
+ button = (Button) findViewById(R.id.TopRight);
+ if (button.getText() == "") {
+ button.performClick();
+ return;
+ }
+ button = (Button) findViewById(R.id.MiddleMiddle);
+ if (button.getText() == "") {
+ button.performClick();
+ return;
+ }
+ button = (Button) findViewById(R.id.BottomLeft);
+ if (button.getText() == "") {
+ button.performClick();
+ return;
+ }
+ break;
+ default:
+ break;
+ }
+ }
+ }
+
+ for (int p = 0; p < 8; p++) { //look for X about to win and block
+ if (pointcount[p] == -2) {
+ switch(p) {
+ case 0: //R1
+ button = (Button) findViewById(R.id.TopLeft);
+ if (button.getText() == "") {
+ button.performClick();
+ return;
+ }
+ button = (Button) findViewById(R.id.TopMiddle);
+ if (button.getText() == "") {
+ button.performClick();
+ return;
+ }
+ button = (Button) findViewById(R.id.TopRight);
+ if (button.getText() == "") {
+ button.performClick();
+ return;
+ }
+ break;
+ case 1: //R2
+ button = (Button) findViewById(R.id.MiddleLeft);
+ if (button.getText() == "") {
+ button.performClick();
+ return;
+ }
+ button = (Button) findViewById(R.id.MiddleMiddle);
+ if (button.getText() == "") {
+ button.performClick();
+ return;
+ }
+ button = (Button) findViewById(R.id.MiddleRight);
+ if (button.getText() == "") {
+ button.performClick();
+ return;
+ }
+ break;
+ case 2: //R3
+ button = (Button) findViewById(R.id.BottomLeft);
+ if (button.getText() == "") {
+ button.performClick();
+ return;
+ }
+ button = (Button) findViewById(R.id.BottomMiddle);
+ if (button.getText() == "") {
+ button.performClick();
+ return;
+ }
+ button = (Button) findViewById(R.id.BottomRight);
+ if (button.getText() == "") {
+ button.performClick();
+ return;
+ }
+ break;
+ case 3: //C1
+ button = (Button) findViewById(R.id.TopLeft);
+ if (button.getText() == "") {
+ button.performClick();
+ return;
+ }
+ button = (Button) findViewById(R.id.MiddleLeft);
+ if (button.getText() == "") {
+ button.performClick();
+ return;
+ }
+ button = (Button) findViewById(R.id.BottomLeft);
+ if (button.getText() == "") {
+ button.performClick();
+ return;
+ }
+ break;
+ case 4: //C2
+ button = (Button) findViewById(R.id.TopMiddle);
+ if (button.getText() == "") {
+ button.performClick();
+ return;
+ }
+ button = (Button) findViewById(R.id.MiddleMiddle);
+ if (button.getText() == "") {
+ button.performClick();
+ return;
+ }
+ button = (Button) findViewById(R.id.BottomMiddle);
+ if (button.getText() == "") {
+ button.performClick();
+ return;
+ }
+ break;
+ case 5: //C3
+ button = (Button) findViewById(R.id.TopRight);
+ if (button.getText() == "") {
+ button.performClick();
+ return;
+ }
+ button = (Button) findViewById(R.id.MiddleRight);
+ if (button.getText() == "") {
+ button.performClick();
+ return;
+ }
+ button = (Button) findViewById(R.id.BottomRight);
+ if (button.getText() == "") {
+ button.performClick();
+ return;
+ }
+ break;
+ case 6: //DD
+ button = (Button) findViewById(R.id.TopLeft);
+ if (button.getText() == "") {
+ button.performClick();
+ return;
+ }
+ button = (Button) findViewById(R.id.MiddleMiddle);
+ if (button.getText() == "") {
+ button.performClick();
+ return;
+ }
+ button = (Button) findViewById(R.id.BottomRight);
+ if (button.getText() == "") {
+ button.performClick();
+ return;
+ }
+ break;
+ case 7: //DU
+ button = (Button) findViewById(R.id.TopRight);
+ if (button.getText() == "") {
+ button.performClick();
+ return;
+ }
+ button = (Button) findViewById(R.id.MiddleMiddle);
+ if (button.getText() == "") {
+ button.performClick();
+ return;
+ }
+ button = (Button) findViewById(R.id.BottomLeft);
+ if (button.getText() == "") {
+ button.performClick();
+ return;
+ }
+ break;
+ default:
+ break;
+ }
+ }
+ }
+
+ //take center if possible
+ button = (Button) findViewById(R.id.MiddleMiddle);
+ if (button.getText() == "") {
+ button.performClick();
+ return;
+ }
+
+ for (int d = 0; d < 8; d++) { //look for O with one and add to it
+ if (pointcount[d] == 1) {
+ switch(d) {
+ case 0: //R1
+ button = (Button) findViewById(R.id.TopLeft);
+ if (button.getText() == "") {
+ button.performClick();
+ return;
+ }
+ button = (Button) findViewById(R.id.TopMiddle);
+ if (button.getText() == "") {
+ button.performClick();
+ return;
+ }
+ button = (Button) findViewById(R.id.TopRight);
+ if (button.getText() == "") {
+ button.performClick();
+ return;
+ }
+ break;
+ case 1: //R2
+ button = (Button) findViewById(R.id.MiddleLeft);
+ if (button.getText() == "") {
+ button.performClick();
+ return;
+ }
+ button = (Button) findViewById(R.id.MiddleMiddle);
+ if (button.getText() == "") {
+ button.performClick();
+ return;
+ }
+ button = (Button) findViewById(R.id.MiddleRight);
+ if (button.getText() == "") {
+ button.performClick();
+ return;
+ }
+ break;
+ case 2: //R3
+ button = (Button) findViewById(R.id.BottomLeft);
+ if (button.getText() == "") {
+ button.performClick();
+ return;
+ }
+ button = (Button) findViewById(R.id.BottomMiddle);
+ if (button.getText() == "") {
+ button.performClick();
+ return;
+ }
+ button = (Button) findViewById(R.id.BottomRight);
+ if (button.getText() == "") {
+ button.performClick();
+ return;
+ }
+ break;
+ case 3: //C1
+ button = (Button) findViewById(R.id.TopLeft);
+ if (button.getText() == "") {
+ button.performClick();
+ return;
+ }
+ button = (Button) findViewById(R.id.MiddleLeft);
+ if (button.getText() == "") {
+ button.performClick();
+ return;
+ }
+ button = (Button) findViewById(R.id.BottomLeft);
+ if (button.getText() == "") {
+ button.performClick();
+ return;
+ }
+ break;
+ case 4: //C2
+ button = (Button) findViewById(R.id.TopMiddle);
+ if (button.getText() == "") {
+ button.performClick();
+ return;
+ }
+ button = (Button) findViewById(R.id.MiddleMiddle);
+ if (button.getText() == "") {
+ button.performClick();
+ return;
+ }
+ button = (Button) findViewById(R.id.BottomMiddle);
+ if (button.getText() == "") {
+ button.performClick();
+ return;
+ }
+ break;
+ case 5: //C3
+ button = (Button) findViewById(R.id.TopRight);
+ if (button.getText() == "") {
+ button.performClick();
+ return;
+ }
+ button = (Button) findViewById(R.id.MiddleRight);
+ if (button.getText() == "") {
+ button.performClick();
+ return;
+ }
+ button = (Button) findViewById(R.id.BottomRight);
+ if (button.getText() == "") {
+ button.performClick();
+ return;
+ }
+ break;
+ case 6: //DD
+ button = (Button) findViewById(R.id.TopLeft);
+ if (button.getText() == "") {
+ button.performClick();
+ return;
+ }
+ button = (Button) findViewById(R.id.MiddleMiddle);
+ if (button.getText() == "") {
+ button.performClick();
+ return;
+ }
+ button = (Button) findViewById(R.id.BottomRight);
+ if (button.getText() == "") {
+ button.performClick();
+ return;
+ }
+ break;
+ case 7: //DU
+ button = (Button) findViewById(R.id.TopRight);
+ if (button.getText() == "") {
+ button.performClick();
+ return;
+ }
+ button = (Button) findViewById(R.id.MiddleMiddle);
+ if (button.getText() == "") {
+ button.performClick();
+ return;
+ }
+ button = (Button) findViewById(R.id.BottomLeft);
+ if (button.getText() == "") {
+ button.performClick();
+ return;
+ }
+ break;
+ default:
+ break;
+ }
+ }
+ }
+ randomMove();
+ }
+ }
+ }
+
public void buttonGlow(int winner) {
int glowcolor;
if (winner == 3)
Please sign in to comment.
Something went wrong with that request. Please try again.