No description, website, or topics provided.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
RitoAPI2-0G
.gitattributes
.gitignore
README.txt
SetupInstructions.txt
riot.txt

README.txt

Summoner Name      : Epic Lag Spikes
Region             : North America
Location           : Maryland, United States of America
Challenge Topic    : 2 - AP Item Usage
Demonstration Link : http://96.244.240.197/RitoAPI2-0/ ( This is my current IP, which may be subject to change. )

//==============================================================\\
||                      Table of Contents                       ||
\\==============================================================//

Functionalities
    |
    +-- Overview
    |
    +-- Item Combinations
    |
    +-- Champion Choice

HTML / CSS Files
    |
    +-- index.html
    |
    +-- MainC1.css
    |
    +-- MainC2.css
    
Javascript Files
    |
    |-- Load.js
    |
    |-- Resize.js

PHP Scripts
    |
    +-- config.php
    |
    +-- DBConnector.php
    |
    +-- RitoConnector.php
    |
    +-- Imports
    |   |
    |   +-- ImportItemList-1.php
    |   |
    |   +-- ImportChampions.php
    |   |
    |   +-- ImportGame.php
    |
    +-- Overview.php
    |
    +-- Item.php

SQL Scripts
    |
    +-- DBSetup-4.sql
    |
    +-- SetCount.sql
    |
    +-- SetCombos-1.sql
    |
    +-- SetCombosF-0.sql
    |
    +-- SetChamps-2.sql
    
MySQL Tables
    |
    +-- items
    |
    +-- champions
    |
    +-- players511
    |
    +-- players514
    |
    +-- purchases511
    |
    +-- purchases514
    |
    +-- synergy
    |
    +-- popular
    |
    +-- synergy_f
    |
    +-- popular_f
    |
    +-- champ_win
    |
    +-- champ_purchase

Additional Discussions

//==============================================================\\
||                       Functionalities                        ||
\\==============================================================//

<<=========================  Overview  =========================>>

The landing page provides an overview of AP item usage.
The information provided on this page include the purchase count and win rate of each item during each patch and the change rate between those numbers.
The change rate for purchase count is computed as the ratio between the different of the purchase counts and the purchase count during the 5.11 patch.
The change rate for win rate is computed as the linear different between the 2 win rates.
The length of the progress bar used to demonstrate purchase count is computed as the ratio between the purchase count of the associated item and the highest purchase count of any non-trinket item.  The current non-trinket item with the highest purchase count is infinity edge.

<<====================  Item Combinations  =====================>>

Item specific pages contains a section on item combinations.
This section provides information on combinations of items that are commonly purchased together and combination of items that produces high win rates when purchased together.
The purchase rate of the combination is computed as the ratio between the purchase count of the combination and the purchase count of the first item in the combination.
The win rate of the combination is computed as the ratio between the win count of the combination and the purchase count of the combination.

Interpretation Example :

    Popularity : Players who purchase item A often purchase item B, C, ...
    Synergy    : The win rate of item A is highest when it is purchase with item B, C, ...

Note: The 2 items part of a single combination are not interchangable.  Example :

    Item 1 has been purchased 10 times.
    Item 2 has been purchased 5 times.
    Item 1 and item 2 have been purchased together 4 times.

    The purchase rate of the combination is 4/10->40% for item 1.
    The purchase rate of the combination is 4/5 ->80% for item 2.

<<=====================  Champion Choice  ======================>>

Item specific pages contains a section on champion choice.
This section provides information on combinations between items and champions that are commonly observed and combinations between items and champions that produces high win rates.
The purchase rate of the combination is computed as the ratio between the purchase count of the combination and the number of times the champion has been selected.
The win rate of the combination is computed as the ratio between the win count of the combination and the purchase count of the combination.

Interpretation Example :

    Popularity : The champions that are most likely to purchase item A are champion A, B, C, ...
    Synergy    : The win rate of item A is highest when it is purchase by champion A, B, C, ...

//==============================================================\\
||                       HTML / CSS Files                       ||
\\==============================================================//

<<========================  index.html  ========================>>

This file is used as the landing page to provide a HTML basis on which PHP scripts will load content.

<<==================  MainC1.css / MainC2.css ==================>>

This file contains CSS formatting for various generalizable classes for 1 column / 2 column layout.

