Skip to content

AI-Cup kernel that communicate with client with Rest API

Notifications You must be signed in to change notification settings

Nimazm/Kernel-web-server-version

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Kernel-web-server-version

AI-Cup kernel that communicate with client with Rest API

Description

This is a web game where artificial intelligence programmers can participate and compete with each other by writing code for robots that try to win. The game is based on the Risk and the objective is to create the best robot possible to win against other players.

Requirements

To participate in this game, you need to install Flask, requests and jwt, which is as follows:

pip install -r requirements.txt

How to run

to run server you just need to run the run.py file

List of APIs

API Type
/ GET
get_owners GET
get_troops_count GET
get_state GET
get_turn_number GET
get_adj GET
next_state GET
put_one_troop POST
put_troop POST
get_player_id GET
attack POST
move_troop POST
get_strategic_nodes GET
get_number_of_troops_to_put GET

APIs description

/

(GET)

this is API is just for test if the server is running or not

output sample:

{
    "message" : "Welcome, server is running"
}

/get_adj

(GET)

this API returns the list of the adjacent nodes of each node

output sample:

{
    "1": [2, 3, 4],
    "2": [1, 3],
    "3": [1, 2, 4],
    "4": [1, 3, 5],
    "5": [4]
}

/number_of_troops_to_put

(GET)

this API returns the number of troops that you can put on the map

output sample:

{
    "number_of_troops": 10
}

/put_one_troop

(POST)

at the beginning the game gives you some troops to put on the map, players can put one troop in each turn this is the init state of the game

input sample:

{
    "node_id": 1
}

output sample1:

{
    "message":"troop added successfully"
}

output sample2:

{
    "error":"You can not put more than one troop in a turn"
}

/put_troop

(POST)

at the beginning of each turn you can put some troops on the map, you can use this API to choose the node that you want to put your troops and the number of troops that you want to put on that node

input sample:

{
    "node_id": 1,
    "number_of_troops": 2
}

output sample1:

{
    "message":"troop added successfully"
}

output sample2:

{
    "error":"This node is already owned by another player"
}

/attack

(POST)

you can use this API to attack a node with your node

input sample:

{
    "attacking_id": 1,
    "target_id": 2,
    "fraction": 0.5
}

rules: - the attacking_id node must be adjacent to the target_id node - the attacking_id node must be owned by you - the target_id node must be owned by another player

output sample1:

{
    "message":"attack is successful"
}

output sample2:

{
    "error":"fraction is not provided"
}

/move_troop

(POST)

you can use this API to move your troops from one node to another node

input sample:

{
    "source": 1,
    "destination": 2,
    "troop_count": 2
}

rules: - between source and destination nodes must be a path that you own all of the nodes in that path - the source node must have enough troops to move - at least one troop must stay in the source node - you should own both of the source and destination nodes - you can just move your troops once in each turn

output sample1:

{
    "message":"troops moved successfully"
}

output sample2:

{
    "error":"troop_count is not provided"
}

About

AI-Cup kernel that communicate with client with Rest API

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%