Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
CaseyNelson314 authored Mar 17, 2022
1 parent 8b134f0 commit aa746bc
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 35 deletions.
57 changes: 57 additions & 0 deletions othelo_prosessing/Ai.pde
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
int situation;

void turnAI() {
boolean aiTurn = turn;
int scoreMap[][] ={
{0, 1, 1, 0},
{1, 0, 0, 1},
{1, 0, 0, 1},
{0, 1, 1, 0},
};


int canPutCount=0;
for (int i=0; i<8; i++)
for (int j=0; j<8; j++)
if (canPut(i, j, false))canPutCount++;
canPutCount=(int)random(canPutCount)+1;
for (int i=0; i<8; i++)
for (int j=0; j<8; j++) {
if (canPut(i, j, false))canPutCount--;
if (canPutCount==0) {
canPut(i, j, true);
break;
}
}
println(canPutCount);
turn^=true;


//switch(situation) {
//case 0: //序盤(4×4内)
// int canPutCount=0;
// for (int i=0; i<4; i++)
// for (int j=0; j<4; j++)
// if (canPut(i+2, j+2, false))canPutCount++;

// int maxScorePointCount=0;
// for (int i=0; i<4; i++)
// for (int j=0; j<4; j++)
// if (canPut(i+2, j+2, false) && scoreMap[i][j]==1)maxScorePointCount++;

// maxScorePointCount=(int)random(maxScorePointCount);
// for (int i=0; i<4; i++)
// for (int j=0; j<4; j++) {
// if (canPut(i+2, j+2, false))maxScorePointCount--;
// if (maxScorePointCount==0)canPut(i+2, j+2, true);
// }
// println(canPutCount);

// if (canPutCount==0)situation++; //序盤終了
// else break;

//case 1: //中盤
//}

//turn^=true;
}
12 changes: 1 addition & 11 deletions othelo_prosessing/drawFunction.pde
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ boolean AImode; //<>//
boolean isHintMode;

void drawScore() { //スコアボード
final int score_height = 100;
noStroke();
rectMode(CENTER);
int glow=abs(millis()/5%200-100)+120;
Expand Down Expand Up @@ -95,7 +94,6 @@ void optionBotton() {
//RESET,SORT
fill(#51bd50);
if (option[1].click()) {
AImode = false;
isHintMode = false;
if (mode==2) {
boardSort();
Expand Down Expand Up @@ -129,18 +127,10 @@ void optionBotton() {


void drawCursor() {
if (mode!=1)return;
int mouseGlow=abs(millis()/10%200-100)+155;
if (turn)
fill(0, mouseGlow);
else
fill(255, mouseGlow);
ellipse(mouseX, mouseY, win.width(80), win.width(80));
}


void turnAI() { //<>//
if (AImode==false)return;

turn^=true;
}
} //<>//
16 changes: 6 additions & 10 deletions othelo_prosessing/othelo_prosessing.pde
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ boolean turn; //true:black,false:white

int mode;

final int score_height = 100;
final int board_height = 300;
final int botton_height = 1350;
final int botton_height = 1400;

Window win = new Window();
Botton option[] = new Botton[3];
Expand All @@ -23,18 +24,17 @@ Botton board[][] = new Botton[8][8];
void setup() {
for (int i=0; i<3; i++)option[i] = new Botton();
for (int i=0; i<8; i++)for (int j=0; j<8; j++)board[i][j] = new Botton();
frameRate(60);
frameRate(1000);
win.setWindow(WINDOW_WIDTH, WINDOW_HEIGHT, 1000, 1500);
win.margin(30);
}

void draw() {
background(#e5b26a);
print((int)frameRate);
println("fps");

//win.drawWindow();
//print((int)frameRate);
//println("fps");

win.drawWindow();
switch(mode) {
case 0: //初期化
boardReset();
Expand All @@ -48,19 +48,15 @@ void draw() {
break;
case 2: //ソート待機
isHintMode=false;
AImode=false;
clearHighlight();
optionBotton();
drawScore();
drawBoard();
drawCursor();
case 3:
isHintMode=false;
AImode=false;
clearHighlight();
optionBotton();
drawScore();
drawBoard();
drawCursor();
}
}
12 changes: 2 additions & 10 deletions othelo_prosessing/systemFunction.pde
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
int getBoradSize() { //画面比率調整
if (width >= height)
return height;
else
return width;
}

int getScore_white() {
int score= 0;
for (int i=0; i<8; i++)
Expand All @@ -23,20 +16,19 @@ int getScore_black() {
void mouseCD() { //ボードとカーソルの当たり判定をhighlightへ書き込み
for (int i=0; i<8; i++)
for (int j=0; j<8; j++) {

board[i][j].botton(win.x(i*125), win.y(board_height+j*125), win.width(125), win.height(125));
highlight[i][j] = board[i][j].hover();
if (board[i][j].click()&&canPut(i, j, true)) {//コマ設置時
turn^=true;
if (AImode)turnAI();
if (isSkip()) { //相手が置けない
turn^=true;
if (isSkip())//どっちも置けない
mode++;
return;
}
turnAI();
}

}
}

Expand Down
16 changes: 12 additions & 4 deletions othelo_prosessing/windowManager.pde
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,19 @@ class Window {
textAlign(LEFT, DOWN);
}

private float lastSize; //前回の幅高さ合計値
boolean sizeUpdate() {
boolean isUpdate = false;
if (width+height != lastSize)isUpdate = true;
lastSize = width+height;
return isUpdate;
}


private void updatePoint_x() {
if (width * heightPerWidth >= height) { //横幅オーバー
left_x = width/2 - height*widthPerHeight*margin/2;
right_x = width/2 + height*widthPerHeight*margin/2;
left_x = (width-height*widthPerHeight*margin)/2;
right_x = (width+height*widthPerHeight*margin)/2;
} else { //縦幅オーバー
left_x = width*(1-margin)/2;
right_x = width*(1+margin)/2;
Expand All @@ -102,8 +110,8 @@ class Window {
left_y = height*(1-margin)/2;
right_y = height*(1+margin)/2;
} else { //縦幅オーバー
left_y = height/2 - width*heightPerWidth*margin/2;
right_y = height/2 + width*heightPerWidth*margin/2;
left_y = (height-width*heightPerWidth*margin)/2;
right_y = (height+width*heightPerWidth*margin)/2;
}
}
};

0 comments on commit aa746bc

Please sign in to comment.