.bItem          - display div as block element
.iItem          - display div as inline-block element
.padded			- padding above and below
.wrapper        - for grouping
.wrapper.narrow - for grouping
.heading        - padding on every side except bottom
.section        - group divs related to a single item or combination 
.target         - identify div as click-able
.icon           - item / champion icon
.purchase       - theme related to purchase
.win            - theme related to win rate
.bar            - background for progress bar
.percent        - foreground for progress bar
.label          - large label
.label2         - small label
.legend         - color code
.home           - button for returning to landing page
.insert         - for isolated sections
.c2             - hidden for single column layout

//==============================================================\\
||                       Javascript Files                       ||
\\==============================================================//

<<=========================  Load.js  ==========================>>

This file contains Javascript used to load PHP files using XMLHttpRequest().

function    - getPHP
parameters  - targetPHP : path to the PHP script
            - targetDiv : ID of the div where the PHP script will be loaded

<<========================  Resize.js  =========================>>

This file contains Javascript that is responsible for selecting between MainC1.css or MainC2.css based on window size.

function    - CheckSize();

//==============================================================\\
||                         PHP Scripts                          ||
\\==============================================================//

<<========================  config.php  ========================>>

This file contains configuration settings for connecting to the Riot API, connecting to the local database, and image file paths.

<<=====================  DBConnector.php  ======================>>

This file contains a class that is responsible for connecting to a MySQL database using MySQLi.

Class Name : SQLConnecter

Constructor Parameters
    Host IP
    Username
    Password
    Database Name
    Database Port
    
Function - connect()
    attempt to connect to the database using the provided parameters

<<====================  RitoConnector.php  =====================>>

This file contains a class that is responsible for making requests using the Riot API.

Class Name : RitoConnector

Constructor Parameters
    $region
    $api_key
    $game       - string specific for requesting match data
    $champ      - string specific for requesting a list of champions
	$items		- string specific for requesting a list of items

Function - get_content($url)
    attempt to retrieve a JSON object from an API request URL

Function - champ_url()
    create an API request URL for retrieving a list of champions
	
Function - champ_url()
    create an API request URL for retrieving a list of items
	
Function - game_url($matchid)
    create an API request URL for retrieving match data

<<===================  ImportItemList-X.php  ===================>>

This script is responsible for populating the items table with item IDs and item names.

<<===================  ImportChampions.php  ====================>>

This script is responsible for populating the champions table.
    
<<======================  ImportGame.php  ======================>>

This script is responsible for populating players and purchase tables with information from a single game.

Function   - ImportGame
Parameters - RitoConnector Object (requires RitoConnector.php)
           - Database Handle (requires DBConnector.php)
		   - Patch Number (511 or 514)
		   - Match ID
		   - Ranked (1 for ranked, 0 for unranked)

<<=======================  Overview.php  =======================>>

This script is responsible for displaying a list of AP items along with their purchase count and win rate.

<<=========================  Item.php  =========================>>

This script is responsible for displaying detailed information on a single item.

Function - GetHeadline($ItemID, $dbh)
    displays the "Back to Item List" button, the legend, and the overview section

Function - GetOverview($ItemID, $dbh)
    displays the overall purchase count and win rate
	
Function - GetCombinations($ItemID, $dbh)
    displays information on item combinations related to the targetted item

Function - GetPopular($ItemID, $dbh)
    displays information on item combinations that are commonly purchased
	
Function - GetSynergy($ItemID, $dbh)
    displays information on item combinations that produce high win rates

Function - GetSynergyF($ItemID, $dbh)
    retrieve information from synergy_f instead of synergy
    applies a filter that requires a purchase rate of at least 10%

Function - GetChampions($ItemID, $dbh)
    displays information on champion+item combinations related to the targetted item

Function - ChampionPurchases($ItemID, $dbh)
    displays information on champion+item combinations that are commmonly observed
	
Function - ChampionWins($ItemID, $dbh)
    displays information on champion+item combinations that produces high win rates

//==============================================================\\
||                        MySQL Scripts                         ||
\\==============================================================//

<<======================  DBSetup-X.sql  =======================>>

This script is responsible for setting up the table structure of the database.
This script contains drop commands if the table already exists.

<<=======================  SetCount.sql  =======================>>

This script is responsible for populating the items table with purchase counts, win counts, and win rates using data from the purchase tables.

Procedure - SetCount()

