Skip to content

Instantly share code, notes, and snippets.

View safoyeth's full-sized avatar

Serg safoyeth

  • Moscow
View GitHub Profile
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@safoyeth
safoyeth / circle.cpp
Last active April 26, 2017 04:09
Simple circle system algorythm
// CircleSystem.cpp: определяет точку входа для консольного приложения.
//
#include "stdafx.h"
#include <iostream>
#include <Windows.h>
#include <vector>
#include <string>
using namespace std;
@safoyeth
safoyeth / circle.py
Created March 24, 2017 03:52
This script generates the circle system schedule
def circle(*players):
'''
you can find the description here https://safoyeth.com/2017/03/04/chessscripts/
'''
if isinstance(players, tuple):
players = list(players)
if not len(players) % 2 == 0:
players.append(None)
result = [[["", ""] for _ in range(int(len(players)/2))] for i in range(int(len(players)-1))]
for each in result:
@safoyeth
safoyeth / elo.py
Last active March 24, 2017 03:53
This is simple script to calculate Elo rating
import math
def elo(ra, rb, sa, sb, ka, kb):
'''
you can find the description here https://safoyeth.com/2017/03/04/chessscripts/
ra/rb - current rating. Python 2.x note - values must be float
sa/sb - result (1 for win, 1/2 for draw, 0 for lose)
ka/kb = 10 if ra/rb >= 2400
ka/kb = 20 if ra/rb < 2400
ka/kb = 40 if gamesPlayed < 30 or (age < 18 and ra/rb < 2300)