java版坦克大战源码-battle-city-ai:战斗城市-ai

  • b9_453111
    了解作者
  • 1.8MB
    文件大小
  • zip
    文件格式
  • 0
    收藏次数
  • VIP专享
    资源类型
  • 0
    下载次数
  • 2022-04-27 03:09
    上传日期
java版坦克战争源码战斗城市-ai 传奇 这是什么? 它是 NES 战斗城市的简单克隆。 视频: 这是如何运作的? 游戏在带有游戏窗口的服务器上运行,并侦听两个连接:player1 和 player2。 每个玩家都是一个单独的客户端(坦克)连接到游戏服务器。 客户端通过向服务器发送动作来控制他们的坦克。 当两个连接都建立并且问候消息发送到两个客户端时,游戏就开始了。 客户端的动作被定义一次,并且在游戏过程中不会发生任何变化。 目标是什么? 有两个目标: 在 2 分钟内生存 获得比第二名玩家更多的积分 如何做到这一点? 为了生存并获得最多的分数,您需要以彻底而聪明的方法来规划客户的动作。 尖端 去做 分数 1对于每个破坏微小砖 每个“冻结”第二个玩家5个 每个被摧毁的 NPC 坦克200 每枚硬币100 协议文档 是 。 如何安装? 克隆这个 repo。 代码适用于 Python 3.5、3.6 和 3.7 记住virtualenv 或 pipenv ! 如果您不是 Pythonic 程序员,那么我为您准备了备忘单: 创建: virtualenv -ppython3 venv 设置虚拟
battle-city-ai-master.zip
内容介绍
# battle-city-ai [![Build Status](https://travis-ci.org/firemark/battle-city-ai.svg?branch=master)](https://travis-ci.org/firemark/battle-city-ai) ## Legend - [What is this?](#what-is-this) - [How does this work?](#how-does-this-work) - [What is the goal?](#what-is-the-goal) - [How to achieve that?](#how-to-achieve-that) - [Tips](#tips) - [Scores](#scores) - [Protocol Documentation](#protocol-documentation) - [How to Install?](#how-to-install) - [How to write first bot?](#how-to-write-first-bot) - [Server script](#server-script) - [Run tests](#run-tests) - [Technology](#technology) - [Contributors](#contributors) ## What is this? It is a simple clone of battle city from NES. Video: https://www.youtube.com/watch?v=KwnwKErXGrI ![Game](image.png) ## How does this work? The game runs on a server with a game window and listens for two connections: player1 and player2. Each player is a separate client (tank) connected to the game server. The clients control their tanks by sending actions to the server. The game starts when both connections are established and greetings messages are send to both clients. The client's moves are defined once, and do not undergo any changes during the gameplay. ## What is the goal? There are two goals: 1. **SURVIVE** in 2 minutes 2. Get more points than the second player ### How to achieve that? In order to survive and score the biggest amount of points, you need to program the moves of your client with a thorough and clever approach. ### Tips TODO ### Scores * **1** for each destroyed tiny-brick * **5** for each 'freeze' second player * **200** for each destroyed NPC tank * **100** for each coin ## Protocol documentation Is [here](docs/). * [General rules of game](docs/rules.md) * [Types in game](docs/types.md) * [Collision](docs/collision.md) * [General Protocol](docs/protocol.md) * [Player actions](docs/actions.md) * [Unit's messages](docs/units.md) * [Game's messages](docs/game.md) ## How to install? Clone This repo. code works in Python 3.5, 3.6 and 3.7 *remember* about virtualenv or pipenv! * https://docs.python.org/3/tutorial/venv.html * https://pipenv.readthedocs.io/en/latest/ * when you are not-pythonic programmer then I have cheat sheet for you: * create: `virtualenv -ppython3 venv` * set virtual enviroment: `source venv/bin/active` ```sh python setup.py develop ``` To get OpenGL support (mega boost!) please install pyglet (not required) ```sh pip install pyglet ``` ## How to write first bot? First, copy example code to main dir with game. Example codes are for: * [python](battle_city/examples/python/radom.py) * [nodejs](battle_city/examples/nodejs/random.js) * [ruby](battle_city/examples/ruby/random.rb) * [java](battle_city/examples/java/Game.java) (more examples are [here](battle_city/examples/)) remember about virtualenv or pipenv! * https://docs.python.org/3/tutorial/venv.html * https://pipenv.readthedocs.io/en/latest/ ### For linux/mingw/osx/wsl #### Python ```sh ./run_game.sh --cmd-p1 "python copied_client.py" ``` #### NodeJs ```sh ./run_game.sh --cmd-p1 "nodejs copied_client.js" ``` #### Ruby ```sh ./run_game.sh --cmd-p1 "ruby copied_client.rb" ``` #### Java oh my god, what a terrible language! You need a json-simple package ```sh javac -cp /usr/share/java/json-simple.jar Game.java -d . ./run_game.sh --cmd-p1 "java -cp /usr/share/java/json-simple.jar:. Game" ``` The color of your tank will be yellow. ### maybe windows? Omg why? You have four options: 1. Install http://www.mingw.org/ and run bash shell 2. WSL https://docs.microsoft.com/en-us/windows/wsl/install-win10 3. Virtualbox https://www.osboxes.org/ubuntu/ 4. Run three scripts in seperate consoles: * `python -m battle_city.server` * `python client_a.py` * `python -m battle_city.examples.random` ### tmux version - more hackerable (with split screens in terminal)! ``` ./run_game_tmux.sh --cmd-p1 "python copied_client.py" ``` command would be a runner, example `"python copied_client.py"` - **remember** about quotes and command (python, nodejs, ruby or something else) to run your script!! Another examples: * *[random](battle_city/examples/random.py)* - show logs and make random actions * *[boilerplate](battle_city/examples/boilerplate.py)* - empty client * *[window](battle_city/examples/window.py)* - client shows window and draw game from recevied data ``` run_game.sh [OPTIONS...] --help print this text --cmd-p1 CMD_P1 command to run client as player1. Default is "python -m battle_city.examples.python.radom" --cmd-p2 CMD_P2 command to run client as player2. Default is "python -m battle_city.examples.python.radom" --cmd-p3 CMD_P3 command to run client as player3. Default is "python -m battle_city.examples.python.radom" --cmd-p4 CMD_P4 command to run client as player4. Default is "python -m battle_city.examples.python.radom" --map MAP select map to run game. Default is pilif --max-players NUM number of bots in game. Max is 4. Default is 2 --ip IP IP of server. Default is 127.0.0.1 --port PORT PORT of server. Default is 8888 --speed SPEED tick speed of game. default is 1 --hidden-window don't show window with game, run only server --turn-off-after-end turn off server when game is end. Good option for machine learning --show-collision-border show borders with collisions ``` The `run_game.sh` script will run the whole game with two clients. There is no need to run anything else. The script includes a command for running server and commands for running two clients. The basic clients are dummy. They will just move randomly. If you want to start implementing your algorithms for moves, create your own client, based on the example [example code](battle_city/examples/random.py), and after finishing, use it in `run_game.sh` script (examples are above). ## Server script ``` python -m battle_city.server [--ip IP] [--port PORT] [--hide-window] [--speed SPEED] ``` Note that `run_game.sh` script runs the server as well as both clients by default. If you want to create your own configuration for running the game, use the command above in your own script. ## Run tests ```sh pip install -e '.[test]' pytest tests/ ``` ## Technology * Python >=3.5 * Pygame * Pyglet * Asyncio * JSON * Love ## Contributors * Firemark - game logic and everything else * Socek - idea * Stachu - documentation improvment, beta testing * Noemi - beta testing * Prs - nice tips
评论
    相关推荐
    • stjornbord-user-daemon:控制面板用户更新服务器
      控制面板用户更新服务器服务器位于学校的 FreeIPA 身份验证服务器上,并定期向仪表板询问需要更新的用户。 更新服务器有几个后端,并向需要通过它们升级的用户发出哔... $ virtualenv --system-site-packages user-d
    • serverpy:服务器
      serverpy:服务器
    • crashparty:Wreckfest的服务器监视器
      Crashparty-Wreckfest服务器的内存监视器 这与Wreckfest,Bugbear Entertainment或THQ Nordic无关。 动机 当Flatout 2流行时,我们就有了自己的内部计分系统,可以跟踪我们自己的Flatout 2的记录,得分和比赛。 由于...
    • budgie:通过 ssh 远程控制服务器
      通过 ssh 远程控制服务器 安装 安装库 virtualenv venv && . venv/bin/activate # optional pip install budgie 您需要为远程主机配置无密码 SSH: ssh-keygen -q -t rsa -N 'your_password_here' -f ~/.ssh/id...
    • Python-lamsonPythonicSMTP应用服务器
      lamson:Pythonic SMTP 应用服务器
    • commapps:社区应用服务器的配置
      部署到社区应用程序主机的脚本和其他文件的存储库。 包含服务器设置运行手册 是开发此存储库并设置外部服务和程序所需的工作清单。 许可证尚未确定,请注意,某些文件是从其他来源提供的。
    • fyp-public:帝国理工学院EEE硕士最后一年项目的公共工作
      期末项目 最终年项目。 电气与电子工程硕士-伦敦帝国学院 建议与故障排除 一组对该项目有用的工具,并结合了该项目中... rayxx.doc.ic.ac.uk机具有PIP -批量服务器没有(但你可以workon一个virtualenv中确实有点子!)
    • discord-voicetools:Bot将角色同步到语音通道中的用户
      语音工具 Discord bot简化了语音工具 当前,这不是供公共使用,而是供私人服务器使用,这意味着UI和...要启动机器人,请安装所有依赖项并输入virtualenv。 将环境变量DISCORD_TOKEN设置为机器人的令牌并启动main.py
    • PRJ_Surveillance_System:这是“最后一年”项目的代码库
      Raspberry pis和服务器始终需要在同一本地网络下运行。 创建一个电报机器人==> 收集电报机器人聊天ID ==> 依存关系 您将需要在Raspbery Pi和本地服务器上下载软件包要求,以设置正确的环境 建议将其在客户端和...
    • 服务器事件广播服务器CycloneSSE.zip
      Cyclone SSE 是一个 Server-Sent Events (EventSource) 广播服务器,基于 Cyclone Web 服务器构建。安装:virtualenv --no-site-packages env . env/bin/activate pip install cyclone-sse客户端使用:<!...