<<======================  SetCombos-X.sql  =======================>>

This script is responsible for populating the popular and synergy tables using data from the items and purchase tables.

Procedure - SetCombos()

<<======================  SetCombosF-X.sql  =======================>>

This script is responsible for populating the popular_f and synergy_f tables using data from the items and purchase tables.

Procedure - SetCombosF()

<<======================  SetChamps-X.sql  =======================>>

This script is responsible for populating the champ_win and champ_synergy tables using data from the champions, items, and purchase tables.

Procedure - SetChamps()

//==============================================================\\
||                        MySQL Tables                          ||
\\==============================================================//

<<==========================  items  ===========================>>

Stores Information on Individual Items

Column Name | Type          | Column Description
------------|---------------|-----------------------------------
ItemID      | INT           | item ID
------------|---------------|-----------------------------------
ItemName    | VARCHAR(64)   | item name
------------|---------------|-----------------------------------
AP          | INT           | value of FlatMagicDamageMod
------------|---------------|-----------------------------------
Purchase511 | INT           | number of purchases in 5.11 games
------------|---------------|-----------------------------------
Win511      | INT           | number of wins in 5.11 games
------------|---------------|-----------------------------------
Rate511     | DECIMAL(5,4)  | win rate in 5.11 games (win/purchase)
------------|---------------|-----------------------------------
Purchase514 | INT           | number of purchases in 5.14 games
------------|---------------|-----------------------------------
Win514      | INT           | number of wins in 5.14 games
------------|---------------|-----------------------------------
Rate514     | DECIMAL(5,4)  | win rate in 5.14 games (win/purchase)
------------|---------------|-----------------------------------

PRIMARY KEY : ItemID

<<========================  champions  =========================>>

Stores Static Champion Information

Column Name | Type          | Column Description
------------|---------------|-----------------------------------
ID          | INT NOT NULL  | champion ID
------------|---------------|-----------------------------------
Name        | VARCHAR(127)  | champion key
------------|---------------|-----------------------------------

PRIMARY KEY : ID

<<=================  players511 / players514  ==================>>

Stores Information on Players from 5.11 / 5.14 Games

Column Name | Type          | Column Description
------------|---------------|-----------------------------------
PlayerPK    | INT           | primary key assinged to the player
------------|---------------|-----------------------------------
GameID      | INT           | game ID
------------|---------------|-----------------------------------
TeamID      | INT           | 100 or 200
------------|---------------|-----------------------------------
ChampID     | INT           | champion ID
------------|---------------|-----------------------------------
Winner      | BOOLEAN       | 1 - won the game, 0 - lost the game
------------|---------------|-----------------------------------
Ranked      | BOOLEAN       | 1 - ranked game, 0 - normal game
------------|---------------|-----------------------------------

PRIMARY KEY : PlayerPK

<<===============  purchases511 / purchases514  ================>>

Stores Information on Individual Items in the Players' Inventory from 5.11 / 5.14 Games

Column Name | Type          | Column Description
------------|---------------|-----------------------------------
PurchasePK  | INT           | primary key assigned to the purchase
------------|---------------|-----------------------------------
PlayerFK    | INT           | foreign key from the table of players
------------|---------------|-----------------------------------
ItemID      | INT           | item ID
------------|---------------|-----------------------------------
ChampID     | INT           | champion ID
------------|---------------|-----------------------------------
Winner      | BOOLEAN       | 1 - won the game, 0 - lost the game
------------|---------------|-----------------------------------
Ranked      | BOOLEAN       | 1 - ranked game, 0 - normal game
------------|---------------|-----------------------------------

PRIMARY KEY : PurchasePK

<<====================  synergy / popular  =====================>>

Stores Information on Item Combinations that produce High Win Rate / are Commonly Purchased
Stores Top 5 Combinations for Each Item
Contains a Filter that Requires a Minimum of 50 Purchases to Qualify for Meaningful Win Rate

