@@ -1,44 +1,44 @@
<?xml version="1.0" encoding="UTF-8"?>
<section name="Workbench">
<section name="WorkbenchPreferenceDialogSettings">
<item value="-6" key="DIALOG_X_ORIGIN"/>
<item value="-91" key="DIALOG_Y_ORIGIN"/>
</section>
<section name="org.eclipse.ui.internal.QuickAccess">
<item value="1009" key="dialogHeight"/>
<item value="1620" key="dialogWidth"/>
<list key="textEntries">
</list>
<list key="orderedElements">
</list>
<list key="orderedProviders">
</list>
<list key="textArray">
</list>
</section>
<section name="NewWizardAction">
<item value="ccw.newClojureFileWizard" key="NewWizardSelectionPage.STORE_SELECTED_ID"/>
<list key="NewWizardSelectionPage.STORE_EXPANDED_CATEGORIES_ID">
<item value="org.eclipse.cdt.ui.newCWizards"/>
<item value="ccw.category.new"/>
<item value="org.eclipse.jdt.ui.java"/>
</list>
</section>
<section name="ShowViewDialog">
<item value="472" key="DIALOG_WIDTH"/>
<item value="1|Segoe UI|9.0|0|WINDOWS|1|-18|0|0|0|400|0|0|0|1|0|0|0|0|Segoe UI" key="DIALOG_FONT_NAME"/>
<item value="org.eclipse.egit.ui.RepositoriesView" key="ShowViewDialog.STORE_SELECTED_VIEW_ID"/>
<item value="517" key="DIALOG_HEIGHT"/>
<item value="855" key="DIALOG_X_ORIGIN"/>
<item value="359" key="DIALOG_Y_ORIGIN"/>
<list key="ShowViewDialog.STORE_EXPANDED_CATEGORIES_ID">
<item value="org.eclipse.egit.ui.GitCategory"/>
</list>
</section>
<section name="ImportExportAction">
<item value="com.android.ide.eclipse.adt.project.ImportProjectWizard" key="ImportExportPage.STORE_SELECTED_IMPORT_WIZARD_ID"/>
<list key="ImportExportPage.STORE_EXPANDED_IMPORT_CATEGORIES">
<item value="com.android.ide.eclipse.wizards.category"/>
</list>
</section>
</section>
<?xml version="1.0" encoding="UTF-8"?>
<section name="Workbench">
<section name="WorkbenchPreferenceDialogSettings">
<item value="-6" key="DIALOG_X_ORIGIN"/>
<item value="-91" key="DIALOG_Y_ORIGIN"/>
</section>
<section name="org.eclipse.ui.internal.QuickAccess">
<item value="1009" key="dialogHeight"/>
<item value="1620" key="dialogWidth"/>
<list key="textEntries">
</list>
<list key="orderedElements">
</list>
<list key="orderedProviders">
</list>
<list key="textArray">
</list>
</section>
<section name="NewWizardAction">
<item value="ccw.newClojureFileWizard" key="NewWizardSelectionPage.STORE_SELECTED_ID"/>
<list key="NewWizardSelectionPage.STORE_EXPANDED_CATEGORIES_ID">
<item value="org.eclipse.cdt.ui.newCWizards"/>
<item value="ccw.category.new"/>
<item value="org.eclipse.jdt.ui.java"/>
</list>
</section>
<section name="ShowViewDialog">
<item value="472" key="DIALOG_WIDTH"/>
<item value="1|Segoe UI|9.0|0|WINDOWS|1|-18|0|0|0|400|0|0|0|1|0|0|0|0|Segoe UI" key="DIALOG_FONT_NAME"/>
<item value="org.eclipse.egit.ui.StagingView" key="ShowViewDialog.STORE_SELECTED_VIEW_ID"/>
<item value="517" key="DIALOG_HEIGHT"/>
<item value="855" key="DIALOG_X_ORIGIN"/>
<item value="359" key="DIALOG_Y_ORIGIN"/>
<list key="ShowViewDialog.STORE_EXPANDED_CATEGORIES_ID">
<item value="org.eclipse.egit.ui.GitCategory"/>
</list>
</section>
<section name="ImportExportAction">
<item value="com.android.ide.eclipse.adt.project.ImportProjectWizard" key="ImportExportPage.STORE_SELECTED_IMPORT_WIZARD_ID"/>
<list key="ImportExportPage.STORE_EXPANDED_IMPORT_CATEGORIES">
<item value="com.android.ide.eclipse.wizards.category"/>
</list>
</section>
</section>
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<workingSetManager>
<workingSet aggregate="true" factoryID="org.eclipse.ui.internal.WorkingSetFactory" id="1418596865380_0" label="Window Working Set" name="Aggregate for window 1418596865380"/>
<?xml version="1.0" encoding="UTF-8"?>
<workingSetManager>
<workingSet aggregate="true" factoryID="org.eclipse.ui.internal.WorkingSetFactory" id="1418596865380_0" label="Window Working Set" name="Aggregate for window 1418596865380"/>
</workingSetManager>
@@ -1,2 +1,2 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<typeInfoHistroy/>
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<typeInfoHistroy/>
@@ -1,2 +1,2 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<qualifiedTypeNameHistroy/>
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<qualifiedTypeNameHistroy/>
@@ -1,3 +1,3 @@
#Tue Mar 17 17:15:42 EDT 2015
#Thu Mar 19 18:06:58 EDT 2015
org.eclipse.core.runtime=2
org.eclipse.platform=4.4.0.v20140925-0400
@@ -1 +1 @@
[[{"location":"C:\\Program Files\\Java\\jre1.8.0_25","type":"JRE","hints":{"EXECUTION_ENVIRONMENT":"JavaSE-1.8"}},"jre:jre:1.8.0"],[{"location":"C:\\Users\\Heman\\android-sdks\\platforms\\android-21\\android.jar","type":"JAR","hints":{}},"ABSENT"],[{"location":"C:\\Users\\Heman\\Desktop\\derpspace\\minesweeper","type":"PROJECT","hints":{"PROJECT_NAME":"minesweeper"}},"ABSENT"],[{"location":"C:\\Users\\Heman\\Desktop\\derpspace\\brainfuck","type":"PROJECT","hints":{"PROJECT_NAME":"brainfuck"}},"ABSENT"],[{"location":"C:\\Users\\Heman\\Desktop\\derpspace\\othello","type":"PROJECT","hints":{"PROJECT_NAME":"othello"}},"ABSENT"],[{"location":"C:\\Users\\Heman\\Desktop\\derpspace\\canvas","type":"PROJECT","hints":{"PROJECT_NAME":"canvas"}},"ABSENT"],[{"location":"C:\\Users\\Heman\\android-sdks\\extras\\android\\support\\v7\\appcompat\\libs\\android-support-v7-appcompat.jar","type":"JAR","hints":{}},"ABSENT"],[{"location":"C:\\Users\\Heman\\Desktop\\derpspace\\MazeGenerator","type":"PROJECT","hints":{"PROJECT_NAME":"MazeGenerator"}},"ABSENT"],[{"location":"C:\\Users\\Heman\\Desktop\\derpspace\\BrainfuckApp","type":"PROJECT","hints":{"PROJECT_NAME":"BrainfuckApp"}},"ABSENT"]]
[[{"location":"C:\\Users\\Heman\\Desktop\\derpspace\\MazeGenerator","type":"PROJECT","hints":{"PROJECT_NAME":"MazeGenerator"}},"ABSENT"],[{"location":"C:\\Users\\Heman\\Desktop\\derpspace\\minesweeper","type":"PROJECT","hints":{"PROJECT_NAME":"minesweeper"}},"ABSENT"],[{"location":"C:\\Users\\Heman\\Desktop\\derpspace\\othello","type":"PROJECT","hints":{"PROJECT_NAME":"othello"}},"ABSENT"],[{"location":"C:\\Users\\Heman\\Desktop\\derpspace\\chess","type":"PROJECT","hints":{"PROJECT_NAME":"chess"}},"ABSENT"],[{"location":"C:\\Users\\Heman\\Desktop\\derpspace\\canvas","type":"PROJECT","hints":{"PROJECT_NAME":"canvas"}},"ABSENT"],[{"location":"C:\\Users\\Heman\\Desktop\\derpspace\\brainfuck","type":"PROJECT","hints":{"PROJECT_NAME":"brainfuck"}},"ABSENT"],[{"location":"C:\\Program Files\\Java\\jre1.8.0_31","type":"JRE","hints":{"EXECUTION_ENVIRONMENT":"JavaSE-1.8"}},"jre:jre:1.8.0"],[{"location":"C:\\Users\\Heman\\Desktop\\derpspace\\BrainfuckApp","type":"PROJECT","hints":{"PROJECT_NAME":"BrainfuckApp"}},"ABSENT"],[{"location":"C:\\Program Files\\Java\\jre1.8.0_25","type":"JRE","hints":{"EXECUTION_ENVIRONMENT":"JavaSE-1.8"}},"jre:jre:1.8.0"],[{"location":"C:\\Users\\Heman\\android-sdks\\extras\\android\\support\\v7\\appcompat\\libs\\android-support-v7-appcompat.jar","type":"JAR","hints":{}},"ABSENT"],[{"location":"C:\\Users\\Heman\\android-sdks\\platforms\\android-21\\android.jar","type":"JAR","hints":{}},"ABSENT"]]
Binary file not shown.
Binary file not shown.

