All Projects → fatihkahveci → simple-matchmaking

fatihkahveci / simple-matchmaking

Licence: MIT License
Simple rule based matchmaking for your online game with support of Redcon(RESP) protocol.

Programming Languages

go
31211 projects - #10 most used programming language

Projects that are alternatives of or similar to simple-matchmaking

awesome-gnu-linux-gaming
A curated list of awesome GNU/Linux tips & tricks, games, tools, and resources - Mirrored from: https://gitlab.com/linuxcafefederation/awesome-gnu-linux-gaming.git
Stars: ✭ 135 (+92.86%)
Mutual labels:  gaming, gaming-software
xcloud-shield
Xcloud Beta Unofficial App for the Nvidia Shield Android TV. Playing Xbox Cloud Gaming directly on the box Nvidia Shield tv in the best way.
Stars: ✭ 93 (+32.86%)
Mutual labels:  gaming
go-evepraisal
the code that powers evepraisal.com
Stars: ✭ 61 (-12.86%)
Mutual labels:  gaming
SteamDepotDownloaderGUI
A simple GUI tool based on DepotDownloader for downloading Steam depots.
Stars: ✭ 26 (-62.86%)
Mutual labels:  gaming
RetroGOG
RetroArch integrations for GOG Galaxy 2.0
Stars: ✭ 84 (+20%)
Mutual labels:  gaming
nim-redisparser
RESP(REdis Serialization Protocol) Serialization for Nim
Stars: ✭ 16 (-77.14%)
Mutual labels:  resp
Apple-Silicon-Guide
Apple Silicon Guide. Learn all about the M1, M1 Pro, M1 Max, and M1 Ultra chips.
Stars: ✭ 240 (+242.86%)
Mutual labels:  gaming
FFXIVPocketGuide
A collection of mobile friendly guides to help players navigate group content in Final Fantasy XIV.
Stars: ✭ 16 (-77.14%)
Mutual labels:  gaming
Dell-S2716DGR-Calibration-Guide
Calibration guide for the Dell S2716DG and S2716DGR to get the best picture quality and colors
Stars: ✭ 33 (-52.86%)
Mutual labels:  gaming
LawRun
Kernel source code (LawRun Kernel) for xiaomi sdm845 | Pocophone f1 (beryllium), Mi 8 (dipper), Mi Mix 2s (polaris) | You can fork and enjoy.
Stars: ✭ 22 (-68.57%)
Mutual labels:  gaming
BoxVR-Playlist-Manager
A Windows based playlist manager for the VR fitness game BoxVR
Stars: ✭ 17 (-75.71%)
Mutual labels:  gaming
brackets-viewer.js
A simple library to display tournament brackets (round-robin, single elimination, double elimination).
Stars: ✭ 52 (-25.71%)
Mutual labels:  gaming
expo-three-orbit-controls
🎥 Three.js Orbit Controls (Camera) bridged into React Native
Stars: ✭ 43 (-38.57%)
Mutual labels:  gaming
Cloudbank
An alternative Computer vision and AI training platform built to play any game on Steam (Linux).
Stars: ✭ 18 (-74.29%)
Mutual labels:  gaming
AirHockey
Air Hockey game created using pygame
Stars: ✭ 25 (-64.29%)
Mutual labels:  gaming
dcli
Command line utilities for Destiny 2
Stars: ✭ 49 (-30%)
Mutual labels:  gaming
es-theme-Super-Retroboy
Super Retroboy Theme for the RetroFlag GPi Case and Small Screens 4:3 Aspect
Stars: ✭ 45 (-35.71%)
Mutual labels:  gaming
thatsmybis
A tool for loot council guilds - easily keep track of your raid's loot distribution
Stars: ✭ 24 (-65.71%)
Mutual labels:  gaming
input-remapper
🎮 An easy to use tool to change the mapping of your input device buttons.
Stars: ✭ 1,142 (+1531.43%)
Mutual labels:  gaming
eve-overview
EVE Online Overview Generator
Stars: ✭ 60 (-14.29%)
Mutual labels:  gaming


Simple Matchmaking

Simple rule based matchmaking for your online game with support of Redcon(RESP) protocol.