Column Name | Type          | Column Description
------------|---------------|-----------------------------------
ItemID1     | INT           | ID of the original item
------------|---------------|-----------------------------------
ItemID1     | INT           | ID of the item paired with the original item
------------|---------------|-----------------------------------
AP1         | INT           | value of FlatMagicDamageMod for the original item (currently unused)
------------|---------------|-----------------------------------
AP2         | INT           | value of FlatMagicDamageMod for the item paired with the original item (currently unused)
------------|---------------|-----------------------------------
Purchase511 | INT           | number of purchases in 5.11 games
------------|---------------|-----------------------------------
PRate511    | DECIMAL(5,4)  | purchase rate in 5.11 games (combination/original)
------------|---------------|-----------------------------------
Win511      | INT           | number of wins in 5.11 games
------------|---------------|-----------------------------------
WRate511    | DECIMAL(5,4)  | win rate in 5.11 games (win/purchase)
------------|---------------|-----------------------------------
Purchase514 | INT           | number of purchases in 5.14 games
------------|---------------|-----------------------------------
PRate514    | DECIMAL(5,4)  | purchase rate in 5.14 games (combination/original)
------------|---------------|-----------------------------------
Win514      | INT           | number of wins in 5.14 games
------------|---------------|-----------------------------------
WRate514    | DECIMAL(5,4)  | win rate in 5.14 games (win/purchase)
------------|---------------|-----------------------------------

<<==================  synergy_f / popular_f  ===================>>

Stores Information on Item Combinations that produce High Win Rate / are Commonly Purchased
Stores All Combinations for Each Item

Column Name | Type          | Column Description
------------|---------------|-----------------------------------
ItemID1     | INT           | ID of the original item
------------|---------------|-----------------------------------
ItemID1     | INT           | ID of the item paired with the original item
------------|---------------|-----------------------------------
AP1         | INT           | value of FlatMagicDamageMod for the original item (currently unused)
------------|---------------|-----------------------------------
AP2         | INT           | value of FlatMagicDamageMod for the item paired with the original item (currently unused)
------------|---------------|-----------------------------------
Purchase511 | INT           | number of purchases in 5.11 games
------------|---------------|-----------------------------------
PRate511    | DECIMAL(5,4)  | purchase rate in 5.11 games (combination/original)
------------|---------------|-----------------------------------
Win511      | INT           | number of wins in 5.11 games
------------|---------------|-----------------------------------
WRate511    | DECIMAL(5,4)  | win rate in 5.11 games (win/purchase)
------------|---------------|-----------------------------------
Purchase514 | INT           | number of purchases in 5.14 games
------------|---------------|-----------------------------------
PRate514    | DECIMAL(5,4)  | purchase rate in 5.14 games (combination/original)
------------|---------------|-----------------------------------
Win514      | INT           | number of wins in 5.14 games
------------|---------------|-----------------------------------
WRate514    | DECIMAL(5,4)  | win rate in 5.14 games (win/purchase)
------------|---------------|-----------------------------------

Notes :
The original design used the synergy / popular tables, which stores the minimum number of records.
Storying minimum number of records should produce faster performance when populating the tables due to less insertions.
Storying minimum number of records should produce faster performance when reading from the tables due to simpler select statements with less conditions.

However, the filter on minimum purchase count to produce meaningful win rates turned out to be difficult to callibrate.
synergy_f / popular_f were created as the "full" versions of the original tables, containing all records before filtering.
The filter is now applied during content generation, which allows developers to experiment with different filters without having to repopulate the database.

<<================  champ_win / champ_purchase  ================>>

Stores Information on Champion+Item Combinations that Produce High Win Rates / are Commonly Observed
Stores Top 5 Combinations for Each Item
Contains a Filter for a Minimum of 50 Purchases to Qualify for Meaningful Win Rate

Column Name | Type          | Column Description
------------|---------------|-----------------------------------
ItemID      | INT           | item ID
------------|---------------|-----------------------------------
ItemID1     | INT           | champion ID
------------|---------------|-----------------------------------
Purchase511 | INT           | number of purchases in 5.11 games
------------|---------------|-----------------------------------
PRate511    | DECIMAL(5,4)  | purchase rate in 5.11 games (purchase/champion)
------------|---------------|-----------------------------------
Win511      | INT           | number of wins in 5.11 games
------------|---------------|-----------------------------------
WRate511    | DECIMAL(5,4)  | win rate in 5.11 games (win/purchase)
------------|---------------|-----------------------------------
Purchase514 | INT           | number of purchases in 5.14 games
------------|---------------|-----------------------------------
PRate514    | DECIMAL(5,4)  | purchase rate in 5.14 games (purchase/champion)
------------|---------------|-----------------------------------
Win514      | INT           | number of wins in 5.14 games
------------|---------------|-----------------------------------
WRate514    | DECIMAL(5,4)  | win rate in 5.14 games (win/purchase)
------------|---------------|-----------------------------------

