Scoring systems - MoutonBinoclard/Super-Python-Calculator GitHub Wiki

What is a scoring system ?

A scoring system is the function that tell how the placement and the kills awards points. It can be anything from a function to the value associated for a certain placement

Here is an exemple:

Placement Points
1st 10
2nd 8
3rd 7
Between 4th and 5th 5
Then to everyone you add (Number_of_player) - (Placement)

And for the points awarded for kill, it can be something like this :

Numbers of kill Points
1st kill 2 points
Then 1 points for each kill

The goal of this page is to let you learn how you can create and use one

How to create a new one

Each scoring system are stored in a python file in the "SPC_scoring" folder. If you want to create a new one, you can copy one of the existing one and modify it or you can go crazy and start from scratch.
 
Each scoring system must contain the following functions:

def kill_points(placement, kills, total_players):
    # Define how kills award 

def placement_points(placement, kills, total_players):
    # Define how placement awards points

def masterkill(presence_de_masterkill, kills, total_players):
    # Define how many points the Masterkill awards
    # presence_de_masterkill is a boolean that tell if there is masterkill

AND ALL THE FUNCTION SHOULD HAVE THIS LINE BEFORE ANYTHING ELSE:

def function(blabla, blablabla, bla):
    if placement == 0 or placement == -1:
        return 0

    else :
        #Then you can write the code

This line is to ignore banned, absents or spectators players. (And these players are either positionned 0 or -1)
  Now we will explain how to create each function more in detail.

Kill points function

A kill function define how kills award points It can be linear :

def kill_points(placement, kills, total_players):
    
    # This is the important line
    if placement ==0 or placement ==-1:
        return 0
    
    # This is the linear part
    else :
        return 2*kills

Here for the players, each kill gives 2 points

Or we can go a bit different

def kill_points(placement, kills, total_players):
    
    # This is the important line
    if placement ==0 or placement ==-1:
        return 0
    
    else:
        if 0 <= kills <= 4:
            return kills # it is the same as writting kills*1
        else :
            reutrn 4

Here, the first 4 kills award 1 points each, then you can't have more points

You can also use crazy mathematics function !

import math
def kill_points(placement, kills, total_players):
    
    # This is the important line
    if placement ==0 or placement ==-1:
        return 0
    
    else:
        return math.exp(kills)-1

Btw, this one is really dumb... Using an exponential for kills, REALLY ???

Anyway, I think there is enough example to make a great kill function here.

Placement points function

And after the kills function, we need to talk about the placement points ! This one is pretty easy since it's very similar to a kill_points function.

So instead of explaining how python works, check this by yourself, I'll give some exemples of what works and give basic structures.

def placement_points(placement, kills, total_players)

    # This is the important line
    if placement ==0 or placement ==-1:
        return 0
    
    else :
        if placement = 1:
            return 10
        elif placement = 2:
            return 8
        elif placement = 3:
            return 6
        elif 4 <= placement <= 7:
            return 5
        else :
            return 0

For this function it's : 10 points for being first, 8 for second and 6 for third. If you're between 4 and 7 included, you gain 5 points. Else you gain nothing.

You can also use affine function

def placement_points(placement, kills, total_players)

    # This is the important line
    if placement ==0 or placement ==-1:
        return 0
    
    else :
        return (total_players - placement)*2

Here last gain 0 point, and for each rank passed, you gain 2 points

Masterkill function

The last function to understand is the masterkill one. Simply explain, it's a bonus you can award to player if someone (or more) has the most kill in a game. Here is one exemple

def masterkill(presence_de_masterkill, kills, total_players):
    if presence_de_masterkill :
        return 3
    else :
        return 0

In the instance, if you have the masterkill, you gain 3 bonus point

Choose the scoring system in SPC

Now that you have created a scoring system, you'll need to tell SPC to use it. To do that, you need to locate this line in the SPC.py file:

'MODIFY THE SCORING SYSTEM'

# To adjust the scoring system, update the function definitions in the Python preset file.
# When team mode is active, kills represent the total kills achieved by the player's team.

# Type the name of the file containing the scoring system you want to use:
# (The file must be in the SPC_scoring_presets folder.)

from SPC_scoring.pvp_arena_solo import kill_points, placement_points, masterkill

And then, you just need to change the name of the file to the one you created. Instead of:

from SPC_scoring.pvp_arena_solo import kill_points, placement_points, masterkill

You can put:

from SPC_scoring.my_own_scoring_system import kill_points, placement_points, masterkill

And now, you can run SPC and it will use your scoring system !