Coder Social home page Coder Social logo

seabotserver's Introduction

seabotserver

This is tcp server for seabattle game. Players are AI bots

tcp protocol

<- client to server
-> server to client

[0 0 0 19]{"field" : "value"}

first 4 butes = json length
первые 4 байта = длина json команды

auth

<- { "auth" : "12334yger5348fhf8d7tdg8s76g" }
-> { "auth" : 
		{ 
			"ok": 		false, 
			"error": 	"some error",
			"id" : 		123 // bot ID
			"userid" : 	11 // user ID 
		}
	}
<- { "exit" : true }
-> disconnect
// bot versus random
// if you want to debug your code, use this command.
<- { "bvr" : { "place": 0 } }
-> { "bvr" : { "id": -1, "name": "bot_-1", "ships": [0,0,0,0...] } }
// bot versus bot
// сервер сам расставляет корабли
<- { "bvb" : { "place": 0 } } 
// игрок расставляет корабли на поле
// сервер должен проверить и допустить или не допустить расстановку
<- { "bvb" : { "place":  1, "ships" : [0,0,0,0,0,0,0]	}
}
// no bots yet, wait
-> { "bvb" : { "wait": 1 } }
// start battle, opponent bot info
-> { "bvb" : { "id": 321, "name": "dopinfo", "ships": [0,0,0,0] } }
0 0 0 0 0 0 0 0 0 1
0 4 0 0 0 0 0 0 0 0
0 4 0 0 0 0 3 0 0 2
0 4 0 0 0 0 3 0 0 2
0 4 0 0 0 0 3 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
LOOP: GAME
// сервер предлагает игроку 123 сделать ход
-> { "turn" : { "id" : 123 } }

// Бот сделал ход, выстрел пришелся в точку 
// (А1) - 0,0
// (Б8) - 1,7
// (А3) - 0,2
// (Г4) - 3,3
// АБВГДЕ....
// 0123456789
// первая цифра это номер ряда, вторая цифра номер колонки
<- { "turn" : { "shot": [y, x] } }

// результат выстрела, -1 - мимо, 1 - попал, 2 - убил
-> { "turn" : { "result": -1 } }

-> { "turn" : {"opponent": { "shot": [y, x], "result": 1 } } }
GOTO GAME
// 10 second timeout
// after timeout -> lose

Battle end

-> { "end": { "winner": 123, "opponent": [0,0,0] } }

DB structure draft

User
	ID
	email
	pass
	name
	
Bot
	ID айди бота
	User
	AuthKey
	
Tournament
	ID
	Type - тип турнира
		SandBox - все боты имеют доступ в песочницу
		Tournament - после отборочного тура админ переносит в турнир
		Quality - игрок подает заявку в диапазоне дат, пишем запись в таблицу TourBot
	Name - Имя турнира
	RegStart
	RegUntil


TourBot
	Bot
	Tour
	State: Access, Deny
	RegisteredDate
	Played - сыграно боев
	Win - побед
	Lose - поражений
	Disconnect - дисконектов


seabotserver's People

Contributors

finalist736 avatar im-kulikov avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.