Colorfightai

A Game AI for game on http://colorfight.herokuapp.com/
Alternatives To Colorfightai
Project NameStarsDownloadsRepos Using ThisPackages Using ThisMost Recent CommitTotal ReleasesLatest ReleaseOpen IssuesLicenseLanguage
Mainloop.js4802664 months ago5May 30, 20174mitJavaScript
Provides a well-constructed main loop useful for JavaScript games and other animated or time-dependent applications.
Nx Activity Log325
12 days ago17mitC++
Homebrew application for the Nintendo Switch which displays play activity with more accuracy
Acnh Bcats186
a year ago
Animal Crossing New Horizons BCAT Events
Gbm173
4 days ago1gpl-3.0Visual Basic .NET
Game Backup Monitor - Automatically backup your saved games!
Redux Time105138 months ago27December 04, 201816mitJavaScript
∞ High-performance declarative JS animation library for building games, data-viz experiences, and more w/ React, ThreeJS, Inferno, SnabbDOM and others...
Realtime88
6 months ago45mitC#
A mod for the Cities: Skylines game. Adjusts the time flow and the citizens behavior to make them more real.
Sandcastle Builder76
3 months ago144otherJavaScript
xkcd: 1190: Time: The Game
Gaming In Python55
2 years agoPython
Code to all the Games I made using Python Programming Language
Game Manager53
a month ago1SourcePawn
Game Manager ( Block Radio , Radio Start Round Hide Radar , Money , Messages , Blood , Ping , Map Rotaion With Maplist , Restart Server Last Player Disconnect , And More )
Jitternator53
5 years agomitC++
Lessons learnt from hunting jitter issues
Alternatives To Colorfightai
Select To Compare


Alternative Project Comparisons
Readme

ColorFight!

ColorFight is a game where you try to occupy as many cells as possible on the map.

Rules

  • When you join the game, you will be given a random cell as a start.

  • You can only attack the cell that's adjacent to your occupied cells.

  • You can only attack one cell at a time. During that time, you are not able to attack other cells.

  • The time you need to occupy a cell is based on the last time when the cell is occupied. The longer the time is, the easier it would be to be attacked. The minimum time to occupy a cell is 2s. (The equation of the time to occupy is 2 + 20 * (2 ^ (-x/20)). So when it's just occupied, it takes 22s to attack it. After 20s, it becomes 12s. After around 55s, it becomes 5s)

  • You can attack your own cell to refresh the occupy time, but it would take the same amount of time as other players attacking it.

How To Start

  • First clone the git repository. git clone https://github.com/gaogaotiantian/ColorFightAI.git

  • Then you can run the exampleAI by python exampleAI.py

  • If your computer complains about requests module, try pip install requests[security] or sudo pip install requests[security] if it complains about privilege.

  • Or you can use python3 by python3 exampleAI.py. The library and the exampleAI support both python2 and python3.

  • You can watch the result here https://colorfight.herokuapp.com/

API

The module provided some API for the game. You are welcome to add your own API, even directly talk to the server with HTTP requests if you want.

Game is the main class for the API. You should instantiate an object for it like g = Game().

After that, you can do the following actions:

  • JoinGame(name) will let you join the game with a name. ex. g.JoinGame('MyAI'). Notice the API is already optimized so when you try to join the game with the same name on the same computer(with the generated token file), it will not generate a user. You can continue to play the game as the user before. name has to be a str.

  • Refresh() will get the current game data from the server. ex. g.Refresh(). This function will store the raw data into self.data which you can access if you want. Also this function will fill in self.width and self.height for the game, as well as self.currTime for the time of this information. For game that has a end time, self.endTime will be updated, otherwise it will be 0.

  • GetCell(x,y) is a easy way to access the data of one cell. ex. g.GetCell(1,2). The function will return a Cell object which has all the data of a single cell at (x,y). If the pair (x,y) given is invalid, it will return None. x and y starts with 0, and the maximum value is g.width-1, g.height-1, respectively.

  • AttackCell(x,y)is the only action you need to play the game. ex. g.AttackCell(2,2). It will try to attack the cell you specified. The return value will be a tuple with 3 items. Returning (True, None, None) means the action is successful. Otherwise it will return a tuple (False, err_code, err_msg) where err_code will contain the error code from the server and err_msg will contain the reason it failed.

You also have the following data in Game:

  • uid contains your user id. That's the unique identification for you.

  • endTime is the time when the current game will end. If it's 0, it's unlimited time game. This is a timestamp from the server.

  • width and height contains the width and height of the current game.

  • currTime is the current time of the current data from the server. This is a timestamp from the server.

  • users is a list of User object which has all the user info.

Cell Data

  • owner: who owns this cell now. It's a user id.

  • attacker: who is attacking this cell now. Invalid if isTaking is False.

  • isTaking: is this cell being attacked. If it's True then you can't attack it.

  • x: x coordinate.

  • y: y coordinate.

  • occupyTime: when is this cell occupied. Server side time in seconds. This is a timestamp from the server.

  • attackTime: when is this cell attacked. Invalid if isTaking is False. This is a timestamp from the server.

  • takeTime: how long it would take if you attack this cell. This is a number of seconds.

  • finishTime: when will the attack finish. Invalid if isTaking is False. This is a timestamp from the server.

User Data

  • id: unique user identification.

  • name: user name.

  • cdTime: when can this user attack again. This is a timestamp from the server.

  • cellNum: how many cells does this user occupy.

Error Code from AttackCell()

  • 0: Success.

  • 1: The cell you attack is invalid. It could be that your input is out of the map, or the cell you attack is not adjacent to your occupied cells.

  • 2: The cell you attack is being taken by another player.

  • 3: You are in CD time. You can't attack any cell now.

Popular Video Game Projects
Popular Time Projects
Popular Games Categories

Get A Weekly Email With Trending Projects For These Categories
No Spam. Unsubscribe easily at any time.
Python
Game
Time
Attack
Timestamp