欧美大屁股bbbbxxxx,狼人大香伊蕉国产www亚洲,男ji大巴进入女人的视频小说,男人把ji大巴放进女人免费视频,免费情侣作爱视频

  • <i id='gl71z68t'><tr id='htrt2tpd'><dt id='sf0nwsxt'><q id='m2oghmii'><span id='7twyv7bs'><b id='ul3u6vpw'><form id='v3fvzxvr'><ins id='uuhj9bzu'></ins><ul id='g0vleknd'></ul><sub id='4euxo0r2'></sub></form><legend id='gftw06vn'></legend><bdo id='dia3a5cd'><pre id='h67h1bwh'><center id='t6yqk9m5'></center></pre></bdo></b><th id='z3wmscmg'></th></span></q></dt></tr></i><div class="c8jzdxauzz" id='k723ojtk'><tfoot id='6zd3joll'></tfoot><dl id='glfsxinz'><fieldset id='jg79iyb8'></fieldset></dl></div>
  • <legend id='172wl1a0'><style id='zktpg9jc'><dir id='8qhfkw7s'><q id='mvoedq9k'></q></dir></style></legend>

      <bdo id='pxqnmwxa'></bdo><ul id='ke14ctrw'></ul>

    <tfoot id='xv71nwrv'></tfoot>

        <small id='bf5j1d91'></small><noframes id='0nr0rdwy'>

      1. 歡迎來(lái)到入門(mén)教程網(wǎng)!

        Java編程

        當(dāng)前位置:主頁(yè) > 軟件編程 > Java編程 >

        五子棋游戲的java代碼 基于java的五子棋游戲的設(shè)計(jì)代碼

        來(lái)源:本站原創(chuàng)|時(shí)間:2023-04-10|欄目:Java編程|點(diǎn)擊: 次

        java五子棋源代碼

        我這有算法 不過(guò)沒(méi)做swing界面 DOS下可以直接運(yùn)行 要不你拿去改改

        import java.io.BufferedReader;

        import java.io.InputStreamReader;

        /*

        * 五子棋源碼

        * 所用的符號(hào)標(biāo)識(shí) ○ ● ┼

        * 在dos界面下運(yùn)行效果最佳

        * 黑白雙方交叉輸入落子點(diǎn)坐標(biāo) 以逗號(hào)隔開(kāi)如 1,1

        * 輸入空 或者一方勝出 程序停止

        */

        public class Chess {

        // 定義棋盤(pán)大小

        private static int SIZE = 15;

        private String[][] board;

        public static void main(String[] args) throws Exception {

        Chess chess = new Chess();

        // 初始化棋盤(pán)

        chess.initBoard();

        // 畫(huà)出棋盤(pán)

        chess.paintBoard();

        // 根據(jù)who的奇偶性 判斷該誰(shuí)落子

        int who = 0;

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        String str = null;

        while ((str = br.readLine()) != null) {

        // 提取輸入的 以","分開(kāi)的數(shù) 分別對(duì)應(yīng)x y坐標(biāo)

        String[] posStr = str.split(",");

        int x = Integer.parseInt(posStr[0]);

        int y = Integer.parseInt(posStr[1]);

        // 判斷落子點(diǎn)是否合法

        if (!"┼".equals(chess.board[x][y])) {

        System.out.println("這里不允許落子,請(qǐng)重下..");

        continue;

        }

        if (who % 2 == 0) {

        chess.board[x][y] = "○";

        chess.paintBoard();

        // 判斷是否勝出

        if (chess.isWin("○")) {

        System.out.println("○獲勝");

        return;

        }

        } else {

        chess.board[x][y] = "●";

        chess.paintBoard();

        // 判斷是否勝出

        if (chess.isWin("●")) {

        System.out.println("●獲勝");

        return;

        }

        }

        who++;

        }

        }

        // 以 "┼" 初始化棋盤(pán)

        public void initBoard() {

        board = new String[SIZE][SIZE];

        for (int i = 0; i SIZE; i++) {

        for (int j = 0; j SIZE; j++) {

        board[i][j] = "┼";

        }

        }

        }

        // 描繪出當(dāng)前棋盤(pán)

        public void paintBoard() {

        // 以下代碼 這里為了使得棋盤(pán)坐標(biāo)看的清楚 加入了坐標(biāo)值

        System.out.print(" ");

        for (int i = 0; i SIZE; i++) {

        if (i 10) {

        System.out.print(i + " ");

        } else {

        System.out.print((i - 10) + " ");

        }

        }

        System.out.println();

        // 以上代碼 這里為了使得棋盤(pán)坐標(biāo)看的清楚 加入了坐標(biāo)值

        for (int i = 0; i SIZE; i++) {

        if (i 10) {

        System.out.print(" " + i);

        } else {

        System.out.print(i);

        }

        for (int j = 0; j SIZE; j++) {

        System.out.print(board[i][j]);

        }

        System.out.println();

        }

        }

        // 判斷是否獲勝

        public boolean isWin(String sign) {

        int count = 0;

        // 橫向掃描各行

        // 有一個(gè)sign的子 計(jì)數(shù)器+1

        // 碰到不是sign的子 計(jì)數(shù)器置零

        // 計(jì)數(shù)器到達(dá)5時(shí) 返回true 勝出

        for (int i = 0; i SIZE; i++) {

        count = 0;

        for (int j = 0; j SIZE; j++) {

        if (board[i][j].equals(sign)) {

        count++;

        if (count == 5) {

        return true;

        }

        } else {

        count = 0;

        }

        }

        }

        // 縱向掃描各列

        // 方法同上

        for (int i = 0; i SIZE; i++) {

        count = 0;

        for (int j = 0; j SIZE; j++) {

        if (board[j][i].equals(sign)) {

        count++;

        if (count == 5) {

        return true;

        }

        } else {

        count = 0;

        }

        }

        }

        // 掃描斜右下

        // 在橫向掃描基礎(chǔ)上 外層套一個(gè)循環(huán) 以k為標(biāo)識(shí)

        // 坐標(biāo)x-y的范圍在-SIZE+1到SIZE-1之間

        // 當(dāng)x-y的值相等時(shí) 在同一右下斜線上

        for (int k = -SIZE + 1; k = SIZE - 1; k++) {

        count = 0;

        for (int i = 0; i SIZE; i++) {

        for (int j = 0; j SIZE; j++) {

        if (i - j == k) {

        if (board[i][j].equals(sign)) {

        count++;

        if (count == 5) {

        return true;

        }

        } else {

        count = 0;

        }

        }

        }

        }

        }

        // 掃描斜左邊上

        // 方法同上 坐標(biāo)x+y的值相等時(shí) 在同一左上斜線上

        for (int k = -SIZE + 1; k = SIZE - 1; k++) {

        count = 0;

        for (int i = 0; i SIZE; i++) {

        for (int j = 0; j SIZE; j++) {

        if (i + j == k) {

        if (board[i][j].equals(sign)) {

        count++;

        if (count == 5) {

        return true;

        }

        } else {

        count = 0;

        }

        }

        }

        }

        }

        return false;

        }

        }

        求五子棋Java代碼旁邊就注釋 讓我看的清楚明白一些,要詳細(xì)的解釋和思路

        import java.applet.*;

        import t.*;

        import t.event.*;

        import java.applet.Applet;

        import t.Color; //這一段import就不說(shuō)了,下面要用到的就import進(jìn)來(lái)

        public class wuziqi extends Applet implements ActionListener,MouseListener,MouseMotionListener,ItemListener

        //繼承Applet表明是個(gè)applet,后面的接口必須要實(shí)現(xiàn)每個(gè)接口的所有方法

        {

        int color_Qizi=0;//旗子的顏色標(biāo)識(shí) 0:白子 1:黑子

        int intGame_Start=0;//游戲開(kāi)始標(biāo)志 0未開(kāi)始 1游戲中

        int intGame_Body[][]=new int[16][16]; //設(shè)置棋盤(pán)棋子狀態(tài) 0 無(wú)子 1 白子 2 黑子

        求java五子棋代碼要注釋~現(xiàn)在1小時(shí)等待

        package org.crazyit.gobang;

        import java.io.BufferedReader;

        import java.io.InputStreamReader;

        /**

        * 五子棋游戲類(lèi)

        *

        * @author yangenxiong [email protected]

        * @author Kelvin Mak [email protected]

        * @version 1.0

        * br/網(wǎng)站: a href=""瘋狂Java聯(lián)盟/a

        * brCopyright (C), 2009-2010, yangenxiong

        * brThis program is protected by copyright laws.

        */

        public class GobangGame {

        // 定義達(dá)到贏條件的棋子數(shù)目

        private final int WIN_COUNT = 5;

        // 定義用戶輸入的X坐標(biāo)

        private int posX = 0;

        // 定義用戶輸入的X坐標(biāo)

        private int posY = 0;

        // 定義棋盤(pán)

        private Chessboard chessboard;

        /**

        * 空構(gòu)造器

        */

        public GobangGame() {

        }

        /**

        * 構(gòu)造器,初始化棋盤(pán)和棋子屬性

        *

        * @param chessboard

        * 棋盤(pán)類(lèi)

        */

        public GobangGame(Chessboard chessboard) {

        this.chessboard = chessboard;

        }

        /**

        * 檢查輸入是否合法。

        *

        * @param inputStr

        * 由控制臺(tái)輸入的字符串。

        * @return 字符串合法返回true,反則返回false。

        */

        public boolean isValid(String inputStr) {

        // 將用戶輸入的字符串以逗號(hào)(,)作為分隔,分隔成兩個(gè)字符串

        String[] posStrArr = inputStr.split(",");

        try {

        posX = Integer.parseInt(posStrArr[0]) - 1;

        posY = Integer.parseInt(posStrArr[1]) - 1;

        } catch (NumberFormatException e) {

        chessboard.printBoard();

        System.out.println("請(qǐng)以(數(shù)字,數(shù)字)的格式輸入:");

        return false;

        }

        // 檢查輸入數(shù)值是否在范圍之內(nèi)

        if (posX 0 || posX = Chessboard.BOARD_SIZE || posY 0

        || posY = Chessboard.BOARD_SIZE) {

        chessboard.printBoard();

        System.out.println("X與Y坐標(biāo)只能大于等于1,與小于等于" + Chessboard.BOARD_SIZE

        + ",請(qǐng)重新輸入:");

        return false;

        }

        // 檢查輸入的位置是否已經(jīng)有棋子

        String[][] board = chessboard.getBoard();

        if (board[posX][posY] != "十") {

        chessboard.printBoard();

        System.out.println("此位置已經(jīng)有棋子,請(qǐng)重新輸入:");

        return false;

        }

        return true;

        }

        /**

        * 開(kāi)始下棋

        */

        public void start() throws Exception {

        // true為游戲結(jié)束

        boolean isOver = false;

        chessboard.initBoard();

        chessboard.printBoard();

        // 獲取鍵盤(pán)的輸入

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        String inputStr = null;

        // br.readLine:每當(dāng)鍵盤(pán)輸入一行內(nèi)容按回車(chē)鍵,則輸入的內(nèi)容被br讀取到

        while ((inputStr = br.readLine()) != null) {

        isOver = false;

        if (!isValid(inputStr)) {

        // 如果不合法,要求重新輸入,再繼續(xù)

        continue;

        }

        // 把對(duì)應(yīng)的數(shù)組元素賦為"●"

        String chessman = Chessman.BLACK.getChessman();

        chessboard.setBoard(posX, posY, chessman);

        // 判斷用戶是否贏了

        if (isWon(posX, posY, chessman)) {

        isOver = true;

        } else {

        // 計(jì)算機(jī)隨機(jī)選擇位置坐標(biāo)

        int[] computerPosArr = computerDo();

        chessman = Chessman.WHITE.getChessman();

        chessboard.setBoard(computerPosArr[0], computerPosArr[1],

        chessman);

        // 判斷計(jì)算機(jī)是否贏了

        if (isWon(computerPosArr[0], computerPosArr[1], chessman)) {

        isOver = true;

        }

        }

        // 如果產(chǎn)生勝者,詢(xún)問(wèn)用戶是否繼續(xù)游戲

        if (isOver) {

        // 如果繼續(xù),重新初始化棋盤(pán),繼續(xù)游戲

        if (isReplay(chessman)) {

        chessboard.initBoard();

        chessboard.printBoard();

        continue;

        }

        // 如果不繼續(xù),退出程序

        break;

        }

        chessboard.printBoard();

        System.out.println("請(qǐng)輸入您下棋的坐標(biāo),應(yīng)以x,y的格式輸入:");

        }

        }

        /**

        * 是否重新開(kāi)始下棋。

        *

        * @param chessman

        * "●"為用戶,"○"為計(jì)算機(jī)。

        * @return 開(kāi)始返回true,反則返回false。

        */

        public boolean isReplay(String chessman) throws Exception {

        chessboard.printBoard();

        String message = chessman.equals(Chessman.BLACK.getChessman()) ? "恭喜您,您贏了,"

        : "很遺憾,您輸了,";

        System.out.println(message + "再下一局?(y/n)");

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        if (br.readLine().equals("y")) {

        // 開(kāi)始新一局

        return true;

        }

        return false;

        }

        /**

        * 計(jì)算機(jī)隨機(jī)下棋

        */

        public int[] computerDo() {

        int posX = (int) (Math.random() * (Chessboard.BOARD_SIZE - 1));

        int posY = (int) (Math.random() * (Chessboard.BOARD_SIZE - 1));

        String[][] board = chessboard.getBoard();

        while (board[posX][posY] != "十") {

        posX = (int) (Math.random() * (Chessboard.BOARD_SIZE - 1));

        posY = (int) (Math.random() * (Chessboard.BOARD_SIZE - 1));

        }

        int[] result = { posX, posY };

        return result;

        }

        /**

        * 判斷輸贏

        *

        * @param posX

        * 棋子的X坐標(biāo)。

        * @param posY

        * 棋子的Y坐標(biāo)

        * @param ico

        * 棋子類(lèi)型

        * @return 如果有五顆相鄰棋子連成一條直接,返回真,否則相反。

        */

        public boolean isWon(int posX, int posY, String ico) {

        // 直線起點(diǎn)的X坐標(biāo)

        int startX = 0;

        // 直線起點(diǎn)Y坐標(biāo)

        int startY = 0;

        // 直線結(jié)束X坐標(biāo)

        int endX = Chessboard.BOARD_SIZE - 1;

        // 直線結(jié)束Y坐標(biāo)

        int endY = endX;

        // 同條直線上相鄰棋子累積數(shù)

        int sameCount = 0;

        int temp = 0;

        // 計(jì)算起點(diǎn)的最小X坐標(biāo)與Y坐標(biāo)

        temp = posX - WIN_COUNT + 1;

        startX = temp 0 ? 0 : temp;

        temp = posY - WIN_COUNT + 1;

        startY = temp 0 ? 0 : temp;

        // 計(jì)算終點(diǎn)的最大X坐標(biāo)與Y坐標(biāo)

        temp = posX + WIN_COUNT - 1;

        endX = temp Chessboard.BOARD_SIZE - 1 ? Chessboard.BOARD_SIZE - 1

        : temp;

        temp = posY + WIN_COUNT - 1;

        endY = temp Chessboard.BOARD_SIZE - 1 ? Chessboard.BOARD_SIZE - 1

        : temp;

        // 從左到右方向計(jì)算相同相鄰棋子的數(shù)目

        String[][] board = chessboard.getBoard();

        for (int i = startY; i endY; i++) {

        if (board[posX][i] == ico board[posX][i + 1] == ico) {

        sameCount++;

        } else if (sameCount != WIN_COUNT - 1) {

        sameCount = 0;

        }

        }

        if (sameCount == 0) {

        // 從上到下計(jì)算相同相鄰棋子的數(shù)目

        for (int i = startX; i endX; i++) {

        if (board[i][posY] == ico board[i + 1][posY] == ico) {

        sameCount++;

        } else if (sameCount != WIN_COUNT - 1) {

        sameCount = 0;

        }

        }

        }

        if (sameCount == 0) {

        // 從左上到右下計(jì)算相同相鄰棋子的數(shù)目

        int j = startY;

        for (int i = startX; i endX; i++) {

        if (j endY) {

        if (board[i][j] == ico board[i + 1][j + 1] == ico) {

        sameCount++;

        } else if (sameCount != WIN_COUNT - 1) {

        sameCount = 0;

        }

        j++;

        }

        }

        }

        return sameCount == WIN_COUNT - 1 ? true : false;

        }

        public static void main(String[] args) throws Exception {

        GobangGame gb = new GobangGame(new Chessboard());

        gb.start();

        }

        }

        <small id='s61e2grv'></small><noframes id='vk1rgf4s'>

          <tbody id='ofsiv44b'></tbody>
        <tfoot id='jyk531kz'></tfoot>
        1. <i id='1l22btmu'><tr id='ln7r35m9'><dt id='ffzeij4m'><q id='ti1mcasa'><span id='8yizq6j9'><b id='u42gk4gl'><form id='0a7dym9w'><ins id='gxribq7j'></ins><ul id='3u3io1cm'></ul><sub id='813y2v5o'></sub></form><legend id='240r3zor'></legend><bdo id='q7aquinu'><pre id='pgpbbekm'><center id='ek3cjpsp'></center></pre></bdo></b><th id='y4an7k3c'></th></span></q></dt></tr></i><div class="c8jzdxauzz" id='i67tjndp'><tfoot id='3un6qwt9'></tfoot><dl id='ds704c64'><fieldset id='b87uekpz'></fieldset></dl></div>
                <bdo id='z9d2q75s'></bdo><ul id='ssqb023p'></ul>

                  <legend id='5n6hqg5o'><style id='76oygtfo'><dir id='fuw3toqo'><q id='r0rviavv'></q></dir></style></legend>

                • 上一篇:矩陣乘法java代碼 java編寫(xiě)矩陣乘法

                  欄    目:Java編程

                  下一篇:沒(méi)有了

                  本文標(biāo)題:五子棋游戲的java代碼 基于java的五子棋游戲的設(shè)計(jì)代碼

                  本文地址:http://mengdiqiu.com.cn/a1/Javabiancheng/17355.html

                  網(wǎng)頁(yè)制作CMS教程網(wǎng)絡(luò)編程軟件編程腳本語(yǔ)言數(shù)據(jù)庫(kù)服務(wù)器

                  如果侵犯了您的權(quán)利,請(qǐng)與我們聯(lián)系,我們將在24小時(shí)內(nèi)進(jìn)行處理、任何非本站因素導(dǎo)致的法律后果,本站均不負(fù)任何責(zé)任。

                  聯(lián)系QQ:835971066 | 郵箱:835971066#qq.com(#換成@)

                  Copyright © 2002-2020 腳本教程網(wǎng) 版權(quán)所有

                        <bdo id='4xjphme4'></bdo><ul id='r6ncuo2t'></ul>
                      <i id='yhs99j2g'><tr id='8n4hzx4a'><dt id='14z5zf4w'><q id='kylcxicz'><span id='c9pcwuua'><b id='dp9yfy68'><form id='qmg1agys'><ins id='gvheb5ba'></ins><ul id='scuw6khb'></ul><sub id='rdwc791m'></sub></form><legend id='5wikjndf'></legend><bdo id='kxndfi6s'><pre id='9rg1746x'><center id='sadimqi9'></center></pre></bdo></b><th id='bii7r8it'></th></span></q></dt></tr></i><div class="c8jzdxauzz" id='bb87ogdw'><tfoot id='4cogj9k3'></tfoot><dl id='srawtvdy'><fieldset id='8m2us1w9'></fieldset></dl></div>

                    1. <tfoot id='88bz2h2g'></tfoot><legend id='qtadhlff'><style id='e7jgkwmv'><dir id='sqdnfxe6'><q id='xn7xsq2e'></q></dir></style></legend>

                      <small id='wz7s41oo'></small><noframes id='tkmsx11q'>