This file was deleted.

This file was deleted.

This file was deleted.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,3 +1,3 @@
#NOTE: This is an Aether internal implementation file, its format can be changed without prior notice.
#Fri Feb 27 21:49:04 EST 2015
maven-metadata-models.xml.lastUpdated=1425091744285
#NOTE: This is an Aether internal implementation file, its format can be changed without prior notice.
#Thu Mar 19 20:22:17 EDT 2015
maven-metadata-models.xml.lastUpdated=1426810937842
@@ -1,3 +1,3 @@
#NOTE: This is an Aether internal implementation file, its format can be changed without prior notice.
#Fri Feb 27 19:29:47 EST 2015
maven-metadata-models.xml.lastUpdated=1425083387606
#NOTE: This is an Aether internal implementation file, its format can be changed without prior notice.
#Thu Mar 19 18:10:57 EDT 2015
maven-metadata-models.xml.lastUpdated=1426803057543
@@ -1,20 +1,32 @@
package chess;

public class Board {
import java.awt.GridLayout;
import javax.swing.*;

public class Board extends JPanel{

private Tile[][] grid;
private Tile selected;

public Board(){
private int currPlayer;
private int totalPlayers;

public Board(int numPlayers){
setLayout(new GridLayout(8,8));

grid = new Tile[8][8];

for(int i = 0; i < 8; i++){
for(int j = 0; j < 8; j++){
grid[i][j] = new Tile(i,j,this);
grid[i][j] = new Tile(j,i,this);
add(grid[i][j]);
}
}

selected = null;

totalPlayers = numPlayers;
currPlayer = 0;
}

public Tile getSelectedTile(){
@@ -23,6 +35,14 @@ public Tile getSelectedTile(){

public void updateSelection(Tile newSelection){
selected = newSelection;
if(newSelection == null){
currPlayer++;
currPlayer %= totalPlayers;
}
}

public int getCurrPlayer(){
return currPlayer;
}

public void restoreAllBackgrounds(){
@@ -39,4 +59,33 @@ public Tile[][] getGrid(){
public boolean isFirstSelectionMade(){
return selected != null;
}

public static Board chessBoard(){
Board toRet = new Board(2);
Tile[][] board = toRet.getGrid();

for(int i = 0; i < 8; i++){
board[1][i].setOccupant(new Pawn(board[1][i],0));
board[6][i].setOccupant(new Pawn(board[6][i],1));

board[1][i].getOccupant().drawLabel();
board[6][i].getOccupant().drawLabel();
}

toRet.repaint();
return toRet;
}

public static Board drawGrid(){
Board toRet = new Board(1);

for(Tile [] row: toRet.getGrid()){
for(Tile t: row){
t.setForeground(java.awt.Color.RED);
t.setText("(" + t.getX() + ", " + t.getY() + " )");
}
}

return toRet;
}
}
@@ -0,0 +1,47 @@
package chess;

public class Pawn extends Piece {

private int player;

public Pawn(Tile currTile, int player) {
super(currTile);

this.player = player;
}

@Override
public void drawLabel(Tile drawTo) {
drawTo.setForeground(java.awt.Color.RED);
if(player == 0)
drawTo.setText("White pawn");
else
drawTo.setText("Black pawn");

}

@Override
public Tile[] getValidMoves() {
Tile curr = getCurrTile();
int moveY = (player == 0)? curr.getY() + 1: curr.getY() - 1;
if(curr.getBoard().getCurrPlayer() != player || moveY >= 8 || moveY < 0)
return null;
else{
Tile [] toRet = new Tile[4];
if(curr.getBoard().getGrid()[moveY][curr.getX()].getOccupant() == null)
toRet[0] = curr.getBoard().getGrid()[moveY][curr.getX()];
if(curr.getX() - 1 >= 0 &&
curr.getBoard().getGrid()[moveY][curr.getX() - 1].getOccupant() != null)
toRet[1] = curr.getBoard().getGrid()[moveY][curr.getX() - 1];
if(curr.getX() + 1 < 8 &&
curr.getBoard().getGrid()[moveY][curr.getX() + 1].getOccupant() != null)
toRet[2] = curr.getBoard().getGrid()[moveY][curr.getX() + 1];
if(((player == 0 && curr.getY() == 1) || (player == 1 && curr.getY() == 6))
&& toRet[0] != null &&
curr.getBoard().getGrid()[curr.getY() + 2 * ((player == 0)? 1 : -1)][curr.getX()].getOccupant() == null)
toRet[3] = curr.getBoard().getGrid()[curr.getY() + 2 * ((player == 0)? 1 : -1)][curr.getX()];
return toRet;
}
}

}
@@ -2,11 +2,9 @@

public abstract class Piece {

private Board game;
private Tile currTile;

public Piece(Board game, Tile currTile){
this.game = game;
public Piece(Tile currTile){
this.currTile = currTile;
}

@@ -15,18 +13,25 @@ public Tile getCurrTile(){
}

public boolean move(Tile dest){
for(Tile t: getValidMoves()){
if(t == dest){
currTile.setOccupant(null);
currTile = dest;
currTile.setOccupant(this);
return true;
Tile [] valids = getValidMoves();
if(valids != null){
for(Tile t: getValidMoves()){
if(t == dest){
currTile.setOccupant(null);
currTile = dest;
currTile.setOccupant(this);
return true;
}
}
}
return false;
}

public abstract void drawLabel();
public void drawLabel(){
drawLabel(getCurrTile());
}

public abstract void drawLabel(Tile drawTo);

public abstract Tile[] getValidMoves();
}
@@ -0,0 +1,17 @@
package chess;

import javax.swing.*;

public class Tester {

public static void main(String[] args) {
JFrame win = new JFrame("Chess");
win.add(Board.chessBoard());
//win.add(Board.drawGrid());
win.setVisible(true);
win.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
win.setSize(700, 700);

}

}
@@ -15,6 +15,7 @@ public Tile(int x, int y, Board surroundings){
this.x = x;
this.y = y;
environs = surroundings;
occupant = null;

addMouseListener(this);
setOpaque(true);
@@ -30,7 +31,9 @@ public Piece getOccupant(){
public void setOccupant(Piece p){
occupant = p;
if(p != null)
p.drawLabel();
p.drawLabel(this);
else
setText("");
}

public void restoreBackgroundColor(){
@@ -39,17 +42,34 @@ public void restoreBackgroundColor(){
else
setBackground(Color.WHITE);
}

public Board getBoard(){
return environs;
}

@Override
public void mouseClicked(MouseEvent arg0) {
if(environs.isFirstSelectionMade()){
boolean moved = environs.getSelectedTile().getOccupant().move(this);
if(moved){
environs.restoreAllBackgrounds();
environs.updateSelection(null);
}
environs.getSelectedTile().getOccupant().move(this);
environs.restoreAllBackgrounds();
environs.updateSelection(null);
}else if(occupant != null){
Tile[] t = occupant.getValidMoves();
if(t != null)
for(Tile a: t)
if(a != null)
a.setBackground(Color.BLUE);
environs.updateSelection(this);
}
}

public int getX(){
return x;
}

public int getY(){
return y;
}

@Override
public void mouseEntered(MouseEvent e) {