关于棋牌游戏源代码开放
- 格式:doc
- 大小:36.00 KB
- 文档页数:4
经典的五子棋java程序(源带码)直接复制粘贴importjava.awt.*;importjava.awt.event.*;importjava.applet.Applet;importjava.awt.Color;publicclassenzitextends Applet implements ActionListener,MouseListener,MouseMotionListener,ItemListener{intcolor_Qizi=0;//旗子的颜色标识0:白子1:黑子intintGame_Start=0;//游戏开始标志0未开始1游戏中intintGame_Body[][]=newint[16][16]; //设置棋盘棋子状态0 无子1 白子2 黑子Button b1=new Button("游戏开始");Button b2=new Button("重置游戏");Label lblWin=new Label(" ");Checkbox ckbHB[]=new Checkbox[2];CheckboxGroupckgHB=new CheckboxGroup();publicvoidinit(){setLayout(null);addMouseListener(this);add(b1);b1.setBounds(330,50,80,30);b1.addActionListener(this);add(b2);b2.setBounds(330,90,80,30);b2.addActionListener(this);ckbHB[0]=new Checkbox("白子先",ckgHB,false);ckbHB[0].setBounds(320,20,60,30);ckbHB[1]=new Checkbox("黑子先",ckgHB,false);ckbHB[1].setBounds(380,20,60,30);add(ckbHB[0]);add(ckbHB[1]);ckbHB[0].addItemListener(this);ckbHB[1].addItemListener(this);add(lblWin);lblWin.setBounds(330,130,80,30);Game_start_csh();}publicvoiditemStateChanged(ItemEvent e){if (ckbHB[0].getState()) //选择黑子先还是白子先{color_Qizi=0;}else{color_Qizi=1;}}publicvoidactionPerformed(ActionEvent e){Graphics g=getGraphics();if (e.getSource()==b1){Game_start();}else{Game_re();}}publicvoidmousePressed(MouseEvent e){}publicvoidmouseClicked(MouseEvent e){Graphics g=getGraphics();int x1,y1;x1=e.getX();y1=e.getY();if (e.getX()<20 || e.getX()>300 || e.getY()<20 || e.getY()>300) {return;}if (x1%20>10){x1+=20;}if(y1%20>10){y1+=20;}x1=x1/20*20;y1=y1/20*20;set_Qizi(x1,y1);}publicvoidmouseEntered(MouseEvent e){}publicvoidmouseExited(MouseEvent e){}publicvoidmouseReleased(MouseEvent e){}publicvoidmouseDragged(MouseEvent e){}publicvoidmouseMoved(MouseEvent e){}publicvoid paint(Graphics g){draw_qipan(g);}publicvoid set_Qizi(intx,int y) //落子{if (intGame_Start==0) //判断游戏未开始{return;}if (intGame_Body[x/20][y/20]!=0){return;}Graphics g=getGraphics();if (color_Qizi==1)//判断黑子还是白子{g.setColor(Color.black);color_Qizi=0;}else{g.setColor(Color.white);color_Qizi=1;}g.fillOval(x-10,y-10,20,20);intGame_Body[x/20][y/20]=color_Qizi+1;if (Game_win_1(x/20,y/20)) //判断输赢{lblWin.setText(Get_qizi_color(color_Qizi)+"赢了!"); intGame_Start=0;}if (Game_win_2(x/20,y/20)) //判断输赢{lblWin.setText(Get_qizi_color(color_Qizi)+"赢了!"); intGame_Start=0;}if (Game_win_3(x/20,y/20)) //判断输赢{lblWin.setText(Get_qizi_color(color_Qizi)+"赢了!"); intGame_Start=0;}if (Game_win_4(x/20,y/20)) //判断输赢{lblWin.setText(Get_qizi_color(color_Qizi)+"赢了!"); intGame_Start=0;}}public String Get_qizi_color(int x){if (x==0){return"黑子";}else{return"白子";}}publicvoid draw_qipan(Graphics G) //画棋盘15*15{G.setColor(Color.lightGray);G.fill3DRect(10,10,300,300,true);G.setColor(Color.black);for(inti=1;i<16;i++){G.drawLine(20,20*i,300,20*i);G.drawLine(20*i,20,20*i,300);}}publicvoid Game_start() //游戏开始{intGame_Start=1;Game_btn_enable(false);b2.setEnabled(true);}publicvoid Game_start_csh() //游戏开始初始化{intGame_Start=0;Game_btn_enable(true);b2.setEnabled(false);ckbHB[0].setState(true);for (inti=0;i<16 ;i++ ){for (int j=0;j<16 ;j++ ){intGame_Body[j]=0;}}lblWin.setText("");}publicvoid Game_re() //游戏重新开始{repaint();Game_start_csh();}publicvoid Game_btn_enable(boolean e) //设置组件状态{b1.setEnabled(e);b2.setEnabled(e);ckbHB[0].setEnabled(e);ckbHB[1].setEnabled(e);}publicboolean Game_win_1(intx,int y) //判断输赢横{int x1,y1,t=1;x1=x;y1=y;for (inti=1;i<5 ;i++ ){if (x1>15){break;}if (intGame_Body[x1+i][y1]==intGame_Body[x][y]) {t+=1;}else{break;}}for (inti=1;i<5 ;i++ ){if (x1<1){break;}if(intGame_Body[x1-i][y1]==intGame_Body[x][y]) {t+=1;}else{break;}}if (t>4){returntrue;}else{returnfalse;}}publicboolean Game_win_2(intx,int y) //判断输赢竖{int x1,y1,t=1;x1=x;y1=y;for (inti=1;i<5 ;i++ ){if (x1>15){break;}if (intGame_Body[x1][y1+i]==intGame_Body[x][y]){t+=1;}else{break;}}for (inti=1;i<5 ;i++ ){if (x1<1){break;}if(intGame_Body[x1][y1-i]==intGame_Body[x][y]) {t+=1;}else{break;}}if (t>4){returntrue;}else{returnfalse;}}publicboolean Game_win_3(intx,int y) //判断输赢左斜{int x1,y1,t=1;x1=x;y1=y;for (inti=1;i<5 ;i++ ){if (x1>15){break;}if (intGame_Body[x1+i][y1-i]==intGame_Body[x][y]) {t+=1;}else{break;}}for (inti=1;i<5 ;i++ ){if (x1<1){break;}if(intGame_Body[x1-i][y1+i]==intGame_Body[x][y]) {t+=1;}else{break;}}if (t>4){returntrue;}else{returnfalse;}}publicboolean Game_win_4(intx,int y) //判断输赢左斜{int x1,y1,t=1;x1=x;y1=y;for (inti=1;i<5 ;i++ ){if (x1>15){break;}if (intGame_Body[x1+i][y1+i]==intGame_Body[x][y]) {t+=1;}else{break;}}for (inti=1;i<5 ;i++ ){if (x1<1){break;}if(intGame_Body[x1-i][y1-i]==intGame_Body[x][y]) {t+=1;}else{break;}}if (t>4){returntrue;}else{returnfalse;}}}。
import java.awt.*;import java.awt.event.*;import java.io.*;import .*;import java.util.*;class clientThread extends Thread {chessClient chessclient;clientThread(chessClient chessclient) {this.chessclient = chessclient;}public void acceptMessage(String recMessage) {if (recMessage.startsWith("/userlist ")) {StringTokenizer userToken = new StringTokenizer(recMessage, " ");int userNumber = 0;erList.removeAll();erChoice.removeAll();erChoice.addItem("所有人");while (userToken.hasMoreTokens()) {String user = (String) userToken.nextToken(" ");if (userNumber > 0 && !user.startsWith("[inchess]")) {erList.add(user);erChoice.addItem(user);}userNumber++;}erChoice.select("所有人");} else if (recMessage.startsWith("/yourname ")) {chessclient.chessClientName = recMessage.substring(10);chessclient.setTitle("Java五子棋客户端" + "用户名:"+ chessclient.chessClientName);} else if (recMessage.equals("/reject")) {try {chessclient.chesspad.statusText.setText("不能加入游戏");chessclient.controlpad.cancelGameButton.setEnabled(false);chessclient.controlpad.joinGameButton.setEnabled(true);chessclient.controlpad.creatGameButton.setEnabled(true);} catch (Exception ef) {chessclient.chatpad.chatLineArea.setText("chessclient.chesspad.chessSocket.close无法关闭");}chessclient.controlpad.joinGameButton.setEnabled(true);} else if (recMessage.startsWith("/peer ")) {chessclient.chesspad.chessPeerName = recMessage.substring(6);if (chessclient.isServer) {chessclient.chesspad.chessColor = 1;chessclient.chesspad.isMouseEnabled = true;chessclient.chesspad.statusText.setText("请黑棋下子");} else if (chessclient.isClient) {chessclient.chesspad.chessColor = -1;chessclient.chesspad.statusText.setText("已加入游戏,等待对方下子...");}} else if (recMessage.equals("/youwin")) {chessclient.isOnChess = false;chessclient.chesspad.chessVictory(chessclient.chesspad.chessColor);chessclient.chesspad.statusText.setText("对方退出,请点放弃游戏退出连接");chessclient.chesspad.isMouseEnabled = false;} else if (recMessage.equals("/OK")) {chessclient.chesspad.statusText.setText("创建游戏成功,等待别人加入...");} else if (recMessage.equals("/error")) {chessclient.chatpad.chatLineArea.append("传输错误:请退出程序,重新加入\n");} else {chessclient.chatpad.chatLineArea.append(recMessage + "\n");chessclient.chatpad.chatLineArea.setCaretPosition(chessclient.chatpad.chatLineArea.getText().length());}}public void run() {String message = "";try {while (true) {message = chessclient.in.readUTF();acceptMessage(message);}} catch (IOException es) {}}}public class chessClient extends Frame implements ActionListener, KeyListener { userPad userpad = new userPad();chatPad chatpad = new chatPad();controlPad controlpad = new controlPad();chessPad chesspad = new chessPad();inputPad inputpad = new inputPad();Socket chatSocket;DataInputStream in;DataOutputStream out;String chessClientName = null;String host = null;int port = 4331;boolean isOnChat = false; // 在聊天?boolean isOnChess = false; // 在下棋?boolean isGameConnected = false; // 下棋的客户端连接?boolean isServer = false; // 如果是下棋的主机boolean isClient = false; // 如果是下棋的客户端Panel southPanel = new Panel();Panel northPanel = new Panel();Panel centerPanel = new Panel();Panel westPanel = new Panel();Panel eastPanel = new Panel();chessClient() {super("Java五子棋客户端");setLayout(new BorderLayout());host = controlpad.inputIP.getText();westPanel.setLayout(new BorderLayout());westPanel.add(userpad, BorderLayout.NORTH);westPanel.add(chatpad, BorderLayout.CENTER);westPanel.setBackground(Color.pink);inputpad.inputWords.addKeyListener(this);chesspad.host = controlpad.inputIP.getText();centerPanel.add(chesspad, BorderLayout.CENTER);centerPanel.add(inputpad, BorderLayout.SOUTH);centerPanel.setBackground(Color.pink);controlpad.connectButton.addActionListener(this);controlpad.creatGameButton.addActionListener(this);controlpad.joinGameButton.addActionListener(this);controlpad.cancelGameButton.addActionListener(this);controlpad.exitGameButton.addActionListener(this);controlpad.creatGameButton.setEnabled(false);controlpad.joinGameButton.setEnabled(false);controlpad.cancelGameButton.setEnabled(false);southPanel.add(controlpad, BorderLayout.CENTER);southPanel.setBackground(Color.pink);addWindowListener(new WindowAdapter() {public void windowClosing(WindowEvent e) {if (isOnChat) {try {chatSocket.close();} catch (Exception ed) {}}if (isOnChess || isGameConnected) {try {chesspad.chessSocket.close();} catch (Exception ee) {}}System.exit(0);}public void windowActivated(WindowEvent ea) {}});add(westPanel, BorderLayout.WEST);add(centerPanel, BorderLayout.CENTER);add(southPanel, BorderLayout.SOUTH);pack();setSize(670, 548);setVisible(true);setResizable(false);validate();}public boolean connectServer(String serverIP, int serverPort)throws Exception {try {chatSocket = new Socket(serverIP, serverPort);in = new DataInputStream(chatSocket.getInputStream());out = new DataOutputStream(chatSocket.getOutputStream());clientThread clientthread = new clientThread(this);clientthread.start();isOnChat = true;return true;} catch (IOException ex) {chatpad.chatLineArea.setText("chessClient:connectServer:无法连接,建议重新启动程序\n");}return false;}public void actionPerformed(ActionEvent e) {if (e.getSource() == controlpad.connectButton) {host = chesspad.host = controlpad.inputIP.getText();try {if (connectServer(host, port)) {chatpad.chatLineArea.setText("");controlpad.connectButton.setEnabled(false);controlpad.creatGameButton.setEnabled(true);controlpad.joinGameButton.setEnabled(true);chesspad.statusText.setText("连接成功,请创建游戏或加入游戏");}} catch (Exception ei) {chatpad.chatLineArea.setText("controlpad.connectButton:无法连接,建议重新启动程序\n");}}if (e.getSource() == controlpad.exitGameButton) {if (isOnChat) {try {chatSocket.close();} catch (Exception ed) {}}if (isOnChess || isGameConnected) {try {chesspad.chessSocket.close();} catch (Exception ee) {}}System.exit(0);}if (e.getSource() == controlpad.joinGameButton) {String selectedUser = erList.getSelectedItem();if (selectedUser == null || selectedUser.startsWith("[inchess]")|| selectedUser.equals(chessClientName)) {chesspad.statusText.setText("必须先选定一个有效用户");} else {try {if (!isGameConnected) {if (chesspad.connectServer(chesspad.host, chesspad.port)) {isGameConnected = true;isOnChess = true;isClient = true;controlpad.creatGameButton.setEnabled(false);controlpad.joinGameButton.setEnabled(false);controlpad.cancelGameButton.setEnabled(true);chesspad.chessthread.sendMessage("/joingame "+ erList.getSelectedItem() + " "+ chessClientName);}} else {isOnChess = true;isClient = true;controlpad.creatGameButton.setEnabled(false);controlpad.joinGameButton.setEnabled(false);controlpad.cancelGameButton.setEnabled(true);chesspad.chessthread.sendMessage("/joingame "+ erList.getSelectedItem() + " "+ chessClientName);}} catch (Exception ee) {isGameConnected = false;isOnChess = false;isClient = false;controlpad.creatGameButton.setEnabled(true);controlpad.joinGameButton.setEnabled(true);controlpad.cancelGameButton.setEnabled(false);chatpad.chatLineArea.setText("chesspad.connectServer无法连接\n" + ee);}}}if (e.getSource() == controlpad.creatGameButton) {try {if (!isGameConnected) {if (chesspad.connectServer(chesspad.host, chesspad.port)) {isGameConnected = true;isOnChess = true;isServer = true;controlpad.creatGameButton.setEnabled(false);controlpad.joinGameButton.setEnabled(false);controlpad.cancelGameButton.setEnabled(true);chesspad.chessthread.sendMessage("/creatgame "+ "[inchess]" + chessClientName);}} else {isOnChess = true;isServer = true;controlpad.creatGameButton.setEnabled(false);controlpad.joinGameButton.setEnabled(false);controlpad.cancelGameButton.setEnabled(true);chesspad.chessthread.sendMessage("/creatgame "+ "[inchess]" + chessClientName);}} catch (Exception ec) {isGameConnected = false;isOnChess = false;isServer = false;controlpad.creatGameButton.setEnabled(true);controlpad.joinGameButton.setEnabled(true);controlpad.cancelGameButton.setEnabled(false);ec.printStackTrace();chatpad.chatLineArea.setText("chesspad.connectServer无法连接\n"+ ec);}}if (e.getSource() == controlpad.cancelGameButton) {if (isOnChess) {chesspad.chessthread.sendMessage("/giveup " + chessClientName);chesspad.chessVictory(-1 * chesspad.chessColor);controlpad.creatGameButton.setEnabled(true);controlpad.joinGameButton.setEnabled(true);controlpad.cancelGameButton.setEnabled(false);chesspad.statusText.setText("请建立游戏或者加入游戏");}if (!isOnChess) {controlpad.creatGameButton.setEnabled(true);controlpad.joinGameButton.setEnabled(true);controlpad.cancelGameButton.setEnabled(false);chesspad.statusText.setText("请建立游戏或者加入游戏");}isClient = isServer = false;}}public void keyPressed(KeyEvent e) {TextField inputWords = (TextField) e.getSource();if (e.getKeyCode() == KeyEvent.VK_ENTER) {if (erChoice.getSelectedItem().equals("所有人")) {try {out.writeUTF(inputWords.getText());inputWords.setText("");} catch (Exception ea) {chatpad.chatLineArea.setText("chessClient:KeyPressed无法连接,建议重新连接\n");erList.removeAll();erChoice.removeAll();inputWords.setText("");controlpad.connectButton.setEnabled(true);}} else {try {out.writeUTF("/" + erChoice.getSelectedItem()+ " " + inputWords.getText());inputWords.setText("");} catch (Exception ea) {chatpad.chatLineArea.setText("chessClient:KeyPressed无法连接,建议重新连接\n");erList.removeAll();erChoice.removeAll();inputWords.setText("");controlpad.connectButton.setEnabled(true);}}}}public void keyTyped(KeyEvent e) {}public void keyReleased(KeyEvent e) {}public static void main(String args[]) {chessClient chessClient = new chessClient();}}。
关于棋牌游戏源代码开放在现今的棋牌游戏运营行业如火如荼的阶段,为了减少与避免一些初次接触此行业的运营商被一些产品开发商公司蒙骗上当,特此编写以下的一些说明和答疑,花点时间认真阅读和思考,可能会为您减少巨大的损失。
深圳市壹柒游网络科技有限公司为您全面解答。
1.对运营商开放源代码,可以使运营商根据运营环境与实际情况调节平台,而不被产品提供商所牵制:运营棋牌游戏,本质上做的事情就是为玩家提供最好的服务和游戏娱乐环境,玩家在这里玩开心,才会留下来,并为拉入更加多的朋友进来,从而才会使你赢取利润,是相辅相成的,是一个因果关系。
而玩家的需求日新月异,你必须根据实际的环境,调节必要的平台功能,例如注册登录策略,游戏奖励策略,游戏规则修改策略,引导购买会员策略,引导购买道具策略等等。
不同的运营时期,所进行的定制策略和程度是不一样的,所以运营商几乎每天都有修改定制部分的欲望与需求。
若运营没有得到源代码,将需要进行一系列繁琐过程:联系开发商,商讨价格,付款,等待开发,然后等待漫长的交付测试阶段。
市场机遇是不会等您的,您说这过程,使您错过了多少发展的机遇呢?从事实也得到证明,横观现今互联网的游戏运营商,从不对运营商开放源代码的棋牌站点,运营成功的又能有多少呢?答案是几乎没有。
再看使用了开放源代码的成功而且还保持不断发展的站点呢?数目是非常多的,具体的资料可以到网上搜索就能得到,这里我们就不逐一提及了。
您说,怎么样的系统您的发展是否更加有利呢?更加容易成功呢?2.对运营商开放源代码,不需要为二次开发承担昂贵的开发费用:拥有了产品源代码,才可以进行二次开发,才可以时刻根据市场的需求的变化而立即变化。
而对于一些不牵涉到高级技术能力的功能的修改,也需要开发商加入的话,容易造成运营策略的泄漏,被其他人捷足先登了。
而且开发商除了收取开发成本的人员费用外,还需要收取您的人员管理成本,市场拓展成本,还有公司的收入等。
而这一切的成本,若运营商有了系统源代码后,您的运营成本将会减少很多,而这些成本费用的节省,可以使您投入到市场营销方面,赢取更加多的发展机遇。
麻将原代码*/#include "dos.h"#include "stdio.h"#include "graphics.h"#include "bios.h"#include "conio.h"#include "stdlib.h"unsigned char far *video_buffer=(char far *)0xA0000000L;#define VGA256 0x13 /*图形模式13h*/#define TEXT_MODE 0x03 /*普通文本模式*/#define SETVGA Set_Video_Mode(VGA256)#define OUTVGA Set_Video_Mode(TEXT_MODE)#define BYTE unsigned char#define WORD unsigned int#define DWORD unsigned int#define ESC 283#define LEFT 19200#define RIGHT 19712#define H 9064#define ENTER 7181unsigned long int z=54400,zz=0,zy=0,zyy=0,z1=0,zl=10140;int key=0,keyy=0,sing=0,sing1=0,second=0,threes=0;struct chi{int lg;int lgg;}ch[13];struct mj{ char *name; /*名字*/int data1; /*是否已出,无用了*/int data2; /*是否在手中,1为自己,2为对方*/int number; /*同一个花色的第几张,共4张*/}m[136]={"1.bmp",0,0,1,"1.bmp",0,0,2,"1.bmp",0,0,3,"1.bmp",0,0,4,"2.bmp",0,0,1, "2.bmp",0,0,2,"2.bmp",0,0,3,"2.bmp",0,0,4,"3.bmp",0,0,1,"3.bmp",0,0,2,"3.bmp",0,0,3,"3.bmp",0,0,4,"4.bmp",0,0,1,"4.bmp",0,0,2,"4.bmp",0,0,3,"4.bmp",0,0,4,"5.bmp",0,0,1,"5.bmp",0,0,2,"5.bmp",0,0,3,"5.bmp",0,0,4,"6.bmp",0,0,1,"6.bmp",0,0,2,"6.bmp",0,0,3,"6.bmp",0,0,4,"7.bmp",0,0,1,"7.bmp",0,0,2,"7.bmp",0,0,3,"7.bmp",0,0,4,"8.bmp",0,0,1,"8.bmp",0,0,2,"8.bmp",0,0,3,"8.bmp",0,0,4,"9.bmp",0,0,1,"9.bmp",0,0,2,"9.bmp",0,0,3,"9.bmp",0,0,4,"10.bmp",0,0,1,"10.bmp",0,0,2,"10.bmp",0,0,3,"10.bmp",0,0,4, "11.bmp",0,0,1,"11.bmp",0,0,2,"11.bmp",0,0,3,"11.bmp",0,0,4,"12.bmp",0,0,1, "12.bmp",0,0,2,"12.bmp",0,0,3,"12.bmp",0,0,4,"13.bmp",0,0,1,"13.bmp",0,0,2,"13.bmp",0,0,3,"13.bmp",0,0,4,"14.bmp",0,0,1,"14.bmp",0,0,2,"14.bmp",0,0,3, "14.bmp",0,0,4,"15.bmp",0,0,1,"15.bmp",0,0,2,"15.bmp",0,0,3,"15.bmp",0,0,4, "16.bmp",0,0,1,"16.bmp",0,0,2,"16.bmp",0,0,3,"16.bmp",0,0,4,"17.bmp",0,0,1, "17.bmp",0,0,2,"17.bmp",0,0,3,"17.bmp",0,0,4,"18.bmp",0,0,1,"18.bmp",0,0,2, "18.bmp",0,0,3,"18.bmp",0,0,4,"19.bmp",0,0,1,"19.bmp",0,0,2,"19.bmp",0,0,3, "19.bmp",0,0,4,"20.bmp",0,0,1,"20.bmp",0,0,2,"20.bmp",0,0,3,"20.bmp",0,0,4, "21.bmp",0,0,1,"21.bmp",0,0,2,"21.bmp",0,0,3,"21.bmp",0,0,4,"22.bmp",0,0,1, "22.bmp",0,0,2,"22.bmp",0,0,3,"22.bmp",0,0,4,"23.bmp",0,0,1,"23.bmp",0,0,2, "23.bmp",0,0,3,"23.bmp",0,0,4,"24.bmp",0,0,1,"24.bmp",0,0,2,"24.bmp",0,0,3, "24.bmp",0,0,4,"25.bmp",0,0,1,"25.bmp",0,0,2,"25.bmp",0,0,3,"25.bmp",0,0,4, "26.bmp",0,0,1,"26.bmp",0,0,2,"26.bmp",0,0,3,"26.bmp",0,0,4,"27.bmp",0,0,1, "27.bmp",0,0,2,"27.bmp",0,0,3,"27.bmp",0,0,4,"28.bmp",0,0,1,"28.bmp",0,0,2, "28.bmp",0,0,3,"28.bmp",0,0,4,"29.bmp",0,0,1,"29.bmp",0,0,2,"29.bmp",0,0,3, "29.bmp",0,0,4,"30.bmp",0,0,1,"30.bmp",0,0,2,"30.bmp",0,0,3,"30.bmp",0,0,4, "31.bmp",0,0,1,"31.bmp",0,0,2,"31.bmp",0,0,3,"31.bmp",0,0,4,"32.bmp",0,0,1, "32.bmp",0,0,2,"32.bmp",0,0,3,"32.bmp",0,0,4,"33.bmp",0,0,1,"33.bmp",0,0,2, "33.bmp",0,0,3,"33.bmp",0,0,4,"34.bmp",0,0,1,"34.bmp",0,0,2,"34.bmp",0,0,3, "34.bmp"};struct every{ int *k; /*名字*/int oneorfour; /*同一张牌的第几张*/int number; /*第几张牌136*/int p;int g;int c;int d[2];};struct me{ int m; /*定义有几张牌,开始有13张随着游戏的进行,会越来越小*/ int p; /*乓对方*/int c; /*吃对方*/int g; /*杠*/struct every pp[14]; /*存放手上的牌*/}me;struct computer{ int m;int p;int c;int g;struct every pp[14];}computer,comp;/* 设置调色板*/void Set_Palette(int Color,BYTE r,BYTE g,BYTE b){outportb(0x3c8,Color); /*0x3c8写端口写色号*/outportb(0x3c9,r); /*0x3c9数据端口R、G、B的比例*/outportb(0x3c9,g);outportb(0x3c9,b);}/*0x3c7读端口0x3c6计算机调色板寄存器调用端口*//* 设置显示模式的函数*/void Set_Video_Mode(int mode){union REGS inregs,outregs; /*定义输入和返回寄存器*/inregs.h.ah=0; /*ah存放功能号0h表示进入视频模式*/inregs.h.al=(unsigned char)mode; /*al存放要设定的视频模式*/int86(0x10,&inregs,&outregs); /*通过10h中断设定显示模式int86()包含在dos.h*/ }void v_line(int y0,int y1,int x,unsigned int color){ unsigned int address,n,temp;if(y0>y1){temp=y1;y1=y0;y0=temp;}address=320*y0+x;for(n=0;n<=y1-y0;n++){video_buffer[address]=color;address+=320;}}void h_line(int x0,int x1,int y,unsigned int color){ unsigned int address,n,temp;if(x0>x1){temp=x1;x1=x0;x0=temp;}address=320*y+x0;for(n=0;n<=x1-x0;n++){video_buffer[address]=color;address+=1;}}void p_pixel(int x,int y,unsigned int color){ video_buffer[y*320+x]=color;}void s_square(int x,int y,int side,int color){h_line(x,x+side,y,color);h_line(x,x+side,y+side,color);v_line(y,y+side,x,color);v_line(y,y+side,x+side,color);}void r_rectangle(int x1,int y1,int x2,int y2,int color) {h_line(x1,x2,y1,color);h_line(x1,x2,y2,color);v_line(y1,y2,x1,color);v_line(y1,y2,x2,color);}void fillRectangle(int x1,int y1,int x2,int y2,int color) {int i;for(i=y1;i<=y2;i++){h_line(x1,x2,i,color);}}void showbmp(int l){ FILE *bmp;int i,x,y;BYTE palette[256][3];bmp=fopen(me.pp[l].k,"rb");fseek(bmp,54,SEEK_SET);for(i=0;i<256;i++){palette[i][2]=fgetc(bmp)>>2;palette[i][1]=fgetc(bmp)>>2;palette[i][0]=fgetc(bmp)>>2;fgetc(bmp);Set_Palette(i,palette[i][0],palette[i][1],palette[i][2]); }for (y=0;y<30;y++)for(x=0;x<20;x++)pokeb(0xa000,y*320+x+z+zz+z1,fgetc(bmp));fclose(bmp);}void showbmpd(int l){ FILE *bmp;int i,x,y;BYTE palette[256][3];bmp=fopen(me.pp[l].k,"rb");fseek(bmp,54,SEEK_SET);for(i=0;i<256;i++){palette[i][2]=fgetc(bmp)>>2;palette[i][1]=fgetc(bmp)>>2;palette[i][0]=fgetc(bmp)>>2;fgetc(bmp);Set_Palette(i,palette[i][0],palette[i][1],palette[i][2]); }for (y=0;y<30;y++)for(x=0;x<20;x++)pokeb(0xa000,y*320+x+zyy,fgetc(bmp));fclose(bmp);}void showybmp(int ll){ FILE *bmp;int i,x,y;BYTE palette[256][3];bmp=fopen(computer.pp[ll].k,"rb");fseek(bmp,54,SEEK_SET);for(i=0;i<256;i++){palette[i][2]=fgetc(bmp)>>2;palette[i][1]=fgetc(bmp)>>2;palette[i][0]=fgetc(bmp)>>2;fgetc(bmp);Set_Palette(i,palette[i][0],palette[i][1],palette[i][2]); }for (y=0;y<30;y++)for(x=0;x<20;x++)pokeb(0xa000,y*320+x+zy,fgetc(bmp));fclose(bmp);}void showcbmp(int ll){ FILE *bmp;int i,x,y;BYTE palette[256][3];bmp=fopen(computer.pp[ll].k,"rb");fseek(bmp,54,SEEK_SET);for(i=0;i<256;i++){palette[i][2]=fgetc(bmp)>>2;palette[i][1]=fgetc(bmp)>>2;palette[i][0]=fgetc(bmp)>>2;fgetc(bmp);Set_Palette(i,palette[i][0],palette[i][1],palette[i][2]); }for (y=0;y<30;y++)for(x=0;x<20;x++)pokeb(0xa000,y*320+x+zyy,fgetc(bmp));fclose(bmp);}void bmpp(int number){ FILE *bmp;int i,x,y;BYTE palette[256][3];bmp=fopen(m[number].name,"rb");fseek(bmp,54,SEEK_SET);for(i=0;i<256;i++){palette[i][2]=fgetc(bmp)>>2;palette[i][1]=fgetc(bmp)>>2;palette[i][0]=fgetc(bmp)>>2;fgetc(bmp);Set_Palette(i,palette[i][0],palette[i][1],palette[i][2]); }for (y=0;y<30;y++)for(x=0;x<20;x++)pokeb(0xa000,y*320+x+zl,fgetc(bmp));fclose(bmp);}void comlipai() /*整理电脑的牌*/{ int n,j,u;int *lingshi;for(n=0;n<computer.m;n++)for(j=n;j<computer.m;j++){if(computer.pp[n].number>computer.pp[j+1].number) {lingshi=computer.pp[n].k;computer.pp[n].k=computer.pp[j+1].k;computer.pp[j+1].k=lingshi;u=computer.pp[n].oneorfour;computer.pp[n].oneorfour=computer.pp[j+1].oneorfour; computer.pp[j+1].oneorfour=u;u=computer.pp[n].number;computer.pp[n].number=computer.pp[j+1].number; computer.pp[j+1].number=u;}elseif(computer.pp[n].number==computer.pp[j+1].number)if(computer.pp[n].oneorfour>computer.pp[j+1].oneorfour) {lingshi=computer.pp[n].k;computer.pp[n].k=computer.pp[j+1].k;computer.pp[j+1].k=lingshi;u=computer.pp[n].oneorfour;computer.pp[n].oneorfour=computer.pp[j+1].oneorfour; computer.pp[j+1].oneorfour=u;u=computer.pp[n].number;computer.pp[n].number=computer.pp[j+1].number; computer.pp[j+1].number=u;}}}void melipai(){ int n,j,u;int *lingshi;for(n=0;n<me.m;n++)for(j=n;j<me.m;j++){if(me.pp[n].number>me.pp[j+1].number){lingshi=me.pp[n].k;me.pp[n].k=me.pp[j+1].k;me.pp[j+1].k=lingshi;u=me.pp[n].oneorfour;me.pp[n].oneorfour=me.pp[j+1].oneorfour;me.pp[j+1].oneorfour=u;u=me.pp[n].number;me.pp[n].number=me.pp[j+1].number;me.pp[j+1].number=u;}elseif(me.pp[n].number==me.pp[j+1].number)if(me.pp[n].oneorfour>me.pp[j+1].oneorfour){lingshi=me.pp[n].k;me.pp[n].k=me.pp[j+1].k;me.pp[j+1].k=lingshi;u=me.pp[n].oneorfour;me.pp[n].oneorfour=me.pp[j+1].oneorfour;me.pp[j+1].oneorfour=u;u=me.pp[n].number;me.pp[n].number=me.pp[j+1].number;me.pp[j+1].number=u;}}}void rgzn(int c) /*本程序涵数的核心针对电脑的牌*/ { int b=0,lg,lgg,logo,logoo,pg=0,gp=0,cs=0,f=0;if(me.pp[c].number<=35 && me.pp[c].number>=0){logo=1;if(me.pp[c].number<=3 && me.pp[c].number>=0) logoo=1;else if(me.pp[c].number<=7 && me.pp[c].number>=4) logoo=2;else if(me.pp[c].number<=11 && me.pp[c].number>=8) logoo=3;else if(me.pp[c].number<=15 && me.pp[c].number>=12) logoo=4;else if(me.pp[c].number<=19 && me.pp[c].number>=16) logoo=5;else if(me.pp[c].number<=23 && me.pp[c].number>=20) logoo=6;else if(me.pp[c].number<=27 && me.pp[c].number>=24) logoo=7;else if(me.pp[c].number<=31 && me.pp[c].number>=28) logoo=8;else if(me.pp[c].number<=35 && me.pp[c].number>=32) logoo=9;}else if(me.pp[c].number<=71 && me.pp[c].number>=36) {logo=2;if(me.pp[c].number<=39 && me.pp[c].number>=36) logoo=1;else if(me.pp[c].number<=43 && me.pp[c].number>=40)else if(me.pp[c].number<=47 && me.pp[c].number>=44) logoo=3;else if(me.pp[c].number<=51 && me.pp[c].number>=48) logoo=4;else if(me.pp[c].number<=55 && me.pp[c].number>=52) logoo=5;else if(me.pp[c].number<=59 && me.pp[c].number>=56) logoo=6;else if(me.pp[c].number<=63 && me.pp[c].number>=60) logoo=7;else if(me.pp[c].number<=67 && me.pp[c].number>=64) logoo=8;else if(me.pp[c].number<=71 && me.pp[c].number>=68) logoo=9;}else if(me.pp[c].number<=107 && me.pp[c].number>=72) {logo=3;if(me.pp[c].number<=75 && me.pp[c].number>=72) logoo=1;else if(me.pp[c].number<=79 && me.pp[c].number>=76) logoo=2;else if(me.pp[c].number<=83 && me.pp[c].number>=80) logoo=3;else if(me.pp[c].number<=87 && me.pp[c].number>=84) logoo=4;else if(me.pp[c].number<=91 && me.pp[c].number>=88) logoo=5;else if(me.pp[c].number<=95 && me.pp[c].number>=92) logoo=6;else if(me.pp[c].number<=99 && me.pp[c].number>=96) logoo=7;else if(me.pp[c].number<=103 && me.pp[c].number>=100) logoo=8;else if(me.pp[c].number<=107 && me.pp[c].number>=104) logoo=9;}else if(me.pp[c].number<=135 && me.pp[c].number>=108) {logo=4;if(me.pp[c].number<=111 && me.pp[c].number>=108) logoo=1;else if(me.pp[c].number<=115 && me.pp[c].number>=112)else if(me.pp[c].number<=119 && me.pp[c].number>=116)logoo=3;else if(me.pp[c].number<=123 && me.pp[c].number>=120)logoo=4;else if(me.pp[c].number<=127 && me.pp[c].number>=124)logoo=5;else if(me.pp[c].number<=131 && me.pp[c].number>=128)logoo=6;else if(me.pp[c].number<=135 && me.pp[c].number>=132)logoo=7;}while(b<=computer.m){if(computer.pp[b].number<=35 && computer.pp[b].number>=0) /*假定电脑经过分析后出了第一张牌*/{lg=1;computer.pp[b].d[0]=1;if(computer.pp[b].number<=3 && computer.pp[b].number>=0){lgg=1;computer.pp[b].d[1]=1;}else if(computer.pp[b].number<=7 && computer.pp[b].number>=4){lgg=2;computer.pp[b].d[1]=2;}else if(computer.pp[b].number<=11 && computer.pp[b].number>=8){lgg=3;computer.pp[b].d[1]=3;}else if(computer.pp[b].number<=15 && computer.pp[b].number>=12){lgg=4;computer.pp[b].d[1]=4;}else if(computer.pp[b].number<=19 && computer.pp[b].number>=16){lgg=5;computer.pp[b].d[1]=5;}else if(computer.pp[b].number<=23 && computer.pp[b].number>=20) {lgg=6;computer.pp[b].d[1]=6;}else if(computer.pp[b].number<=27 && computer.pp[b].number>=24) {lgg=7;computer.pp[b].d[1]=7;}else if(computer.pp[b].number<=31 && computer.pp[b].number>=28) {lgg=8;computer.pp[b].d[1]=8;}else if(computer.pp[b].number<=35 && computer.pp[b].number>=32) {lgg=9;computer.pp[b].d[1]=9;}}else if(computer.pp[b].number<=71 && computer.pp[b].number>=36) {lg=2;computer.pp[b].d[0]=2;if(computer.pp[b].number<=39 && computer.pp[b].number>=36) {lgg=1;computer.pp[b].d[1]=1;}else if(computer.pp[b].number<=43 && computer.pp[b].number>=40) {lgg=2;computer.pp[b].d[1]=2;}else if(computer.pp[b].number<=47 && computer.pp[b].number>=44) {lgg=3;computer.pp[b].d[1]=3;}else if(computer.pp[b].number<=51 && computer.pp[b].number>=48) {lgg=4;computer.pp[b].d[1]=4;}else if(computer.pp[b].number<=55 && computer.pp[b].number>=52) {lgg=5;computer.pp[b].d[1]=5;}else if(computer.pp[b].number<=59 && computer.pp[b].number>=56) {lgg=6;computer.pp[b].d[1]=6;}else if(computer.pp[b].number<=63 && computer.pp[b].number>=60) {lgg=7;computer.pp[b].d[1]=7;}else if(computer.pp[b].number<=67 && computer.pp[b].number>=64) {lgg=8;computer.pp[b].d[1]=8;}else if(computer.pp[b].number<=71 && computer.pp[b].number>=68) {lgg=9;computer.pp[b].d[1]=9;}}else if(computer.pp[b].number<=107 && computer.pp[b].number>=72) {lg=3;computer.pp[b].d[0]=3;if(computer.pp[b].number<=75 && computer.pp[b].number>=72){lgg=1;computer.pp[b].d[1]=1;}else if(computer.pp[b].number<=79 && computer.pp[b].number>=76) {lgg=2;computer.pp[b].d[1]=2;}else if(computer.pp[b].number<=83 && computer.pp[b].number>=80) {lgg=3;computer.pp[b].d[1]=3;}else if(computer.pp[b].number<=87 && computer.pp[b].number>=84) {lgg=4;computer.pp[b].d[1]=4;}else if(computer.pp[b].number<=91 && computer.pp[b].number>=88) {lgg=5;computer.pp[b].d[1]=5;}else if(computer.pp[b].number<=95 && computer.pp[b].number>=92) {lgg=6;computer.pp[b].d[1]=6;}else if(computer.pp[b].number<=99 && computer.pp[b].number>=96) {lgg=7;computer.pp[b].d[1]=7;}else if(computer.pp[b].number<=103 && computer.pp[b].number>=100) {lgg=8;computer.pp[b].d[1]=8;}else if(computer.pp[b].number<=107 && computer.pp[b].number>=104) {lgg=9;computer.pp[b].d[1]=9;}}else if(computer.pp[b].number<=135 && computer.pp[b].number>=108) {lg=4;computer.pp[b].d[0]=4;if(computer.pp[b].number<=111 && computer.pp[b].number>=108) {lgg=1;computer.pp[b].d[1]=1;}else if(computer.pp[b].number<=115 && computer.pp[b].number>=112) {lgg=2;computer.pp[b].d[1]=2;}else if(computer.pp[b].number<=119 && computer.pp[b].number>=116) {lgg=3;computer.pp[b].d[1]=3;}else if(computer.pp[b].number<=123 && computer.pp[b].number>=120) {lgg=4;computer.pp[b].d[1]=4;}else if(computer.pp[b].number<=127 && computer.pp[b].number>=124) {lgg=5;computer.pp[b].d[1]=5;}else if(computer.pp[b].number<=131 && computer.pp[b].number>=128) {lgg=6;computer.pp[b].d[1]=6;}else if(computer.pp[b].number<=135 && computer.pp[b].number>=132) {lgg=7;computer.pp[b].d[1]=7;}}if(logo==lg) /*如果相等的话,那再进一步的判断,乓杠的判断*/if(logoo==lgg)pg++;ch[b].lg=lg; /*保存电脑手里的每张牌的信息*/ch[b].lgg=lgg;lg=0;lgg=0;b++;}if(pg==2) /*乓*/{sing=1;b=computer.m;while(b!=-1){if(strcmp(me.pp[c].k,computer.pp[b].k)==0) computer.pp[b].p=1;b--;}}if(pg==3) /*杠*/{sing=2;b=computer.m;while(b!=-1){if(strcmp(me.pp[c].k,computer.pp[b].k)==0) computer.pp[b].g=1;b--;}}f=0;while(f<computer.m) /*吃的判断*/{ if(ch[f].lg==logo && ch[f].lg!=4){if(ch[f+1].lgg-ch[f].lgg==1) /*顺吃*/if(ch[f].lgg-logoo==1){gp++;computer.pp[f].c=1;computer.pp[f+1].c=1;}if(ch[f].lgg-ch[f+1].lgg==-1) /*逆吃*/if(ch[f+1].lgg-logoo==-1){gp++;computer.pp[f].c=1;computer.pp[f+1].c=1;}if(ch[f].lgg-logoo==-1) /*中吃*/if(ch[f+1].lgg-logoo==1){gp++;computer.pp[f].c=1;computer.pp[f+1].c=1;}if(gp==1)break;}f++;}if(gp==1){sing=7;}pg=0;gp=0;b=0;}void rgznme(int c) /*本程序涵数的核心针对我的牌*/{ int b=0,lg,lgg,logo,logoo,pg=0,gp=0,cs=0,f=0;if(computer.pp[c].number<=35 && computer.pp[c].number>=0) {logo=1;if(computer.pp[c].number<=3 && computer.pp[c].number>=0) logoo=1;else if(computer.pp[c].number<=7 && computer.pp[c].number>=4) logoo=2;else if(computer.pp[c].number<=11 && computer.pp[c].number>=8) logoo=3;else if(computer.pp[c].number<=15 && computer.pp[c].number>=12) logoo=4;else if(computer.pp[c].number<=19 && computer.pp[c].number>=16) logoo=5;else if(computer.pp[c].number<=23 && computer.pp[c].number>=20) logoo=6;else if(computer.pp[c].number<=27 && computer.pp[c].number>=24) logoo=7;else if(computer.pp[c].number<=31 && computer.pp[c].number>=28) logoo=8;else if(computer.pp[c].number<=35 && computer.pp[c].number>=32) logoo=9;}else if(computer.pp[c].number<=71 && computer.pp[c].number>=36) {logo=2;if(computer.pp[c].number<=39 && computer.pp[c].number>=36) logoo=1;else if(computer.pp[c].number<=43 && computer.pp[c].number>=40)else if(computer.pp[c].number<=47 && computer.pp[c].number>=44) logoo=3;else if(computer.pp[c].number<=51 && computer.pp[c].number>=48) logoo=4;else if(computer.pp[c].number<=55 && computer.pp[c].number>=52) logoo=5;else if(computer.pp[c].number<=59 && computer.pp[c].number>=56) logoo=6;else if(computer.pp[c].number<=63 && computer.pp[c].number>=60) logoo=7;else if(computer.pp[c].number<=67 && computer.pp[c].number>=64) logoo=8;else if(computer.pp[c].number<=71 && computer.pp[c].number>=68) logoo=9;}else if(computer.pp[c].number<=107 && computer.pp[c].number>=72) {logo=3;if(computer.pp[c].number<=75 && computer.pp[c].number>=72) logoo=1;else if(computer.pp[c].number<=79 && computer.pp[c].number>=76) logoo=2;else if(computer.pp[c].number<=83 && computer.pp[c].number>=80) logoo=3;else if(computer.pp[c].number<=87 && computer.pp[c].number>=84) logoo=4;else if(computer.pp[c].number<=91 && computer.pp[c].number>=88) logoo=5;else if(computer.pp[c].number<=95 && computer.pp[c].number>=92) logoo=6;else if(computer.pp[c].number<=99 && computer.pp[c].number>=96) logoo=7;else if(computer.pp[c].number<=103 && computer.pp[c].number>=100) logoo=8;else if(computer.pp[c].number<=107 && computer.pp[c].number>=104) logoo=9;}else if(computer.pp[c].number<=135 && computer.pp[c].number>=108) {logo=4;if(computer.pp[c].number<=111 && computer.pp[c].number>=108) logoo=1;else if(computer.pp[c].number<=115 && computer.pp[c].number>=112)else if(computer.pp[c].number<=119 && computer.pp[c].number>=116)logoo=3;else if(computer.pp[c].number<=123 && computer.pp[c].number>=120)logoo=4;else if(computer.pp[c].number<=127 && computer.pp[c].number>=124)logoo=5;else if(computer.pp[c].number<=131 && computer.pp[c].number>=128)logoo=6;else if(computer.pp[c].number<=135 && computer.pp[c].number>=132)logoo=7;}while(b<=me.m){if(me.pp[b].number<=35 && me.pp[b].number>=0) /*我分析后出了第一张牌*/ {lg=1;me.pp[b].d[0]=1;if(me.pp[b].number<=3 && me.pp[b].number>=0){lgg=1;me.pp[b].d[1]=1;}else if(me.pp[b].number<=7 && me.pp[b].number>=4){lgg=2;me.pp[b].d[1]=2;}else if(me.pp[b].number<=11 && me.pp[b].number>=8){lgg=3;me.pp[b].d[1]=3;}else if(me.pp[b].number<=15 && me.pp[b].number>=12){lgg=4;me.pp[b].d[1]=4;}else if(me.pp[b].number<=19 && me.pp[b].number>=16){lgg=5;me.pp[b].d[1]=5;}else if(me.pp[b].number<=23 && me.pp[b].number>=20){lgg=6;me.pp[b].d[1]=6;}else if(me.pp[b].number<=27 && me.pp[b].number>=24) {lgg=7;me.pp[b].d[1]=7;}else if(me.pp[b].number<=31 && me.pp[b].number>=28) {lgg=8;me.pp[b].d[1]=8;}else if(me.pp[b].number<=35 && me.pp[b].number>=32) {lgg=9;me.pp[b].d[1]=9;}}else if(me.pp[b].number<=71 && me.pp[b].number>=36) {lg=2;me.pp[b].d[0]=2;if(me.pp[b].number<=39 && me.pp[b].number>=36) {lgg=1;me.pp[b].d[1]=1;}else if(me.pp[b].number<=43 && me.pp[b].number>=40) {lgg=2;me.pp[b].d[1]=2;}else if(me.pp[b].number<=47 && me.pp[b].number>=44) {lgg=3;me.pp[b].d[1]=3;}else if(me.pp[b].number<=51 && me.pp[b].number>=48) {lgg=4;me.pp[b].d[1]=4;}else if(me.pp[b].number<=55 && me.pp[b].number>=52) {lgg=5;me.pp[b].d[1]=5;}else if(me.pp[b].number<=59 && me.pp[b].number>=56) {lgg=6;me.pp[b].d[1]=6;}else if(me.pp[b].number<=63 && me.pp[b].number>=60) {lgg=7;me.pp[b].d[1]=7;}else if(me.pp[b].number<=67 && me.pp[b].number>=64) {lgg=8;me.pp[b].d[1]=8;}else if(me.pp[b].number<=71 && me.pp[b].number>=68) {lgg=9;me.pp[b].d[1]=9;}}else if(me.pp[b].number<=107 && me.pp[b].number>=72) {lg=3;me.pp[b].d[0]=3;if(me.pp[b].number<=75 && me.pp[b].number>=72){lgg=1;me.pp[b].d[1]=1;}else if(me.pp[b].number<=79 && me.pp[b].number>=76) {lgg=2;me.pp[b].d[1]=2;}else if(me.pp[b].number<=83 && me.pp[b].number>=80) {lgg=3;me.pp[b].d[1]=3;}else if(me.pp[b].number<=87 && me.pp[b].number>=84) {lgg=4;me.pp[b].d[1]=4;}else if(me.pp[b].number<=91 && me.pp[b].number>=88) {lgg=5;me.pp[b].d[1]=5;}else if(me.pp[b].number<=95 && me.pp[b].number>=92) {lgg=6;me.pp[b].d[1]=6;}else if(me.pp[b].number<=99 && me.pp[b].number>=96) {lgg=7;me.pp[b].d[1]=7;}else if(me.pp[b].number<=103 && me.pp[b].number>=100) {lgg=8;me.pp[b].d[1]=8;}else if(me.pp[b].number<=107 && me.pp[b].number>=104) {lgg=9;me.pp[b].d[1]=9;}}else if(me.pp[b].number<=135 && me.pp[b].number>=108) {lg=4;me.pp[b].d[0]=4;if(me.pp[b].number<=111 && me.pp[b].number>=108) {lgg=1;me.pp[b].d[1]=1;}else if(me.pp[b].number<=115 && me.pp[b].number>=112) {lgg=2;me.pp[b].d[1]=2;}else if(me.pp[b].number<=119 && me.pp[b].number>=116) {lgg=3;me.pp[b].d[1]=3;}else if(me.pp[b].number<=123 && me.pp[b].number>=120) {lgg=4;me.pp[b].d[1]=4;}else if(me.pp[b].number<=127 && me.pp[b].number>=124) {lgg=5;me.pp[b].d[1]=5;}else if(me.pp[b].number<=131 && me.pp[b].number>=128) {lgg=6;me.pp[b].d[1]=6;}else if(me.pp[b].number<=135 && me.pp[b].number>=132) {lgg=7;me.pp[b].d[1]=7;}}}}void istwo(testt)int testt[];{ if(testt[0]==testt[1])second++;}void isthree(testt,n)int testt[],n=0;{ int i,j,flage=0,lianx=0,same=0;n=n/3;for(j=0;j<n;j++){for(i=j*3;i<2+j*3;i++){if(testt[i]==testt[i+1])same++;if(testt[i+1]-testt[i]==1)lianx++;}if(same==2)threes++;if(lianx==2)threes++;same=0;lianx=0;}}void panduan() /*本程序的精髓*/{int data[14];int pw[14];int pt[14];int pi[14];int pf[14];int test[12];int jj,w,mm,nn,tpp=0,lp=0,ww=0,tt=0,ii=0,ff=0;ill=0; for(jj=0;jj<=me.m;jj++){if(me.pp[jj].d[0]==1)data[jj]=me.pp[jj].d[1];if(me.pp[jj].d[0]==2)data[jj]=me.pp[jj].d[1]+10;if(me.pp[jj].d[0]==3)data[jj]=me.pp[jj].d[1]+20;if(me.pp[jj].d[0]==4)data[jj]=me.pp[jj].d[1]+30;}if(logo==2)w=logoo+10;if(logo==3)w=logoo+20;if(logo==4)w=logoo+30;data[computer.m+1]=w;for(mm=0;mm<=computer.m;mm++)for(nn=mm;nn<=computer.m;nn++)if(data[mm]>data[nn+1]){tpp=data[mm];data[mm]=data[nn+1];。
Java五子棋源代码本程序共有3个类,下载后将三个类复制到三个记事本里然后重名记事本(为了阅读方便分三个文件),其中main()方法在StartChessJFrame 类中。
我是菜鸟,交流QQ:609429837import java.awt.Color;public class Point {private int x;//棋盘中X的索引private int y;//棋盘中Y的索引private Color color;//颜色public static final int DIAMETER = 30;//直径public Point(int x,int y,Color color){ this.x=x;this.y=y;this.color =color;}//拿到棋盘中的Y索引public int getX(){return x;}public int getY(){return y;}//得到颜色public Color getColor(){return color;}}import javax.swing.*;import java.awt.*;import java.awt.event.MouseListener; importjava.awt.event.MouseMotionListener; import java.awt.event.MouseEvent;/*五子棋-棋盘类*/public class ChessBoard extends JPanel implements MouseListener {public static final int MARGIN = 30;//边距protected static final int GRID_SPAN = 35;//网格间距public static final int ROWS = 10;//棋盘行数public static final int COLS = 10;//棋盘列数Point[] chessList = new Point[(ROWS+1)*(COLS+1)];//初始化每个数组元素为nullboolean isBlack = true;//默认开始是黑棋先下boolean gameOver = false;//游戏是否结束int chessCount;//当前棋盘棋子的个数int xIndex,yIndex;//当前刚下的棋子的索引public ChessBoard(){super.setBackground(Color.ORANGE);//setBackground(Color.ORANGE);//设置背景颜色为橘黄色addMouseListener(this);//添加监听器addMouseMotionListener(new MouseMotionListener(){//匿名内部类public void mouseDragged(MouseEvent e){}public void mouseMoved(MouseEvent e){int x1 = (e.getX()- MARGIN +GRID_SPAN/2)/GRID_SPAN;//将鼠标单击的坐标位置转换成网格索引int y1 = (e.getY()- MARGIN +GRID_SPAN/2)/GRID_SPAN;//游戏已经结束,落在棋盘外,x、y 位置已经有棋子存在,不能下if(x1<0||x1>ROWS||y1<0||y1>COLS||gameOv er||findChess(x1,y1))setCursor(newCursor(Cursor.DEFAULT_CURSOR));//设置成默认形状elsesetCursor(newCursor(Cursor.HAND_CURSOR));//设置成手型}});}//绘制public void paintComponent(Graphics g){ super.paintComponent(g);//画棋类for(int i=0;i<=ROWS;i++){//画横线g.drawLine(MARGIN,MARGIN+i*GRID_SPAN,MARGIN+COLS*GRID_SPAN,MARGIN+i*GRID_SPAN);}for(int i=0;i<=COLS;i++){//画直线g.drawLine(MARGIN+i*GRID_SPAN,MARGIN,MA RGIN+i*GRID_SPAN,MARGIN+ROWS*GRID_SPAN);}//画棋子for(int i=0;i<chessCount;i++) {int xPos = chessList[i].getX()*GRID_SPAN+MARGIN;//网络交叉点的x坐标int yPos = chessList[i].getY()*GRID_SPAN+MARGIN;//网络交叉点的y坐标g.setColor(chessList[i].getColor());//设置颜色g.fillOval(xPos-Point.DIAMETER/2, yPos-Point.DIAMETER/2, Point.DIAMETER, Point.DIAMETER);//标记最后一个棋子的红矩形框if(i == chessCount -1){//最后一个棋子g.setColor(Color.red);g.drawRect(xPos - Point.DIAMETER/2,yPos-Point.DIAMETER/2,Po int.DIAMETER,Point.DIAMETER);}}}//鼠标按键在组建上按下时调用public void mousePressed(MouseEvent e){ //游戏已经结束,不能下if(gameOver)return;String colorName = isBlack ?"黑棋":"白棋";xIndex = (e.getX() - MARGIN + GRID_SPAN/2)/GRID_SPAN;//将鼠标单击的坐标位置转换成网格索引yIndex = (e.getY() - MARGIN + GRID_SPAN/2)/GRID_SPAN;//落在棋盘外,不能下if(xIndex <0 || xIndex > ROWS || yIndex < 0 || yIndex > COLS)return;//x、y位置都已经有棋子存在,不能下if(findChess(xIndex , yIndex))return;Point ch = new Point(xIndex,yIndex,isBlack ? Color.black:Color.white);chessList[chessCount++] = ch;repaint();//通知系统重新绘制if(isWin()){//给出胜利信息,不能再继续下棋String msg = String.format("恭喜,%s赢了!", colorName);JOptionPane.showMessageDialog(this, msg);gameOver = true;}isBlack = !isBlack;}//覆盖MouseListener的方法public void mouseClicked(MouseEvent e){ }//鼠标按键在组件上单击(按下并释放)时调用public void mouseEntered(MouseEvent e){ }//鼠标进入到组件上时调用public void mouseExited(MouseEvent e){ }//鼠标离开组件时调用public void mouseReleased(MouseEvent e){ }//鼠标离开组件时调用//在棋子数组中查找是否有索引为x、y的棋子存在private boolean findChess(int x, int y){ for(Point c : chessList){if(c !=null && c.getX() == x && c.getY() == y)return true;}return false;}//判定哪方赢private boolean isWin(){int continueCount =1;//连续棋子的个数//横向向西寻找for(int x = xIndex-1; x>=0;x--){Color c = isBlack ? Color.black : Color.white;if(getChess(x,yIndex,c) !=null){continueCount++;}elsebreak;}//横向向东寻找for(int x =xIndex+1;x<=ROWS;x++){ Color c = isBlack ? Color.black : Color.white;if(getChess(x,yIndex,c) !=null){continueCount++;}elsebreak;}//判定记录数大于等于五,即表示此方取胜if(continueCount>=5){return true;}elsecontinueCount =1;//继续另一种情况的搜索:纵向//纵向向上寻找for(int y = yIndex - 1; y >= 0; y--){ Color c =isBlack ? Color.black : Color.white;if(getChess(xIndex,y,c) !=null){continueCount++;}elsebreak;}//纵向向下寻找for(int y = yIndex + 1; y<=ROWS; y++){ Color c = isBlack ? Color.black : Color.white;if(getChess(xIndex,y,c)!=null){continueCount++;}elsebreak;}if(continueCount>=5){return true;}elsecontinueCount =1;//继续另一种情况的搜索:斜向//东北寻找for(int x = xIndex + 1,y=yIndex-1; y>=0 && x<=COLS; x++,y--){Color c = isBlack ? Color.black : Color.white;if(getChess(x,y,c)!=null){continueCount++;}elsebreak;}//西南寻找for(int x = xIndex - 1,y=yIndex+1; y<=ROWS && x>=0; x--,y++){Color c = isBlack ? Color.black : Color.white;if(getChess(x,y,c)!=null){continueCount++;}elsebreak;}if(continueCount >=5){return true;}elsecontinueCount = 1;//继续另一种情况的搜索:斜向//西北寻找for(int x = xIndex - 1,y = yIndex-1; y>=0 && x>=0; x--,y--){Color c = isBlack ? Color.black : Color.white;if(getChess(x,y,c)!=null){continueCount++;}elsebreak;}//西南寻找for(int x = xIndex + 1,y=yIndex+1; y<=ROWS && x<=COLS; x++,y++){Color c = isBlack ? Color.black : Color.white;if(getChess(x,y,c)!=null){continueCount++;}elsebreak;}if(continueCount >=5){return true;}elsecontinueCount = 1;return false;}private Point getChess(int xIndex, intyIndex, Color color){for(Point c: chessList){if(c !=null && c.getX() == xIndex && c.getY() == yIndex && c.getColor() == color)return c;}return null;}public void restartGame(){//清除棋子for(int i=0; i< chessList.length; i++) chessList[i]=null;//恢复游戏相关的变量值isBlack = true;gameOver = false;//游戏是否结束chessCount = 0;//当前棋盘的棋子个数//System.out.println(this.toString());//repaint();}//悔棋public void goback(){if (chessCount == 0)return;chessList[chessCount-1]=null;chessCount--;if(chessCount >0){xIndex = chessList[chessCount -1].getX();yIndex = chessList[chessCount -1].getY();}isBlack = !isBlack;//repaint();}//Dimension:矩形public Dimension getPreferredSize(){ return new Dimension (MARGIN*2 + GRID_SPAN*COLS,MARGIN*2 + GRID_SPAN*ROWS);}}import java.awt.BorderLayout;import java.awt.Color;import java.awt.FlowLayout;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import javax.swing.JButton;import javax.swing.JFrame;import javax.swing.JMenu;import javax.swing.JMenuBar;import javax.swing.JMenuItem;import javax.swing.JPanel;public class StartChessJFrame extends JFrame {private ChessBoard chessBoard;//对战面板private JPanel toolbar;//工具条面板private JButton startButton;private JButton backButton;private JButton exitButton;//“重新开始”按钮,“悔棋”按钮,“退出”按钮private JMenuBar menuBar;//菜单栏private JMenu sysMenu;//系统菜单private JMenuItem startMenuItem;private JMenuItem exitMenuIatem;private JMenuItem backMenuItem;//“重新开始”,“退出”和“悔棋”菜单项public StartChessJFrame(){setTitle("单机版五子棋");//设置标题chessBoard =new ChessBoard();//初始化面板对象//创建和添加菜单menuBar = new JMenuBar();//初始化菜单栏sysMenu = new JMenu("系统");//初始化菜单startMenuItem = new JMenuItem("重新开始");exitMenuIatem = new JMenuItem("退出");backMenuItem = new JMenuItem("悔棋");//初始化菜单项sysMenu.add(startMenuItem);//将三个菜单项添加到菜单上sysMenu.add(backMenuItem);sysMenu.add(exitMenuIatem);MyItemListener lis = new MyItemListener();//初始化按钮事件监听器内部类this.startMenuItem.addActionListener(li s);//将三个菜单项注册到事件监听器上backMenuItem.addActionListener(lis);exitMenuIatem.addActionListener(lis);menuBar.add(sysMenu);//将“系统”菜单添加到菜单栏上setJMenuBar(menuBar);//将menuBar设置为菜单栏toolbar =new JPanel();//工具面板实例化startButton = new JButton("重新开始");//三个按钮初始化backButton = new JButton("悔棋");exitButton = new JButton("退出");toolbar.setLayout(newFlowLayout(FlowLayout.LEFT));//将工具面板按钮用FlowLayout布局toolbar.add(startButton);//将三个按钮添加到工具面板上toolbar.add(backButton);toolbar.add(exitButton);startButton.addActionListener(lis);//将三个按钮注册监听事件backButton.addActionListener(lis);exitButton.addActionListener(lis);add(toolbar,BorderLayout.SOUTH);//将工具面板布局到界面“南”方也就是下面add(chessBoard);//将面板对象添加到窗体上setDefaultCloseOperation(JFrame.EXIT_ON _CLOSE);//设置界面关闭事件//setSize(600,650);pack();//自适应大小}//事件监听器内部类private class MyItemListener implements ActionListener{public void actionPerformed(ActionEvent e){Object obj = e.getSource();//取得事件源if(obj == StartChessJFrame.this.startMenuItem || obj ==startButton){//重新开始//JFiveFrame.this //内部类引用外部类System.out.println("重新开始...");chessBoard.restartGame();repaint();}else if (obj == exitMenuIatem || obj == exitButton){System.exit(0);//结束应用程序}else if (obj == backMenuItem || obj == backButton){//悔棋System.out.println("悔棋...");chessBoard.goback();repaint();}}}public static void main(String[] args){ StartChessJFrame f = newStartChessJFrame();//创建主框架f.setVisible(true);//显示主框架}}。
Python扑克牌21点游戏实例代码废话还是说太多了直接上代码import randomimport sys# 牌⾯列表card_code = ['A', '2', '3', '4', '5', '6', '7', '8', '9', '10', 'J', 'Q', 'K']# 花⾊列表card_symbol = ['♦', '♣', '♥', '♠']# 游戏初始化def init(player_count):# 根据玩家数来⽣成玩家记牌器player_group = [[] for _ in range(player_count)]# 根据玩家数来⽣成玩家是否要牌player_isWant = [True for _ in range(player_count)]# ⽣成元素1~52的列表 (去掉⼤⼩⿁的扑克牌[52张])poker = list(range(1, 53))# ⽤random的shuffle函数对列表打乱顺序 (洗牌)random.shuffle(poker)# 返回玩家组玩家是否要牌乱序52张扑克return player_group, player_isWant, poker# 打印玩家点数def print_player_point(player_group):# 存放玩家点数player_point = []# 遍历每⼀位玩家for index in range(len(player_group)):# 打印每位玩家的牌和点数print("-------玩家"+str(index+1)+"------")# 初始化玩家点数如果含有牌A 因为A可视为1点或11点则有两种点数current_player = [0, 0]# 遍历每位玩家的⼿牌for card in player_group[index]:"""核⼼代码由于牌⾯的数字是从1到52 所以牌⾯要先减1再求余才是牌⾯列表真正的下标若玩家抽到牌为15 即牌⾯为15 - 13 = 2 且按花⾊顺序为♣即2♣牌⾯ 15 - 1 = 14 再 14 % 13 = 1 这个就是对应牌⾯列表的第⼆位元素即2花⾊ 15 - 1 = 14 再 14 / 13 = 1 对应花⾊列表第⼆位元素即♣"""# 获取牌⾯和花⾊下标code_index = int((card - 1) % 13)symbol_index = int((card - 1) / 13)# 打印玩家牌信息print(card_code[code_index] + card_symbol[symbol_index], end="\t")# 如果牌⾯含有A 则添加不同点数1和11if (code_index + 1) == 1:current_player[0] += 1current_player[1] += 11# 如果牌⾯不含A 则添加相同点数else:current_player[0] += code_index + 1current_player[1] += code_index + 1# 如果两个点数⼀致则打印⼀个点数if current_player[0] == current_player[1]:print("点数为"+str(current_player[0])+"点")# 否则打印两个点数else:print("点数为"+str(current_player[0])+"点或"+str(current_player[1]))# 添加当前玩家点数player_point.append(current_player)# 返回所有玩家点数return player_point# 玩游戏def play_game():# 打印游戏规则print("-------21点游戏------")print("---A可看做1点或11点---")# 死循环⼀直进⾏游戏while True:# 初始化玩家数为0player_count = 0# 当玩家数⼩于等于1或⼤于5时继续询问while player_count <= 1 or player_count > 5:# 询问玩家数print("有多少位玩家?(2~5位)", end="")# 获取控制台输⼊的数字⽆验证输⼊若输⼊⾮数字程序直接报错player_count = int(input())# 初始化游戏返回玩家组玩家是否要牌乱序52张扑克player_group, player_isWant, poker = init(player_count)# 开始发牌先为每位玩家发两张牌循环玩家数for index in range(player_count):for i in range(2):# pop() 函数⽤于移除列表中的⼀个元素(默认最后⼀个元素)并且返回该元素的值。
#include <stdio.h>#include <windows.h>#pragma comment ( lib, "Winmm.lib")// 0,1,2,3分别代表+,-,*,/float OperVisual(float num1,float num2,int oper);//双目运算int Show(float num1,float num2,float num3,float num4,int i);//交换率运算并显示void main(){int i1,i2,i3,i4,i=0;unsigned int s1,s2;float num[4];//分别代表输入的4个数puts("Please enter the number 4:");scanf("%f%f%f%f",&num[0],&num[1],&num[2],&num[3]);s1=timeGetTime();for(i1=0;i1<4;i1++){for(i2=0;i2<4;i2++){for(i3=0;i3<4;i3++){for(i4=0;i4<4;i4++){if(i1!=i2&&i1!=i3&&i1!=i4&&i2!=i3&&i2!=i4&&i3!=i4)i=Show(num[i1],num[i2],num[i3],num[i4],i);}}}}if(!i) printf("No answer !");s2=timeGetTime();printf("\ntime consuming:%dms\n",s2-s1);getchar();getchar();}int Show(float num1,float num2,float num3,float num4,int i){int oper1,oper2,oper3;//分别代表3个操作符char OperShow[4]={'+','-','*','/'};//0,1,2,3float end1,end2,end3;for(oper1=0;oper1<4;oper1++){//第一个运算符end1=OperVisual(num1,num2,oper1);//将第一个数进行4次运算for(oper2=0;oper2<4;oper2++){//第二个运算符end2=OperVisual(end1,num3,oper2);//将前两个数的结果和第三个数进行4次运算for (oper3=0;oper3<4;oper3++){//第三个运算符end3=OperVisual(end2,num4,oper3);//将前三个数的结果和第三个数进行4次运算if(end3==24){if(oper1<=1&&oper2>=2)//如果第一个运算符为+或-第二个运算符为*或/printf("(%.f%c%.f)%c%.f%c%.f=24\n",num1,OperShow[oper1],num2,OperShow[oper2],nu m3,OperShow[oper3],num4),i++;else if(oper1<=1&&oper2<=1&&oper3>=2)printf("(%.f%c%.f%c%.f)%c%.f=24\n",num1,OperShow[oper1],num2,OperShow[oper2],nu m3,OperShow[oper3],num4),i++;else if(oper1>=2&&oper2<=1&&oper3>=2)printf("(%.f%c%.f%c%.f)%c%.f=24\n",num1,OperShow[oper1],num2,OperShow[oper2],nu m3,OperShow[oper3],num4),i++;elseprintf("%.f%c%.f%c%.f%c%.f=24\n",num1,OperShow[oper1],num2,OperShow[oper2],num3,Op erShow[oper3],num4),i++;}}}}return i;}float OperVisual(float num1,float num2,int oper){float result;switch(oper){case 0:result=num1+num2;break;case 1:result=num1-num2;break;case 2:result=num1*num2;break;case 3:result=num1/num2;break;}return result;}。
#include "mj.h"#include "stdlib.h"#include "time.h"#include "iostream.h"//辅助函数编写CPlayMj::CPlayMj(){pPaiOwn=new Pai[13];pPaiNew=new Pai;pShowPai=new ShowPai[13];pShowNewPai=new ShowPai;iCiNum=0;iPongNum=0;iGangNum=0;iPairNum=0;iMark=0;};CPlayMj::~CPlayMj(){delete []pPaiOwn;delete pPaiNew;delete []pShowPai;delete pShowNewPai;};Pai * CPlayMj:aiInPaiOwn(Pai *pPaiRest,int iPaiNum){for(int i=0;i<13;i++){if(pPaiRest.iNum==1)//对未被吃,碰,杠{if(pPaiRest.iPaiNum==iPaiNum)return pPaiRest+i;}}return NULL;}bool CPlayMj::NumInNum(int a,int b){if(a>26 || b>26)return 0;if(a>=0 && a<=8 && b>=0 && b<=8)return 1;if(a>=9 && a<=17 && b>=9 && b<=17)return 1;if(a>=18 && a<=26 && b>=18 && b<=26)return 1;return 0;}bool CPlayMj::IsPair(Pai* pPaiRest){for(int i=0;i<13;i++){if(pPaiRest.iPaiNum==pPaiNew->iPaiNum && pPaiRest.iNum==1)return 1;}return 0;}void CPlayMj:air(Pai* pPaiRest){for(int i=0;i<13;i++){if(pPaiRest.iPaiNum==pPaiNew->iPaiNum && pPaiRest.iNum==1){pPaiRest.iNum=0;pPaiNew->iNum=0;}}}Pai* CPlayMj::GetPaiOwn(){return pPaiOwn;}Pai* CPlayMj::GetNew(){return pPaiNew;}bool CPlayMj::GetMark(){return iMark;}void CPlayMj::SetMark(bool i){iMark=i;}void CPlayMj::MyShow(Pai *pTemp){int iTemp;ShowPai pShowPai[14];for(int i=0;i<14;i++){iTemp=pTemp.iPaiNum;switch(iTemp/9){case 0:pShowPai.Hua=WANG;//判断是那个牌花:万,条,铜pShowPai.str="万";pShowPai.iPaiNum=iTemp+1;//从1到9,下标转换为牌号break;case 1:pShowPai.Hua=TONG;pShowPai.str="铜";pShowPai.iPaiNum=iTemp-9+1;break;case 2:pShowPai.Hua=TIAO;pShowPai.str="条";pShowPai.iPaiNum=iTemp-18+1;break;default:pShowPai.Hua=ZI;switch(iTemp){case 27:pShowPai.str="东";break;case 28:pShowPai.str="南";break;case 29:pShowPai.str="西";break;case 30:pShowPai.str="北";break;case 31:pShowPai.str="中";break;case 32:pShowPai.str="发";break;case 33:pShowPai.str="白";break;default:;};pShowPai.iPaiNum=iTemp;//字的只有7种,东南西北,中发白};pShowPai.iNum=pTemp.iNum;if(pShowPai.iPaiNum>26)cout<<i+1<<" "<<pShowPai.str<<" "<<pShowPai.iNum<<endl;elsecout<<i+1<<""<<pShowPai.iPaiNum<<pShowPai.str<<""<<pShowPai.iNum<<endl;}}//主函数编写bool CPlayMj::IsHu(Pai *pOwn){return 0;}void CPlayMj::Hu(Pai *pOwn){// char a;int i;int j=0;int iTemp;int iTag=0;//if(iPairNum+iGangNum+iPongNum+iCiNum>4){if(iPairNum==7){cout<<"七对子";iMark=1;}if((iPongNum+iGangNum)==4 && (iPairNum==1)){cout<<"碰碰胡";iMark=1;}if((iCiNum>=1) && ((iPongNum+iGangNum+iCiNum)==4) && (iPairNum==1)){cout<<"平胡";iMark=1;}}if(iMark==1)return;SortPai(14,pOwn);// MyShow(pOwn);// cin>>a;while(pOwn[j].iNum!=1 && j<14)j++;if(j==14 || iMark==1)return;//假如情况是吃的if( iMark==0&&((pOwn[j].iPaiNum<=24 && pOwn[j].iPaiNum>=18)||(pOwn[j].iPaiNum<=15 && pOwn[j].iPaiNum>=9)||(pOwn[j].iPaiNum<=6 && pOwn[j].iPaiNum>=0) ) ){if(pOwn[j].iPaiNum+1==pOwn[j+1].iPaiNum){for(i=j+2;i<14;i++){if(pOwn.iPaiNum==pOwn[j].iPaiNum+2)iTag=i;}/////////////////等换牌if(iTag!=0){//可以吃,执行吃的操作pOwn[j].iNum=0;pOwn[j+1].iNum=0;iTemp=pOwn[j+2].iPaiNum;pOwn[j+2].iPaiNum=pOwn[iTag].iPaiNum;pOwn[iTag].iPaiNum=iTemp;pOwn[j+2].iNum=0;iCiNum++;//吃的次数加一次Hu(pOwn);iTemp=pOwn[j+2].iPaiNum;pOwn[j+2].iPaiNum=pOwn[iTag].iPaiNum;pOwn[iTag].iPaiNum=iTemp;pOwn[j].iNum=1;pOwn[j+1].iNum=1;pOwn[j+2].iNum=1;iCiNum--;}}}//假如情况是可以碰if(iMark==0 && pOwn[j].iPaiNum==pOwn[j+1].iPaiNum){for(i=j+2;i<14;i++){if(pOwn.iPaiNum==pOwn[j].iPaiNum)iTag=i;}if(iTag!=0){//可以碰,执行碰操作pOwn[j].iNum=0;pOwn[j+1].iNum=0;iTemp=pOwn[j+2].iPaiNum;pOwn[j+2].iPaiNum=pOwn[iTag].iPaiNum;pOwn[iTag].iPaiNum=iTemp;pOwn[j+2].iNum=0;iPongNum++;//碰的次数加一次Hu(pOwn);iTemp=pOwn[j+2].iPaiNum;pOwn[j+2].iPaiNum=pOwn[iTag].iPaiNum;pOwn[iTag].iPaiNum=iTemp;pOwn[j].iNum=1;pOwn[j+1].iNum=1;pOwn[j+2].iNum=1;iPongNum--;//有可能碰胡不了,对而可以胡,如55 567,555 67。
五子棋游戏JAVA源代码本源代码实现的是一单机双人对战五子棋游戏本源代码由五个java源程序文件组成,Game.java、GameFrame.java、GamePanel.java、 ChessMan.java、Player.java源代码下载源代码:Game.javaimport javax.swing.*;public class Game {public static void main(String[] args) {GameFrame GFrame=new GameFrame();GFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);GFrame.setVisible(true);}}GameFrame.javaimport java.awt.*;import javax.swing.*;class GameFrame extends JFrame {private static final int Width=570;private static final int Height=470;GameFrame(){setTitle("五子棋游戏");CenteredFrame();setSize(Width,Height);GamePanel Gpanel=new GamePanel();add(Gpanel);}void CenteredFrame(){Toolkit kit=Toolkit.getDefaultToolkit(); Dimension screenSize=kit.getScreenSize();int screenHeight=screenSize.height;int screenWidth=screenSize.width;int Xposition=(screenWidth-Width)/2;int Yposition=(screenHeight-Height)/2;setLocation(Xposition,Yposition);}}GamePanel.javaimport java.awt.*;import java.awt.event.*;import javax.swing.*;class GamePanel extends JPanel {private Point cursor=new Point(40,60); //棋盘坐标private int[][] ChessState=new int[18][18];//棋盘状态private int i=0;//横坐标private int j=0;//纵坐标private final static int testnum=5;//五子棋的规定棋子数private Player Black=new Player(1,Color.BLACK,"黑方");//黑方棋子private Player White=new Player(2,Color.WHITE,"白方");//白方棋子private Player Cplayer=null;//当前用户的引用private JTextField textBlack=new JTextField("",5);//黑方文本提示框对象和文本长度设置private JTextField textWhite=new JTextField("",5);//白方文本提示框对象和文本长度设置private String Nothing="";private String textblack="请黑方下子";//黑方提示文本private String textwhite="请白方下子";//白方提示文本GamePanel(){setLayout(null);Initialization();setFocusable(true);JButton Rutton=new JButton("重新开局");Rutton.setBounds(20,14,100,26);RestartListener restart=new RestartListener();Rutton.addActionListener(restart);add(Rutton);textBlack.setHorizontalAlignment(JTextField.CENTER);textBlack.setBounds(150,14,110,26);textBlack.setEditable(false);add(textBlack);textWhite.setHorizontalAlignment(JTextField.CENTER);textWhite.setBounds(290,14,110,26);textWhite.setEditable(false);add(textWhite);JTextArea gInstruction=new JTextArea();gInstruction.setSelectedTextColor(newColor(238,238,238));String gSInstruction="Play1(黑方) Key \nup--------W \ndown----S\nleft--------A \nright------F \n\n"+"Play2(白方) Key \nup--------up \ndown----down \nleft--------left \nright------right \n\n"+"Exit game: \nPress Esc";gInstruction.setText(gSInstruction);gInstruction.setEditable(false);gInstruction.setBounds(440,60,100,340);add(gInstruction);ChessManPerformListener Perform=new ChessManPerformListener();addKeyListener(Perform);}// 设置第一个JTextField输出"请黑方下棋",坐标为(40,60)void Initialization(){for(int i=0,j;i<18;i++)for(j=0;j<18;j++){ChessState[i][j]=0;}cursor.setLocation(40,60);Cplayer=Black;textBlack.setText(textblack);textWhite.setText(Nothing);}//画棋盘和初始化棋局状态protected void paintComponent(Graphics g){super.paintComponent(g);Graphics2D g2=(Graphics2D) g;for(int i=60;i<=400;i+=20){g2.drawLine(40,i,380,i);}for(int j=40;j<=380;j+=20){g2.drawLine(j,60,j,400);}g2.drawString("_",cursor.x-6,cursor.y);g2.drawString("_",cursor.x,cursor.y);for(i=0;i<18;i++)for(j=0;j<18;j++){if(ChessState[i][j]!=0){if(ChessState[i][j]==1){g2.setPaint(Black.getplayerChessManColor());}if(ChessState[i][j]==2){g2.setPaint(White.getplayerChessManColor());}g2.fillOval(j*20+40-10, i*20+60-10,ChessMan.getChessManSize(), ChessMan.getChessManSize());}}}//判断棋盘的当前位置是否已有棋子boolean isChessState(){this.j=(cursor.x-40)/20;this.i=(cursor.y-60)/20;if(ChessState[this.i][this.j]!=0)return true;elsereturn false;}//记录落子后棋盘的当前位置的状态void RecordChessState(){this.j=(cursor.x-40)/20;this.i=(cursor.y-60)/20;ChessState[this.i][this.j]=Cplayer.getCurrentIdentify(); }//判断当前玩家落子后是否赢了void JudgeWin(){for(int i=0;i<4;i++)if(JudgeWinLine(i)){//提示当前玩家已经获得胜利try{String Ginformation="GameInformation";String Message="恭喜玩家"+Cplayer.getsIdentify()+"获胜!"+"\n"+"继续游戏还是退出游戏?";String[] options = {"继续","退出"};intselection=JOptionPane.showOptionDialog(null,Message,Ginform ation,JOptionPane.YES_NO_OPTION,RMATION_MESSAGE , null,options,options[0]);//throws HeadlessExceptionif(selection==JOptionPane.OK_OPTION){Initialization();repaint();return;}if(selection==JOptionPane.NO_OPTION){ System.exit(0);//退出程序}}catch(HeadlessException e){e.printStackTrace();}}//如果当前方没有赢棋则双方轮换ChangeCurrentPlayer();}//在当前方向上是否有连续的五只棋子boolean JudgeWinLine(int direction){int i,j,di,dj,count;i=j=di=dj=count=0;switch(direction){case 0:j=this.j-(testnum-1);i=this.i;dj=1;di=0;break;case 1:j=this.j;i=this.i-(testnum-1);dj=0;di=1;break;case 2:j=this.j-(testnum-1);i=this.i+(testnum-1);dj=1;di=-1;break;case 3:j=this.j-(testnum-1);i=this.i-(testnum-1);dj=1;di=1;break;}for(int k=0;k<testnum*2+1;k++){if(j>=0&&j<18&&i>=0&&i<18){if(ChessState[i][j]==Cplayer.getCurrentIdentify()){count++;if(count>=testnum)return true;}elsecount=0;}j+=dj;i+=di;}return false;}//更换当前玩家void ChangeCurrentPlayer(){if(Cplayer==Black){Cplayer=White;textBlack.setText(Nothing);textWhite.setText(textwhite);}else{Cplayer=Black;textBlack.setText(textblack);textWhite.setText(Nothing);}}//重新开局监听器private class RestartListener implements ActionListener{public void actionPerformed(ActionEvent arg0) {Initialization();repaint();requestFocus();}}//棋盘、棋局状态监听器private class ChessManPerformListener implements KeyListener{//玩家2的按键public void keyPressed(KeyEvent event) {int keyCode=event.getKeyCode();if(keyCode==KeyEvent.VK_ESCAPE)System.exit(0);if(Cplayer.getCurrentIdentify()==2){//判别当前玩家if(keyCode==KeyEvent.VK_LEFT){if(cursor.x>40)cursor.x-=20;}else if(keyCode==KeyEvent.VK_RIGHT){if(cursor.x<380)cursor.x+=20;}else if(keyCode==KeyEvent.VK_UP){if(cursor.y>60)cursor.y-=20;}else if(keyCode==KeyEvent.VK_DOWN){if(cursor.y<400)cursor.y+=20;}else if(keyCode==KeyEvent.VK_ENTER){if(!isChessState()){Cplayer.PerformChessMan();RecordChessState();repaint();JudgeWin();//判定当前落子后是否赢棋}}repaint();}}public void keyReleased(KeyEvent event) {}//玩家1的按键public void keyTyped(KeyEvent event) {char keyChar=event.getKeyChar();if(Cplayer.getCurrentIdentify()==1){//判别当前玩家if(keyChar=='a'){if(cursor.x>40)//对移动光标超界现象做判别cursor.x-=20;}else if(keyChar=='d'){if(cursor.x<380)cursor.x+=20;}else if(keyChar=='w'){if(cursor.y>60)cursor.y-=20;}else if(keyChar=='s'){if(cursor.y<400)cursor.y+=20;}else if(keyChar==' '){if(!isChessState()){ //落子前先判断当前位置上是否已有棋子Cplayer.PerformChessMan();//落子RecordChessState();//记录当前落子后棋盘状态repaint();JudgeWin();//判定当前落子后是否赢棋}}}repaint();}}}ChessMan.javaimport java.awt.Color;class ChessMan {private static final int ChessManSize=20; private Color ChessManColor;ChessMan(Color c){ChessManColor=c;}static int getChessManSize(){return ChessManSize;}Color getChessManColor(){return ChessManColor;}}Player.javaimport java.awt.Color;class Player {private int identify;private ChessMan pChessMan;private String PlayerStringIdentify;Player(int identify,Color c,String sIdentify){this.identify=identify;pChessMan=new ChessMan(c);this.PlayerStringIdentify=sIdentify;}int getCurrentIdentify(){return identify;}String getsIdentify(){return PlayerStringIdentify;}void PerformChessMan(){}Color getplayerChessManColor(){return pChessMan.getChessManColor(); }}。
本人学会的一个五子棋网络版和单机版游戏,有老师指导完成,详细的解释和代码都在下面,希望可以帮助到大家!1.客户端连接新建个gobangClient类package gobang;public class gobangClient {public static void main(String[] args) throws Exception { new ChessBoard("localhost",8866);}}2.服务端连接新建个gobangServer类package gobang;public class gobangServer {public static void main(String[] args) throws Exception { new ChessBoard(8866);}}3.源代码,有详细解释package gobang;import java.awt.BorderLayout;import java.awt.Container;import java.awt.Dimension;import java.awt.FlowLayout;import java.awt.Toolkit;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.awt.event.MouseAdapter;import java.awt.event.MouseEvent;import java.awt.image.BufferedImage;import java.io.BufferedReader;import java.io.IOException;import java.io.InputStream;import java.io.InputStreamReader;import java.io.PrintWriter;import .ServerSocket;import .Socket;import java.util.ArrayList;import java.awt.Graphics;import javax.swing.JButton;import javax.swing.JFrame;import javax.swing.JOptionPane;import javax.swing.JPanel;public class ChessBoard extends JFrame{private boolean myPlay=false;//(默认是false)是否轮到我落子private JButton button1 =new JButton("开始");private JButton button2 =new JButton("悔棋");private JPanel p1 = new JPanel();private PicPane pp = null;private int side=1;//1表示黑private int n=0;//记录点击开始的次数public static final int SIZE=15;public static int[][]board=new int[SIZE][SIZE];//用来保存棋盘上棋子状态//1为黑,2为白,0为无public static final int BLACK=1;public static final int WHITE=-1;private NetService service;private static ArrayList<String> list =new ArrayList<String>(); //保存了下棋的步骤private boolean end=true;//true表示游戏已经结束private int currentColor=1;//服务端的构造器public ChessBoard(int port) throws Exception{//调用本类的无参构造树this();//构造器调用规则:1,只能调用本类或父类的构造器2. 调用构造器的代码写在新构造器的第一行3.构造器的调用只能使用this(本类)或者(父类) //将按钮设置能无效的button1.setEnabled(false);button2.setEnabled(false);//3.创建ServerSocket对象ServerSocket ss=new ServerSocket(port);//4.等待连接Socket s=ss.accept();//5.连接成功后创建一个线程来处理请求service=new NetService(s);service.start();//6.将按钮设置成有效的button1.setEnabled(true);button2.setEnabled(true);}//客户端的构造器public ChessBoard(String ip,int port) throws Exception{ //调用本类无参构造器this();//连接服务器Socket s=new Socket(ip,port);//初始化服务类service=new NetService(s);service.start();}public ChessBoard() throws IOException{Container c = this.getContentPane();c.setLayout(new BorderLayout());pp = new PicPane();BorderLayout bl = new BorderLayout();c.setLayout(bl);FlowLayout fl = new FlowLayout();p1.setLayout(fl);p1.add(button1);p1.add(button2);c.add(p1,BorderLayout.NORTH);c.add(pp,BorderLayout.CENTER);setSize(pp.getWidth()+6,pp.getHeight()+65);setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);setResizable(false);setVisible(true);button1.addActionListener(new SomeListener());button2.addActionListener(new button2Listener());}class SomeListener implements ActionListener{public void actionPerformed(ActionEvent e){// button2.setVisible(true);// if(n==0)// {// JOptionPane.showMessageDialog(// ChessBoard.this, "开始游戏啦!",// "提示",RMATION_MESSAGE);// }// else// {// JOptionPane.showMessageDialog(// ChessBoard.this, "确定要重新开始?",// "提示",RMATION_MESSAGE); // }// board=new int[15][15];// //调用重绘// pp.repaint();// end=false;// n++;start();}}private void start(){netStart();localStart();myPlay=true;//谁先点了开始按钮,谁先开始}private void localStart(){//重新初始化棋盘board=new int[SIZE][SIZE];//重新设置当前颜色currentColor=BLACK;//清空下棋步骤list=new ArrayList<String>();//重绘棋盘pp.repaint();//重新设置使下期没有结束end=false;}private void netStart(){service.send("start");}class button2Listener implements ActionListener{public void actionPerformed(ActionEvent e){back();// if(end==true)// {// JOptionPane.showMessageDialog(// ChessBoard.this, "人家都赢了你不能悔棋啦!", // "提示",RMATION_MESSAGE); // return;// }// int length = list.size();// if(list.size()<0)// {return;}// String str1 = list.remove(list.size() - 1);// String[] str3s = str1.split(",");// String str31 = str3s[0];// String str32 = str3s[1];// int row = Integer.parseInt(str31);// int col = Integer.parseInt(str32);// board[row][col]=0;// pp.repaint();// side = (side==1?2:1);//同下// if(side==1)// side=2;// else// side=1;}}public void back(){netBack();localBack();myPlay=!myPlay;//经典啊boolean的好处啊,悔棋了还是我下棋}private void localBack(){//如果结束不能悔棋if(end){return;}//if(list.isEmpty()){return;}//String str1 = list.remove(list.size() - 1);String[] str3s = str1.split(",");String str31 = str3s[0];String str32 = str3s[1];int row = Integer.parseInt(str31);int col = Integer.parseInt(str32);board[row][col]=0;currentColor=-currentColor;//pp.repaint();//}private void netBack(){if(end){//节省时间return;}service.send("back");}public static void toCenter(JFrame frame){int width = frame.getWidth();int height = frame.getHeight();Toolkit tookie = Toolkit.getDefaultToolkit();Dimension dim = tookie.getScreenSize();int screenWidth = dim.width;int screenHeight = dim.height;frame.setLocation((screenWidth - width)/2,(screenHeight-height)/2);}class PicPane extends JPanel{private int width;private int height;private BufferedImage bImg;//棋盘private BufferedImage chessImg;//黑子private BufferedImage wImg;//白子public PicPane() throws IOException{InputStreamips =PicPane.class.getResourceAsStream("images/chessboard.jpg");bImg = javax.imageio.ImageIO.read(ips);ips =PicPane.class.getResourceAsStream("images/b.gif");chessImg = javax.imageio.ImageIO.read(ips);ips =PicPane.class.getResourceAsStream("images/w.gif");wImg = javax.imageio.ImageIO.read(ips);width = bImg.getWidth();height = bImg.getHeight();addMouseListener(new boardListener());}@Overridepublic void paint(Graphics g){super.paint(g);g.drawImage(bImg,0,0,null);//加上画棋子的代码//依据board数组中的数据for(int i=0;i<board.length;i++){for(int j=0;j<board[i].length;j++){if(board[i][j]==1){g.drawImage(chessImg,j*35+3,i*35+3,null);}else if(board[i][j]==-1){g.drawImage(wImg,j*35+3,i*35+3,null);}}}}public int getHeight(){return height;}public int getWidth(){return width;}class boardListener extends MouseAdapter//只对感兴趣的方法实现,不用借口全部实现{@Overridepublic void mouseClicked(MouseEvent ae){int x=ae.getX();int y=ae.getY();int row=(y-4)/35;int col=(x-4)/35;play(row,col);// //判断游戏的状态,游戏是否结束的逻辑// if(end)// {// return;// }// //获得点击的坐标// int x=e.getX();// int y=e.getY();// int row=y/35;// int col=x/35;// if(row>=15||col>=15)// {// return;// }// if(board[row][col]==0)// switch(side)// {// case 1:// {//e.getComponent().getGraphics().drawImage(chessImg,col*35+3,row *35+3,null);// board[row][col]=1;//记录棋子// side=2;//改为白方// list.add(row+","+col);// break;// }// case 2:// {//e.getComponent().getGraphics().drawImage(wImg,col*35+3,row*35+ 3,null);// board[row][col]=2;// side=1;//改为黑方// list.add(row+","+col);// break;//改为黑方// }// }// //判断输赢// if(isWin(row,col))// {// //如果赢了:// end=true;// //提示用户,谁赢了// JOptionPane.showMessageDialog(ChessBoard.this,// (side==1?"白方胜":"黑方胜"),"提示",RMATION_MESSAGE);// }//}}}private void play(int row,int col){if(!myPlay){//如果不是我落子,直接返回,什么也不做return;}netPlay(row,col);//使另一方的棋盘上落子localPlay(row,col);//在本地的棋盘上落子myPlay=false;}private void netPlay(int row, int col){ if(end){//只打开服务器,会报错的问题return;}service.send(row+","+col);}private void localPlay(int row, int col){if(end){return;}if(row>=SIZE||col>=SIZE||row<0||col<0){return;}if(board[row][col]!=0){return;}//保存棋子board[row][col]=currentColor;//保存下棋步骤list.add(row+","+col);//重绘棋盘pp.repaint();if(isWin(row,col)){end=true;JOptionPane.showMessageDialog(ChessBoard.this,((currentColor==BLACK?"黑方":"白方")+"胜!"),"提示",RMATION_MESSAGE);}currentColor=-currentColor;}private boolean isWin(int currRow,int currCol){ // 需要比较四个方向的棋子(是否同色)int color=board[currRow][currCol];int[][]directions={{1,0},{1,1},{0,1},{-1,1}};//从四个方向比较for(int i=0;i<directions.length;i++){//计数器int num=1;//控制正反的for(int j=-1;j<2;j+=2){//比较次数for(int k=1;k<5;k++){//获得相邻的棋子的坐标int row=currRow+j*k*directions[i][0];int col=currCol+j*k*directions[i][1];//有可能行和列越界if(row<0||row>=15||col<0||row>=15){break;}if(board[row][col]==color){num++;if(num==5){return true;}}elsebreak;}}return false;}class NetService extends Thread{Socket s;BufferedReader in;PrintWriter out;public NetService(Socket s){try {this.s=s;in=new BufferedReader(new InputStreamReader(s.getInputStream()));out=new PrintWriter(s.getOutputStream());} catch (IOException e) {e.printStackTrace();}}public void send(String message){out.println(message);out.flush(); //刷新缓冲区}public void run(){try {while(true){String command=in.readLine();if(command.equals("start")){localStart();myPlay=false;}else if(command.equals("back")){localBack();myPlay=!myPlay;}else{String[]arr=command.split(",");int row=Integer.parseInt(arr[0]);int col=Integer.parseInt(arr[1]);localPlay(row,col);myPlay=true;}}} catch (IOException e) {e.printStackTrace();}}}public static void main(String[] args) throws IOException {ChessBoard chessboard = new ChessBoard();toCenter(chessboard);}}。
C语言教程:简易五子棋程序收集于网络/* 纯用字符和数组编的五子棋,棋盘也是用字符画的。
、编了1上午了,主要是算法跟按键比较烦,发现有bug-- 按键速度过快会产生延时显示,可能是算法不好。
操作:玩家1:a,s,w,d(方向)空格(落子)玩家2:上、下、左、右回车(落子)ESC:退出编译测试环境:`*/#include <>#include <>#include <>#include <>/#define CRRU 0xbf /*右上角点197*/#define CRLU 0xda /*左上角点218*/#define CRLD 0xc0 /*左下角点192*/#define CRRD 0xd9 /*右下角点217*/<#define CRL 0xc3 /*左边195*/#define CRR 0xb4 /*右边190*/#define CRU 0xc2 /*上边194*/#define CRD 0xc1 /*下边193*/#define CR 0xc5 /*十字交叉点197*/-#define size 19char a[size][size];int i,j; int x=10;int y=3; return ;}void pressct(int m){switch(m){¥case 19200: //左if(i>0) {i--;x--;gotoxy(x,y);} break;case 20480: //下if(j<size-1){j++;y++;gotoxy(x,y);} break;case 18432: //上$if(j>0) {j--;y--;gotoxy(x,y);} break;case 19712: //右if(i<size-1){i++;x++;gotoxy(x,y);} break;case 7181: //回车if(a[i][j]!=CB&&a[i][j]!=CW){a[i][j]=CW;putch(CW);gotoxy(x,y);side=1;}break; {default: break;}return ;}>int judge(int pa) //判断是否胜利,胜利则返回1,否则返回0;// 其中i,j为当前的落子位;{int m;int sum=1;for(m=1;m<=i&&m<=j;m++) {if(a[i-m][j-m]!=pa) break;sum++;}for(m=1;m<(size-i)&&m<(size-j);m++) {if(a[i+m][j+m]!=pa) break;sum++;}if(sum>=5) return 1;else sum=1;for(m=1;m<=i;m++) {if(a[i-m][j]!=pa) break;sum++;}for(m=1;m<(size-j);m++) {if(a[i+m][j]!=pa) break;sum++;}if(sum>=5) return 1;else sum=1;for(m=1;m<=j;m++) {if(a[i][j-m]!=pa) break;sum++;}for(m=1;m<(size-j);m++) {if(a[i][j+m]!=pa) break;sum++;}if(sum>=5) return 1;else sum=1;for(m=1;m<=i&&m<(size-j);m++) {if(a[i-m][j+m]!=pa) break;sum++;}for(m=1;m<(size-i)&&m<=j;m++) {if(a[i+m][j-m]!=pa) break;sum++;}if(sum>=5) return 1;else return 0;本文章来自21视频教程网C语言教程:简易五子棋程序_C语言程序设计教程原文链接:。
#include<stdio.h>#define N 10void welcome();void initqipan();void showqi(int i);void save(int p);void panduan(int p);void heqi();void over();int zouqihang();int zouqilie();/******************结构体*****************/ struct zuobiao{int x[N*N];int y[N*N];}weizhi[N*N];/******************主函数*****************/ void main(){int p=0;welcome();initqipan();for(p=1;p<=N*N;p++){weizhi[p].x[p]=zouqihang();weizhi[p].y[p]=zouqilie();save(p);showqi(p);panduan(p);}if(p==N*N)heqi();over();}/******************建立棋盘*****************/ void initqipan(){int i,j;for(i=0;i<N;i++){printf("%d",i);printf(" ");}printf("\n");for(i=1;i<N;i++){for(j=0;j<N;j++){if(j==0)printf("%d",i);elseprintf("·");}printf("\n");}}/******************显示棋子*****************/void showqi(int p){int i,j,k,m;int a[N*N],b[N*N];FILE *fp;fp=fopen("wuzi_list","rb");for(i=1;i<=N*N;i++){fread(&weizhi[i],sizeof(struct zuobiao),1,fp);a[i]=weizhi[i].x[i];b[i]=weizhi[i].y[i];}for(m=1;m<p;m++){while(weizhi[p].x[p]==a[m]&&weizhi[p].y[p]==b[m]){printf("error!\n");weizhi[p].x[p]=zouqihang();weizhi[p].y[p]=zouqilie();m=1;}}for(i=0;i<N;i++){printf("%d",i);printf(" ");}printf("\n");for(i=1;i<N;i++){for(j=1;j<N;j++){if(j==1)printf("%d",i);for(k=1;k<=p;k++){if(i==weizhi[k].x[k]&&j==weizhi[k].y[k]){if(k%2==1){printf("○");break;}else if(k%2==0){printf("●");break;}}}if(k>p)printf("·");else continue;}printf("\n");}}/******************走棋行*****************/int zouqihang(){int x;printf("请输入要走棋子所在行数!\n");printf("x=");scanf("%d",&x);while(x>N-1||x<1){printf("error!\n");printf("请输入要走棋子所在行数!\n");printf("x=");scanf("%d",&x);}return x;}/******************走棋列*****************/int zouqilie(){int y;printf("请输入要走棋子所在列数!\n");printf("y=");scanf("%d",&y);while(y>N-1||y<1){printf("error!\n");printf("请输入要走棋子所在列数!\n");printf("y=");scanf("%d",&y);}return y;}/******************文件保存*****************/void save(int i){FILE *fp;fp=fopen("wuzi_list","wb");fwrite(&weizhi[i],sizeof(struct zuobiao),1,fp);}/****************判断输赢*******************/void panduan(int p){int i,j,k[8]={1,1,1,1,1,1,1,1,};int a[N*N],b[N*N];FILE *fp;fp=fopen("wuzi_list","rb");for(i=1;i<=p;i++){fread(&weizhi[i],sizeof(struct zuobiao),1,fp);a[i]=weizhi[i].x[i];b[i]=weizhi[i].y[i];}/*****************判断行******************/for(i=1;i<=p;i++){if(i%2==1){for(j=1;j<=p;j=j+2){if((a[i]==a[j])&&(b[i]==b[j]-1)){k[0]++;continue;}else if((a[i]==a[j])&&(b[i]==b[j]-2)){k[0]++;continue;else if((a[i]==a[j])&&(b[i]==b[j]-3)){k[0]++;continue;}else if((a[i]==a[j])&&(b[i]==b[j]-4)){k[0]++;continue;}else if(k[0]==5){printf("Player 1 wins!!!\n");}elsecontinue;}if(k[0]==5)break;k[0]=1;}else if(k[0]==5)break;else if(i%2==0){for(j=2;j<=p;j=j+2){if((a[i]==a[j])&&(b[i]==b[j]-1)){k[1]++;continue;}else if((a[i]==a[j])&&(b[i]==b[j]-2)){k[1]++;continue;}else if((a[i]==a[j])&&(b[i]==b[j]-3)){k[1]++;continue;}else if((a[i]==a[j])&&(b[i]==b[j]-4))k[1]++;continue;}else if(k[1]==5){printf("Player 2 wins!!!\n");}elsecontinue;}if(k[1]==5)break;k[1]=1;}}/**********************判断列************************/ for(i=1;i<=p;i++){if(k[0]==5||k[1]==5)break;else if(i%2==1){for(j=1;j<=p;j=j+2){if((a[i]==a[j]-1)&&(b[i]==b[j])){k[2]++;continue;}else if((a[i]==a[j]-2)&&(b[i]==b[j])){k[2]++;continue;}else if((a[i]==a[j]-3)&&(b[i]==b[j])){k[2]++;continue;}else if((a[i]==a[j]-4)&&(b[i]==b[j])){k[2]++;continue;else if(k[2]==5){printf("Player 1 wins!!!\n");}elsecontinue;}if(k[2]==5)break;k[2]=1;}else if(k[2]==5)break;else if(i%2==0){for(j=2;j<=p;j=j+2){if((a[i]==a[j]-1)&&(b[i]==b[j])){k[3]++;continue;}else if((a[i]==a[j]-2)&&(b[i]==b[j])){k[3]++;continue;}else if((a[i]==a[j]-3)&&(b[i]==b[j])){k[3]++;continue;}else if((a[i]==a[j]-4)&&(b[i]==b[j])){k[3]++;continue;}else if(k[3]==5){printf("Player 2 wins!!!\n");}elsecontinue;}if(k[3]==5)break;k[3]=1;}}/****************判断对角(左上-右下)******************/ for(i=1;i<=p;i++){if(k[0]==5||k[1]==5||k[2]==5||k[3]==5)break;else if(i%2==1){for(j=1;j<=p;j=j+2){if((a[i]==a[j]-1)&&(b[i]==b[j]-1)){k[4]++;continue;}else if((a[i]==a[j]-2)&&(b[i]==b[j]-2)){k[4]++;continue;}else if((a[i]==a[j]-3)&&(b[i]==b[j]-3)){k[4]++;continue;}else if((a[i]==a[j]-4)&&(b[i]==b[j]-4)){k[4]++;continue;}else if(k[4]==5){printf("Player 1 wins!!!\n");}elsecontinue;}if(k[4]==5)break;}else if(k[2]==5)break;else if(i%2==0){for(j=2;j<=p;j=j+2){if((a[i]==a[j]-1)&&(b[i]==b[j]-1)){k[5]++;continue;}else if((a[i]==a[j]-2)&&(b[i]==b[j]-2)){k[5]++;continue;}else if((a[i]==a[j]-3)&&(b[i]==b[j]-3)){k[5]++;continue;}else if((a[i]==a[j]-4)&&(b[i]==b[j]-4)){k[5]++;continue;}else if(k[5]==5){printf("Player 2 wins!!!\n");}elsecontinue;}if(k[5]==5)break;k[5]=1;}}/**********判断对角(左下-右上)************/for(i=1;i<=p;i++){if(k[0]==5||k[1]==5||k[2]==5||k[3]==5||k[4]==5||k[5]==5)else if(i%2==1){for(j=1;j<=p;j=j+2){if((a[i]==a[j]+1)&&(b[i]==b[j]-1)){k[6]++;continue;}else if((a[i]==a[j]+2)&&(b[i]==b[j]-2)){k[6]++;continue;}else if((a[i]==a[j]+3)&&(b[i]==b[j]-3)){k[6]++;continue;}else if((a[i]==a[j]+4)&&(b[i]==b[j]-4)){k[6]++;continue;}else if(k[6]==5){printf("Player 1 wins!!!\n");}elsecontinue;}if(k[6]==5)break;k[6]=1;}else if(k[6]==5)break;else if(i%2==0){for(j=2;j<=p;j=j+2){if((a[i]==a[j]+1)&&(b[i]==b[j]-1)){k[7]++;continue;}else if((a[i]==a[j]+2)&&(b[i]==b[j]-2)){k[7]++;continue;}else if((a[i]==a[j]+3)&&(b[i]==b[j]-3)){k[7]++;continue;}else if((a[i]==a[j]+4)&&(b[i]==b[j]-4)){k[7]++;continue;}else if(k[7]==5){printf("Player 2 wins!!!\n");}elsecontinue;}if(k[7]==5)break;k[7]=1;}}}/****************和棋*******************/void heqi(){printf("************************************\n");printf(" Tie!!!\n");printf("************************************\n");}/****************游戏结束*******************/void over(){printf("************************************\n");printf(" game over!!!\n");printf("************************************\n");}/****************游戏开始*******************/void welcome(){printf("************************************\n");printf(" Welcome!!!\n");printf("************************************\n"); }。
(精选)关于棋牌游戏源代码开放棋牌游戏源代码开放是指游戏开发者将游戏的源代码开放给公众,使得任何人都可以查看、修改和使用这些代码。
这种开放源代码的做法在近年来越来越受到游戏开发者和玩家的青睐,因为它为游戏开发和创新提供了更多的可能性。
在本文中,我们将探讨棋牌游戏源代码开放的优势和劣势,以及对游戏行业的影响。
首先,让我们来看看棋牌游戏源代码开放的优势。
首先,开放源代码可以促进游戏开发的创新。
通过开放源代码,开发者可以共享他们的代码和技术,从而为其他开发者提供了更多的灵感和资源。
这种开放的环境可以促进游戏行业的不断发展和进步。
其次,开放源代码可以增加游戏的可玩性和持续性。
玩家可以通过修改游戏源代码来创建新的游戏模式、角色和地图,从而为游戏增加了更多的乐趣和挑战性。
此外,开放源代码还可以增加游戏的可信度和安全性。
由于开放源代码可以被公众审查,因此可以更容易地发现和修复游戏中的漏洞和问题,从而提高了游戏的质量和可靠性。
然而,棋牌游戏源代码开放也存在一些劣势。
首先,开放源代码可能会导致游戏的盗版和侵权问题。
一旦游戏的源代码被公开,就很难控制它的使用和传播。
这可能会导致游戏的盗版和侵权现象,从而损害了开发者的利益。
其次,开放源代码可能会增加游戏的安全风险。
由于游戏的源代码可以被公众访问,黑客和恶意用户可能会利用这些代码来攻击游戏的服务器和玩家的账户,从而造成严重的安全问题。
因此,开放源代码需要开发者采取更多的安全措施来保护游戏和玩家的利益。
尽管棋牌游戏源代码开放存在一些劣势,但它仍然对游戏行业产生了积极的影响。
首先,开放源代码可以促进游戏开发者之间的合作和交流。
通过共享源代码和技术,开发者可以相互学习和帮助,从而提高了整个行业的水平和竞争力。
其次,开放源代码可以增加游戏玩家的参与度和忠诚度。
玩家可以通过修改游戏源代码来定制自己喜欢的游戏内容,从而增加了他们对游戏的投入和喜爱。
此外,开放源代码还可以帮助游戏开发者更好地了解玩家的需求和反馈,从而更好地满足他们的期望和要求。
扑克牌游戏c++源代码/*第1题扑克牌游戏--源代码及关键源代码注解如下:*///* This Program was written entirely by the author Frank Vokoun.//*******************preprocessor directives***********************//#include <iostream.h>#include <string.h>#include <conio.h>#include <stdlib.h>#include <stdio.h>#include <time.h>// used to seed the random number generator////*********************************************************************** class Playing_Card //扑克类{private:int m_Value;char m_Face[3]; //扑克的数字大小char m_Suit ; //扑克的花色(黑、红、梅、方)public:Playing_Card();// CONSTRUCTORvoid showcard();// Displays an object of class Playing_Card void Card_Make(int);};class Deck//一副扑克(52张){private:Playing_Card m_cardarray[52];// Object array of class Playing_Cardint m_lastdelt;public:Deck();// CONSTRUCTOR initializes empty Deck objectvoid MakeDeck();// makes a complete object of class Deckvoid Deal_One();// Deals a card from top of the deckvoid ShowDeck();// Displays a Deck object to the screenvoid DeckShuff(int);// "Shuffles" a Deck object for int timesvoid Remove_Card();// Removes used card from Deck Prevents};//mistakenly using a nonexistant card //can bu used to send a card ??//***************************prototypes**********************************void Program_Init();// Program informationint main();void Center_Text(char []);// Centers textint get_number();// Gets a integer from userchar Get_Key();// Gets a char from user, pauses programvoid DeckMakeDriver();// Tests Several Functions including Makedeck int getRandInt(int min, int max);// Random number generatorvoid prog_close();// pauses before program termination//****************************Main*************************************int main()//************************************************************************** //*int main:Main Function Calls other functions//*//*expects:None.//*Returns:Integer 0;//*Side effects None//*//*Tasks(1) Seeds the Random number generator//*(2) Calls Program Init function for Title etc.//*(3) Call DeckMakeDriver to Test MakeDeck and DeckShuff.//*//***********************************************************************{srand( (unsigned)time( NULL ) );// Seeds GetRandIntint Card_Number = 0;Program_Init();// Showd title etc.DeckMakeDriver();// The Main Function Driver Tests Deck and//Playing_Card classesprog_close();// pauses screen outputreturn 1;}Playing_Card::Playing_Card()// CONSTRUCTOR//************************************************************************** //*Playing_Card Playing_Card CONSTRUCTOR FOR CLASS Playing_Card//*//*expects:None.//*Returns:None//*Side effects None//*//*Tasks Constructs object of class playing_card replaces default constructor//*********************************************************************// Constructor replaces default constructor{int i;for(i=1;i<=3;)// inits string variable to blanks{m_Face[i] = ' ';i++;}m_Suit = ' ';// inits char variable to blankm_Value = 0;}void Program_Init()//************************************************************************* //*void Program_Init():Shows Title//*//*expects None//*returns:None//*Side Effects:Text is centered on screen//*//*Task(s)Output program information to screen.//*//***********************************************************************{Center_Text("Lab #5");cout << endl;Center_Text("A Deck Driver");cout << endl <<"\n" ;Center_Text("By Frank Vokoun");cout << endl <<"\n" ;Center_Text("(C) 2001, Frank Vokoun");cout << endl <<"\n" ;Center_Text("Hit the <Return> key to Continue..");cin.get();}char Get_Key()//*********************************************************************** //*char Get_Key():Uses a input prompt to get a char//*//*expects:None.//*Returns:Input char.//*Side effects:Pauses Program execution (desired effect).//*//*Task(s):Gets a char from the user..//*//********************************************************************** {char x;x = cin.get();cout << endl;return x;}void Playing_Card::showcard()//*****************************************************************//*void showcard(card):Displays a Playing Cards object to the screen//*//* Expects:None -> Uses calling members Playing_Card object//* Returns:None//* Side Effects:Displays//*//*Task(s):Displays the object of class Playing_Card to screen//*//*********************************************************************** {cout << " ";cout << m_Face ;cout.width(1);cout << m_Suit;cout << " ";}void Center_Text(char ShellText[80])//********************************************************************** //*Void Center_Text:Displays text centered on the screen.//*//*expects:The text to display.//*Returns:None.//*Side effects:Outputs Centered text on screen.//*//*******************************************************************{int length;int center;length= strlen(ShellText);center = (80 - length)/2;for(;center!=0;center--){cputs(" ");}cputs(ShellText);}int get_number()//******************************************************************** //*//*int get_number:Gets an integer from the user.//*expects:None.//*Returns:Integer.//*Side effects:None.//*Task(s):Asks the user to enter an integer then returnsthat integer.//*.//********************************************************************** {int Input_Integer = 0;Center_Text("Please enter an integer between 0 and 51. 52 to quit.");cout << endl;cin >> Input_Integer;return Input_Integer;}void Playing_Card::Card_Make(int num)//********************************************************************* //* Get_Card(int):Creates a Playing_Card object based on an interger input.//* Expects:int//* Returns:None -> uses Calling members Playing_Card object//* Side Effects:None//*//*Tasks: 1. assign a face value//* 2. assign a m_Suit(char type)//* 3. assign a point value//*//******************************************************************** {int i = 0;char j;int face_num = num % 13;switch(face_num)// Assigns a Face value for string cards{case 0: strcpy(m_Face," A");break;case 9: strcpy(m_Face,"10");break;case 10: strcpy(m_Face," J");break;case 11: strcpy(m_Face," Q");break;case 12: strcpy(m_Face," K");break;default:j = char(face_num + 49);// Fills string with number mod 13if(i<3){m_Face[i] = ' '; i++;m_Face[i] = j;i++;m_Face[i] = NULL;break;}}if(num <= 12)m_Suit = 6;// assigns suit use ascii values forif(num >12 && num <= 25)m_Suit = 3;//card symbolsif(num >25 && num <= 38)m_Suit = 5;if(num >38 && num <= 51)m_Suit = 4;if(face_num <= 9)m_Value = face_num + 1;// Card value's Ace = 1 if(face_num >= 10)m_Value = 10;}void DeckMakeDriver()//********************************************************************//* DeckMakeDriver():Used to test the various deck functions Deckmake,//*Deckshuff, Deckcopy etc.//*Expects:None.//* Returns:None.//* Side effects:None//*//* Tasks: 1. Call make Deck//* 2. Show Deck//* 3. Call shuffle//* 4. Call show deck//* 5. While !Done Call//* a. Deal one//* b. Show card//*//*Note the dot operator is need to access object because this is not a member of the class //**********************************************************************{Deck deck_1;deck_1.MakeDeck();// Creates the Deck.deck_1.ShowDeck();// Displays deck to screen.Get_Key();// Pauses Program.deck_1.DeckShuff(250);// Shuffles the deck 250 timesdeck_1.ShowDeck();// Displays deck to screen.cout << endl <<endl << endl;char y;do{deck_1.Deal_One();cout << endl;cout << endl << endl << "Y to Deal One more N to quit"<< endl;cin >> y;y = toupper(y);}while(y == 'Y' );}void Deck::MakeDeck()// creates a full deck not a construct//************************************************************************** //* Deck Make Deck():Creates a Deck Object//* Expects:none -> uses calling functions deck object//*Returns:none -> uses calling functions Deck object //* Side effects:none//* Tasks: 1. Create a Full Deck structure of unique card structures//* a. have the decks last delt variable = to the top card//***********************************************************************{m_lastdelt = 51;// Set Deck to emptywhile(m_lastdelt >-1)// iterate until deck is full.{m_cardarray[m_lastdelt].Card_Make(m_lastdelt); // call card make for every card object m_lastdelt--;// inside the deck object ie cardarray}}void Deck::ShowDeck()//********************************************************************//* void ShowDeck:Displays the deck in a organized readable fashion to the screen //* Expects:none shows calling functions object of class deck//* Returns:none//* Side Effects:None//* Tasks: 1. set an index to lastdealt + 1//* 2. call ShowCard passing in card[index]//*********************************************************************{int index = m_lastdelt + 1;int newline = 0;Center_Text("Current Deck of Cards from top to bottom");cout << endl;while(index<=51){if(newline % 11 == 0) cout << endl;m_cardarray[index].showcard();// calls showcard for every card innewline++;// the cardarray objectindex++;}}int getRandInt(int min, int max)//*********************************************************************//*int GetRandInt:Returns a random number between min and max//*//* BORROWED FUNCTION:Used with permission from Prof. Steve Samuelson.//*//*Expects:min -- smallest possible number to return//*max -- largest possible number to return//* Returns: A number between min and max//* Side Effects:None//*//* Tasks: 1. set a num = to random number generator.//* 2. make num = num % (max - min +1); add min.//* 3. Return the num//*******************************************************************{int numToReturn;numToReturn = rand();numToReturn = numToReturn % (max - min + 1) + min;return numToReturn;}void Deck::DeckShuff( int times) //洗牌次数//********************************************************************//*Deck DeckShuff(Deck, int):Simulates the shuffling of a deck of cards//*expects:none -> uses calling functions Deck object//*Returns:none -> manipulates calling functions object of class Deck USING //* A THIS POINTER//*Side effects:no unintended effects.//*//*Task(s) 1. To randomly arrange the elements of the Deck structure Playing_Card//*array.//* A. split the Deck structure into two halves at a random location//*between 20 and 35.//* B. Alternating between the two halves move a random number of //*Playing_Card structures to the original deck structure, Until//*it is full of cards (52cards in a deck).* this is also the//*number of cards available in the to halves.//* C. Since it is a full unused deck set the lastdelt variable to -1//*//*//*********************************************************************{int x, split; //split是分开成两部分的位置,如上部分、下部分Center_Text("Shuffling Deck");cout << endl;for(x=0;x<=times;x++)// iterate input number of times {split = getRandInt(20,35);// Get split locationDeck topdeck;// Create 2 new unfilled decks Deck bottomdeck;int i;int bottomdeckindex = 1;int topdeckindex = 1;for(i=0;i<=split - 1;){topdeck.m_cardarray[topdeckindex] = this->m_cardarray[i];topdeckindex++;i++;}for(i=(split);i< 52;)// move remaining cards to bottom deck{bottomdeck.m_cardarray[bottomdeckindex] = this->m_cardarray[i]; bottomdeckindex++;i++;}int deckoutindex = 0;// set deck to fill's index to zeroint numcardstomovetop;int numcardstomovebottom;int j;int h = 0;bottomdeckindex = 52 - split;// set index to num cards in bottom topdeckindex =split;// set index to num cards in topwhile(deckoutindex <= 51){numcardstomovetop = getRandInt(2,7);//从上部分抽取的张数,是2-7之间的随机数numcardstomovebottom = getRandInt(2,7);// Move a random number of cards(2-7)for(j=0;j <=numcardstomovebottom;j++)//from bottomdeck to original deck{if(bottomdeckindex > 0)// check for available cards{this->m_cardarray[deckoutindex] = bottomdeck.m_cardarray[bottomdeckindex]; deckoutindex++;bottomdeckindex--;}for(h=0;h<=numcardstomovetop;h++)// Move a random number of cards (2 to 7){//from topdeck to original deck.if((topdeckindex > 0) && (deckoutindex <=52))// check for available cards{//and slotsthis->m_cardarray[deckoutindex]=topdeck.m_cardarray[topdeckindex]; deckoutindex++;topdeckindex--;}}}}}this->m_lastdelt = -1;// Return a complete shuffled deck}void prog_close()//*******************************************************************//*void prog_close:Waits for user input to end//*Inputs:None//*Returns:None//*Side effects:Output text to screen/waits for user input to//*end program.//*//*task(s) 1. Pauses Program so the last output can be seen//*//*********************************************************************** {cout << endl << endl;cout << " Hit the <Return> key to Continue.." << endl;cout << endl << endl;Get_Key();// Necesary for clear input.cin.get();}void Deck::Remove_Card()//*****************************************************************//* Deck Remove_Card(Deck deck_1):Removes the card delt from dealing deck.//*Expects:The Deck that delt the card.//*Returns:The Deck without the card delt.//*Side effects:None.//*//*Task(s):Remove card delt from Deck//****************************************************************{m_cardarray[m_lastdelt]= Playing_Card();// reinits used card prevents mistakes}void Deck::Deal_One()//************************************************************************** *****************//* Deck Deal one(Deck):Deals a card from the top of the deck//* Expects: A deck to deal from//* Returns:The deck minus the card delt//* Side effects:lastdealt in the deck is incremented//*//* Tasks: 1. Check if lastdealt = 51 if so Error//* 2. Increment last dealt//* 3. Return card[last dealt]//************************************************************************** {if(m_lastdelt != 51)// Checks for available cards{m_lastdelt++;cout.width(5);cout <<" Card delt";m_cardarray[m_lastdelt].showcard();}else{cout << "Out of range Error";prog_close();}}Deck :: Deck()// CONSTRUCTOR replaces default//**********************************************************************//* Deck Deck Class Deck CONSTRUCTOR//* Expects: A deck to deal from//* Returns:The deck minus the card delt//* Side effects:lastdealt in the deck is incremented//*//* Tasks: 1. Check if lastdealt = 51 if so Error//* 2. Increment last dealt//* 3. Return card[last dealt]//******************************************************************* {int lastdelt = 0;int i;for(i=0;i<=51;i++){m_cardarray[1] = Playing_Card();// calls constructor class Playing_Card}// for every Playing_Card object in}// the class Deck's array.。
关于棋牌游戏源代码开放
在现今的棋牌游戏运营行业如火如荼的阶段,为了减少与避免一些初次接触此行业的运营商被一些产品开发商公司蒙骗上当,特此编写以下的一些说明和答疑,花点时间认真阅读和思考,可能会为您减少巨大的损失。
深圳市壹柒游网络科技有限公司为您全面解答。
1.对运营商开放源代码,可以使运营商根据运营环境与实际情况调节平台,而不被产品提供商所牵制:
运营棋牌游戏,本质上做的事情就是为玩家提供最好的服务和游戏娱乐环境,玩家在这里玩开心,才会留下来,并为拉入更加多的朋友进来,从而才会使你赢取利润,是相辅相成的,是一个因果关系。
而玩家的需求日新月异,你必须根据实际的环境,调节必要的平台功能,例如注册登录策略,游戏奖励策略,游戏规则修改策略,引导购买会员策略,引导购买道具策略等等。
不同的运营时期,所进行的定制策略和程度是不一样的,所以运营商几乎每天都有修改定制部分的欲望与需求。
若运营没有得到源代码,将需要进行一系列繁琐过程:联系开发商,商讨价格,付款,等待开发,然后等待漫长的交付测试阶段。
市场机遇是不会等您的,您说这过程,使您错过了多少发展的机遇呢?
从事实也得到证明,横观现今互联网的游戏运营商,从不对运营商开放源代码的棋牌站点,运营成功的又能有多少呢?
答案是几乎没有。
再看使用了开放源代码的成功而且还保持不断发展的站点呢?数目是非常多的,具体的资料可以到网上搜索就能得到,这里我们就不逐一提及了。
您说,怎么样的系统您的发展是否更加有利呢?更加容易成功呢?
2.对运营商开放源代码,不需要为二次开发承担昂贵的开发费用:
拥有了产品源代码,才可以进行二次开发,才可以时刻根据市场的需求的变化而立即变化。
而对于一些不牵涉到高级技术能力的功能的修改,也需要开发商加入的话,容易造成运营策略的泄漏,被其他人捷足先登了。
而且开发商除了收取开发成本的人员费用外,还需要收取您的人员管理成本,市场拓展成本,还有公司的收入等。
而这一切的成本,若运营商有了系统源代码后,您的运营成本将会减少很多,而这些成本费用的节省,可以使您投入到市场营销方面,赢取更加多的发展机遇。
您说,怎么样的系统您的发展是否更加有利呢?更加容易成功呢?
3.对运营商开放源代码,可以使游戏系统更加健壮:
俗语说,一人智短,二人智长。
那么更加多的人呢?是不是应该更加更加智长呢?答案当然是肯定的。
开放源代码的系统,经历着这么多的运营商的实际运营考验,实际进行的功能增加和功能修改,并被众多的技术人员的查阅和审核,您说,这样的系统是不是比不开放源代码的系统更加健壮和问题,漏洞问题是否更加容易发现和及时修补。
而对于不开放源代码的产品商,他们是没有精力顾及到那么多的运营商,也没有这样的人力投入进行到错误的检测和修正方面。
所以,他们的系统只是把错误隐藏起来,使您无法察觉而已,而到了错误产生的时候,您的损失就无法避免了。
让我们一起开一个实际的例子吧,微软的Windows系统与开源的Linux系统,那个更加稳定,那个更加健壮?Linux经历这众多的开发人员共同研究,共同除错,是一个非常稳定的系统。
现今网络上,几乎一切超大型的门户网站,新闻网站,社区网站做服务器系统的,几乎都是清一色的开源Linux服务器系统,谁会用Windows系统的呢?
您说,怎么样的系统您的发展是否更加有利呢?更加容易成功呢?
4.对运营商开放源代码,可以使游戏运营商更加迅速适应市场的变化:
玩家的需求日新月异,你必须根据实际的环境,调节必要的平台功能,例如注册登录策略,游戏奖励策略,游戏规则修改策略,引导购买会员策略,引导购买道具策略等等。
不同的运营时期,所进行的定制策略和程度是不一样的,所以运营商几乎每天都有修改定制部分的欲望与需求。
若运营没有得到源代码,将需要进行一系列繁琐过程:联系开发商,商讨价格,付款,等待开发,然后等待漫长的交付测试阶段。
市场机遇是不会等您的,您说这过程,使您错过了多少发展的机遇呢?
5.对运营商开放源代码,可以使运营商更加放心,避免被开发商植入后门程序的顾虑:
开发源代码,可以用代码事实证明,系统是没有植入后门程序的。
若没有提供源代码,您又怎么知道和证明开发商没有植入后门程序呢?您就真的完全放心地用这样的产品去发展吗?就不怕等您发展到一定的阶段的时候,被别人利用后门进入您的系统进行破坏吗?您的一切不就被后门程序说要挟和控制了吗?安全又从而而来呢?
您说,怎么样的系统您的发展是否更加有利呢?更加容易成功呢?
6.对运营商开放源代码,可以使运营商的平台更加容易成功,更加具有价值:
棋牌系统运营的某个程度,必定会吸引某些投资商,收购商的兴趣,会提出对您的网站进行投资或者收购。
而若您的运营系统是没有代码的,您觉得投资商与收购商还会那么傻给您进行投资与收购吗?是绝对不会的,因为没有源代码,无论如何成功,都只是个空壳,没有一点实际价值和意义,运营商只能谋求在游戏运作阶段每月的玩家消费收入。
您说,怎么样的系统您的发展是否更加有利呢?更加容易成功呢?
一些疑问回答:
1.开放源代码的系统,数据是如何保证安全的呢?
一套棋牌游戏系统,是由服务器与客户端组合而成的。
服务器,是运作在您具有完全控制权的机器里,一切的修改,更新,维护,替换工作都是在您的知情,可控的范围内进行的。
客户端,是供玩家下载的,运行在玩家的电脑里。
有些运营上会有这样的疑问,游戏代码都开放了,那玩家不就更加容易编写木马和外挂程序了吗?其实这个是个极端除错误的认识,其实开放代码的系统,更加不容易出现木马和外挂程序,请接着看以下的一些分析和概念说明。
在游戏系统中,游戏客户端承担的角色只是负责玩家的输入与服务器的数据的显示,还有一些辅助逻辑功能的预先计算功能。
例如服务器告诉客户端,某某玩家干了些什么事情,客户端就简单的用友好的视觉界面表现给玩家而已。
又例如玩家要出某个牌,就发个消息通知服务器,我要出什么什么牌了,请代我告诉其他人,客户端是以这样的一个模式运作的。
我们不要忘记了,这一切的可执行的行为的合法性,正确性,都是由服务器效验和执行,而不是客户端说干嘛就能干嘛的。
开放源代码的程序,可以供运营商检测系统到底是否这样做了,服务器有没有做验证(备注:某些不开发代码的系统,为了编码的简单和减少开发时间和工作量,是不会在服务器严格的验证,导致的后果就是客户端要干什么就什么,导致服务器的数据混乱,系统不稳定)
而在整个游戏系统中,服务器程序的修改与替换,都是由您的控制而完成的,所以,只要保证了服务器环境的安全,就等于保证了整个游戏系统的安全,保证不会被玩家加入木马程序与外挂程序了。
2.既然这样,那些不提供代码的开发商为什么就不能提供源代码呢?
有几个原因的,导致他们不提供源代码:
a)系统源代码的撷取有非法性,非本公司的技术开发成果产品,是从某些不见得人的渠道获得的。
若提供源代码的话,将
会被被法律控告,遭受巨额赔款,而不提供源代码,将使控告流程无法取证,也就无法被控告了,也就没有巨额赔款了。
b)为了控制运营商,使运营上的发展与自己紧密绑定在一起,为自己日后的发展做铺垫。
c)为了获取运营商更多的利润,若是一个有了1000人的游戏平台,运营商没有代码只能给开发商来开发,那岂不是任由
开发商宰割?都有可以直接吞并的可能性存在!
d)代码具有严重的安全性,若公开的了源代码,将会被众多的技术开发人员阅读,导致爆发出系统漏洞无法修复,影响巨
大。
请各位运营商醒醒吧,因为以上的这些原因,他们是不会为您提供源代码的,就算您愿意付出昂贵的报酬代价,也是不可以的,因为涉及到的是他的命脉哦,他们知道了若提供了源代码后,等于自取灭亡,遭受巨额赔款,您觉得他们会为您提供源代码吗?。