//==============================================================\\
||                    Additional Discussions                    ||
\\==============================================================//

<<===================  Combination Analysis  ====================>>

These analysis is driven by a very simple notion.  Every component in the game is only a part of a larger system.  The way an item interacts with other items is as significant as its individual behavior, if not more.  This concept has influenced numerous design decisions and can be applied to provide various in-depth information.  Below are a few examples.

The list of items on the landing page contains only items that provides AP.  This is because the analysis is targetted at changes in the usage of AP items.  However, the combinations in the popularity and synergy analysis does not require the second item to provide AP.  This is intended to produce a snap-shot of how the targetted item interacts with all other items in the game. This can provide insights on questions such as "is this item most successful on full-ap builds or tanky builds" or "how efficient is it to purchase a Guardian Angel on an AP carry".

Another piece of information these combination analysis can provide is the relative resource requirement of these items.  For example, suppose an item shows incomplete items such as Amplifying Tome or Blasting Wand as popular combinations while the combinations that produced high win rates are mostly other items that are fairly expensive.  This may suggest that rushing this items can cause the player to fall behind and therefore unable to maintain the income necessary to finish other items.  However, it synergizes very well with other items when purchased after a player has completed his or her core build.

<<=======  Purchasing Multiple Copies of the Same Item  =========>>

The current calculations allows a single player to generate a purchase count that is higher than 1 in a single game by purchasing multiple copies of the same item.  Performing the count on DISTINCT(PlayerFK) instead of PurchasePK would prevent a single player from generating more than 1 entry in a single game.  However, this was not performed because purchasing multiple copies of the same item is a unique behavior that deserves to be taken into account.  For example, if players are consistently purchasing multiple copies of an item, the developers may want to evaluate whether they should limit how efficiently this item stacks with itself.  Past examples of this behavior includes the season 1 Phantom Dancers as well as the old Black Cleaver that fully stacked with itself.

<<= Filter on Minimum Purchase Count for Meaningful Win Rates ==>>

This is a tricky design decision. In the most extreme scenario, even if a combination has a "true" win rate of 0.01%, it can still appear as 100% if only 1 purchase of it was recorded and that happened to be the game when it won.  However, first choice is between putting the filter on a flat purchase count or a minimum purchase rate.

The arguement for a filter that requires a minimum purchase count is as follow.  A combination can have a very high win rate with a very low purchase rate if the players are simply not aware of its effectiveness.  This is especially relevant for catching potentially over-powered combinations that are unintended by the developers and discovered by a small portion of the player base.

The arguement for a filter that requires a minimum purchase rate is as follow.  If a combination is rarely purchased, its presence could be triggered by an unaccounted factor that is having an impact on the win rate.  For example, players are often known to adopt inefficient builds when they known they'll win the game.  This includes buying a Zhonya's Hourglass on an AD champion after being ahead enough, buying a BF Sword as the last item on an AP champion to push after a team fight, or high MMR players purposefully using a inefficient build on their alternate account.  In these cases, the high win rate is not a result of the item combination, even if the 2 are correlated.

After choosing between flat count and rate, the actual threshold on the filter is also very crucial.  A threshold that is too low will not serve any purpose.  A threshold that is too high can overpower the criteria on win rate and return a result set that is equivalent to the popularity analysis.  In truth, this is the biggest weakness of the filter on flat count.  With a large enough dataset, a filter on flat count can have a high enough threshold where the result set is worth examining regardless of what other factors are in play.  However, on smaller datasets, this is very sensitive having a threshold that is too high.  This is why the current implementation uses a filter on rate.

<<= Minimum Record Tables for Synergy / Popularity versus Full =>>

The tables with minimum records has better performance all around if the developers are certain on the filter choice.
Otherwise, the tables with full records is an acceptable neccessity.  They are the expected solution for development and testing environments.
For a truely deployed production environment, tables with minimum records should be used.

<<========================  Game Count  =========================>>

Comparing the change in win rate, or any other information on rates, between 5.11 and 5.14 is straight forward.  Comparing actual purchase count between 5.11 and 5.14 is only meaningful if the dataset contains the same number of games from 5.11 and 5.14.