Go Report Card Go Cover Card GitHub license

1- Simple Match Rule

Easiest usage of system is "Direct Match Rule" in this rule players match each other without any rule.

package main

import (
	"github.com/fatihkahveci/simple-matchmaking/matchmaking"
	"github.com/fatihkahveci/simple-matchmaking/server"
	"github.com/fatihkahveci/simple-matchmaking/store"
	"time"
)

func main()  {
	inMemory := store.NewInMemoryStore()
	dur, _ := time.ParseDuration("10s")

	r := matchmaking.NewDirectMatchRule()


	respServer := server.NewRespServer(inMemory, ":1234")

	matcher := matchmaking.NewMatchmaking("test",respServer,inMemory, r, dur)

	matcher.Start()
}

2- Score Match Rule

In this example users match with given score rule which means match happens only user score 10 between 15.

package main

import (
	"github.com/fatihkahveci/simple-matchmaking"
	"github.com/fatihkahveci/simple-matchmaking/rules"
	"github.com/fatihkahveci/simple-matchmaking/server"
	"github.com/fatihkahveci/simple-matchmaking/store"
	"time"
)

func main()  {
	inMemory := store.NewInMemoryStore()
	dur, _ :=time.ParseDuration("10s")

	r := rules.NewScoreMatchRule(10,15)


	respServer := server.NewRespServer(inMemory, ":1234")

	matcher := simpe_mm.NewMatchmaking("score",respServer,inMemory, r, dur)

	matcher.Start()
}

3- Custom Match Rule

In this example we create our own rule. We just need to follow "MatchRule" interface.

package main

import (
	"github.com/fatihkahveci/simple-matchmaking"
	"github.com/fatihkahveci/simple-matchmaking/server"
	"github.com/fatihkahveci/simple-matchmaking/store"
	"time"
)


type CustomFieldMatchRule struct {
	Field string
	MinThreshold int
	MaxThreshold int
}

func NewCustomFieldMatchRule(field string,minThreshold, maxThreshold int) CustomFieldMatchRule {
	return CustomFieldMatchRule{
		Field: field,
		MinThreshold: minThreshold,
		MaxThreshold: maxThreshold,
	}
}

func (r CustomFieldMatchRule) Match(user1, user2 store.User) bool {
	user1Level := user1.Fields[r.Field].(int)
	user2Level := user2.Fields[r.Field].(int)


	minLevel := user1Level - r.MinThreshold
	maxLevel := user1Level + r.MaxThreshold

	if user2Level >= minLevel && user2Level <= maxLevel {
		return true
	}

	return false
}

func (r CustomFieldMatchRule) GetName() string {
	return "CustomField"
}

func main()  {
	inMemory := store.NewInMemoryStore()
	dur, _ :=time.ParseDuration("10s")

	r := NewCustomFieldMatchRule("level",10,20)


	respServer := server.NewRespServer(inMemory, ":1234")

	matcher := simpe_mm.NewMatchmaking("custom",respServer,inMemory, r, dur)

	matcher.Start()
}

Usage

You can add new user to pool using any redis client. Thanks for Redcon ❤️

redis-cli -p 1234 add '{
  "id": "55",
  "score": 5
}'

Also you need to subscribe your matchmaking channel.

redis-cli -p 1234
127.0.0.1:1234> subscribe simple
Reading messages... (press Ctrl-C to quit)
1) "subscribe"
2) "simple"
3) (integer) 1
1) "message"
2) "simple"
3) "{\"user_1\":{\"id\":\"12\",\"score\":5,\"join_time\":\"2021-08-31T22:57:27.109609+03:00\",\"fields\":null},\"user_2\":{\"id\":\"55\",\"score\":5,\"join_time\":\"2021-08-31T22:57:27.109614+03:00\",\"fields\":null},\"match_rule_name\":\"Direct\",\"time\":\"2021-08-31T22:57:27.116724+03:00\",\"action_type\":\"match\"}"

TODOS

  • More Server Support (WebSocket etc)
  • More Store Support (Redis, Mongo etc)
  • Multiple User Support (Team matchmaking)
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].