摘 要本文详细介绍了一个网络对战军棋游戏的设计和实现。对于军棋游戏来说,规则非常简单,就是根据先后顺序在棋盘上走棋吃子,直到一方最先将对方的“军旗”挖掉为胜。该 游 戏 使 用 C# 编 程 实 现 在 网 络 中 的 通 信 。 这 里 使 用 了 UDP ( User Data Protocol)。UDP 是用户数据文报协议的简称,两台计算机之间的传输类似于传递邮件;两台之间没有明确的连接,使用 UDP 协议建立对等通信。游戏开始后,创建一个线程。启动线程后,通过不断侦听本机设定的端口,得到对方发送来的信息,根据自己定义的通信协议中传送的是“输赢信息”、“下的棋子位置信息”、“重新开始”等信息而分别处理。发送信息较为简单,主要实现创建 UDP 网络服务,传送信息到指定计算机的端口号后,关闭 UDP 服务。游戏最终实现了在网络中创建游戏、加入游戏等功能,可以实现在网络中联机对战的要求。关键词:军棋;UDP;C#Abstract This paper describes the design and implementation of the Versus-network Jun Qi.Game rules are very simple:take turns playing chess on a chess board,and the one who dig the “flag” of the other side first will be the winner. The game uses the C # programming to establish communication in the network .UDP is used there.UDP is the short for User Data Protocol.Transmission between two computers is similar to delivering the message;There is no clear connection between the two, using the UDP protocol to establish peer communications.After the start of the game, create a thread.After starting the thread ,through continuously listening to the port we set,we get information from the other side. Then process respectively "winning or losing ", "the pieces position ", "start again" and other information according to our own definition of communication protocol.Sending information is relatively simple,mainly to create UDP network services, transmit information to the designated remote port of the other computer, shut down the UDP service...