In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)05/31 Report--
The main content of this article is to explain "how to use JavaSE to achieve Gobang game", interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to use JavaSE to realize the game of backgammon.
Using object-oriented thinking, the realization of backgammon is divided into four modules:
Main function public class main {public static void main (String [] args) {player player1 = new player (); game game1 = new game (player1); while (true) {game1.initialize (); game1.play (); game1.destroy (); boolean b = player1.queryContinue () If (! B) {System.out.println ("Welcome to play next time"); break;} chessboard module design
Chessboard initialization
Accept the player to drop the son and return to the current chessboard state
Accept AI drop and return to the current chessboard state
Judge the winner, draw or continue the game, and the new game resets the board.
Import java.util.Arrays;public class chessboard {private static final int blank = 0; private static final int circle = 1; private static final int cross = 2; private int [] [] array = {{blank, blank},} Public boolean moveCircleAt (int row,int column) {if (Array [row] [column]! = blank) {return false;} array [row] [column] = circle; return true;} public boolean moveCrossAt (int row,int column) {if (Array [row] [column]! = blank) {return false } array [row] [column] = fork; return true;} public static final int CIRCLE_WIN = 0; public static final int CROSS_WIN = 1; public static final int DRAW = 2; public static final int CONTINUE = 3; private static String display (int I) {switch (I) {case blank: return "; case circle: return" @ " Case fork: return "*"; default:return ";} @ Override public String toString () {String s =" +-+\ n "; for (int I = 0 position I)
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.