cs/info 4154 · beta postmortems similar to alpha postmortems report something learned from...

39
CS/INFO 4154: Analytics-driven Game Design SQL Class 20:

Upload: donga

Post on 12-Aug-2019

218 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: CS/INFO 4154 · Beta Postmortems Similar to Alpha postmortems Report something learned from analytics perfectly fine if not very insightful e.g. players clicked 5436 times!

CS/INFO 4154:Analytics-driven Game Design

SQL

Class 20:

Page 2: CS/INFO 4154 · Beta Postmortems Similar to Alpha postmortems Report something learned from analytics perfectly fine if not very insightful e.g. players clicked 5436 times!

Final Course Deadlines We will not meet during the scheduled exam time Final report will be due at the end of exam time Cornell cannot delete exam from Student Center Final (Kongregate) Report due: Saturday,

December 9th, NOON Final Peer Evaluations due: Monday, December

11th, 11:59pm

Page 3: CS/INFO 4154 · Beta Postmortems Similar to Alpha postmortems Report something learned from analytics perfectly fine if not very insightful e.g. players clicked 5436 times!

Mon Wed Fri

10/11MySQL

10/13Beta Playtesting 1

10/16Beta Playtesting 2

10/18Beta Postmortems

10/19: Midterm Peer Evaluations Due

Page 4: CS/INFO 4154 · Beta Postmortems Similar to Alpha postmortems Report something learned from analytics perfectly fine if not very insightful e.g. players clicked 5436 times!

Beta Postmortems Similar to Alpha postmortems Report something learned from analytics

perfectly fine if not very insightful e.g. players clicked 5436 times!

Page 5: CS/INFO 4154 · Beta Postmortems Similar to Alpha postmortems Report something learned from analytics perfectly fine if not very insightful e.g. players clicked 5436 times!

Today Basic MySQL How the tables are implemented on GDIAC Open office hours

Page 6: CS/INFO 4154 · Beta Postmortems Similar to Alpha postmortems Report something learned from analytics perfectly fine if not very insightful e.g. players clicked 5436 times!

Today Basic MySQL How the tables are implemented on GDIAC Open office hours

Page 7: CS/INFO 4154 · Beta Postmortems Similar to Alpha postmortems Report something learned from analytics perfectly fine if not very insightful e.g. players clicked 5436 times!

SQL Structured Query Language a programming language designed to manage data

stored in relational databases

Page 8: CS/INFO 4154 · Beta Postmortems Similar to Alpha postmortems Report something learned from analytics perfectly fine if not very insightful e.g. players clicked 5436 times!

SHOW TABLES Shows tables within current database

mysql> SHOW TABLES;

+----------------------------+| player_action_log || player_pageload_log || player_quest_log || users |+----------------------------+4 rows in set (0.00 sec)

Page 9: CS/INFO 4154 · Beta Postmortems Similar to Alpha postmortems Report something learned from analytics perfectly fine if not very insightful e.g. players clicked 5436 times!

Sample table: actionsplayer_id quest_id action_id time detail0 0 0 14 (2, 2)0 0 1 16 (2, 4)0 0 2 19 (1, 3)0 1 2 20 (1, 1)1 0 2 78 (2, 1)1 1 2 80 (3, 8)

Page 10: CS/INFO 4154 · Beta Postmortems Similar to Alpha postmortems Report something learned from analytics perfectly fine if not very insightful e.g. players clicked 5436 times!

DESCRIBE Tells you the table schema Example:

DESCRIBE actions;important

+-----------+--------------+------+-----+---------+-------+| Field | Type | Null | Key | Default | Extra |+-----------+--------------+------+-----+---------+-------+| player_id | int(11) | YES | | NULL | || quest_id | int(11) | YES | | NULL | || level_id | int(11) | YES | | NULL | || time | int(11) | YES | | NULL | || detail | varchar(255) | YES | | NULL | |+-----------+--------------+------+-----+---------+-------+

Page 11: CS/INFO 4154 · Beta Postmortems Similar to Alpha postmortems Report something learned from analytics perfectly fine if not very insightful e.g. players clicked 5436 times!

SELECT The basic query

SELECT <attributes>FROM <one or more tables>;

Page 12: CS/INFO 4154 · Beta Postmortems Similar to Alpha postmortems Report something learned from analytics perfectly fine if not very insightful e.g. players clicked 5436 times!

SELECTplayer_id quest_id action_id time detail

0 0 0 14 (2, 2)

0 0 1 16 (2, 4)

0 0 2 19 (1, 3)

0 1 2 20 (1, 1)

1 0 2 78 (2, 1)

1 1 2 80 (3, 8)

SELECT player_id FROM actions;player_id

0

0

0

0

1

1

Page 13: CS/INFO 4154 · Beta Postmortems Similar to Alpha postmortems Report something learned from analytics perfectly fine if not very insightful e.g. players clicked 5436 times!

DISTINCT Filters results for unique values Can be used as a keyword:

SELECT DISTINCT player_id FROM actions; Can also be used as a function:

SELECT DISTINCT(player_id) FROM actions;

Page 14: CS/INFO 4154 · Beta Postmortems Similar to Alpha postmortems Report something learned from analytics perfectly fine if not very insightful e.g. players clicked 5436 times!

DISTINCTplayer_id quest_id action_id time detail

0 0 0 14 (2, 2)

0 0 1 16 (2, 4)

0 0 2 19 (1, 3)

0 1 2 20 (1, 1)

1 0 2 78 (2, 1)

1 1 2 80 (3, 8)

SELECT DISTINCT player_idFROM actions; player_id

0

1

Page 15: CS/INFO 4154 · Beta Postmortems Similar to Alpha postmortems Report something learned from analytics perfectly fine if not very insightful e.g. players clicked 5436 times!

COUNT() Function that counts number of rows Usage: COUNT(<rows>) Example:

SELECT COUNT(player_id) FROM actions;

Page 16: CS/INFO 4154 · Beta Postmortems Similar to Alpha postmortems Report something learned from analytics perfectly fine if not very insightful e.g. players clicked 5436 times!

COUNT()player_id quest_id action_id time detail

0 0 0 14 (2, 2)

0 0 1 16 (2, 4)

0 0 2 19 (1, 3)

0 1 2 20 (1, 1)

1 0 2 78 (2, 1)

1 1 2 80 (3, 8)

SELECT COUNT(player_id)FROM actions; COUNT(player_id)

6

Page 17: CS/INFO 4154 · Beta Postmortems Similar to Alpha postmortems Report something learned from analytics perfectly fine if not very insightful e.g. players clicked 5436 times!

How do I?player_id quest_id action_id time detail

0 0 0 14 (2, 2)

0 0 1 16 (2, 4)

0 0 2 19 (1, 3)

0 1 2 20 (1, 1)

1 0 2 78 (2, 1)

1 1 2 80 (3, 8)

How do I get the number of unique players?SELECT COUNT(DISTINCT(player_id)) FROM actions

COUNT(DISTINCT(player_id))

2

Page 18: CS/INFO 4154 · Beta Postmortems Similar to Alpha postmortems Report something learned from analytics perfectly fine if not very insightful e.g. players clicked 5436 times!

SELECT *

player_id quest_id action_id time detail0 0 0 14 (2, 2)0 0 1 16 (2, 4)0 0 2 19 (1, 3)0 1 2 20 (1, 1)1 0 2 78 (2, 1)1 1 2 80 (3, 8)

SELECT * returns all rows Example:

SELECT * FROM actions;

Page 19: CS/INFO 4154 · Beta Postmortems Similar to Alpha postmortems Report something learned from analytics perfectly fine if not very insightful e.g. players clicked 5436 times!

WHERE Specifies constraints Example:

SELECT * FROM actions WHERE time>20;

Page 20: CS/INFO 4154 · Beta Postmortems Similar to Alpha postmortems Report something learned from analytics perfectly fine if not very insightful e.g. players clicked 5436 times!

WHEREplayer_id quest_id action_id time detail

0 0 0 14 (2, 2)

0 0 1 16 (2, 4)

0 0 2 19 (1, 3)

0 1 2 20 (1, 1)

1 0 2 78 (2, 1)

1 1 2 80 (3, 8)

SELECT * FROM actions WHERE time>20player_id quest_id action_id time detail

1 0 2 78 (2, 1)

1 1 2 80 (3, 8)

Page 21: CS/INFO 4154 · Beta Postmortems Similar to Alpha postmortems Report something learned from analytics perfectly fine if not very insightful e.g. players clicked 5436 times!

WHERE Specifies constraints Example:

SELECT * FROM actions WHERE time>20; Can combine WHERE constraints with AND:

SELECT * FROM actions WHERE time<15 AND player_id=0;

Page 22: CS/INFO 4154 · Beta Postmortems Similar to Alpha postmortems Report something learned from analytics perfectly fine if not very insightful e.g. players clicked 5436 times!

How do I?

Count # of actions with id=2?

player_id quest_id action_id time detail

0 0 0 14 (2, 2)

0 0 1 16 (2, 4)

0 0 2 19 (1, 3)

0 1 2 20 (1, 1)

1 0 2 78 (2, 1)

1 1 2 80 (3, 8)

SELECT COUNT(*) FROM actions WHERE action_id=2;

Page 23: CS/INFO 4154 · Beta Postmortems Similar to Alpha postmortems Report something learned from analytics perfectly fine if not very insightful e.g. players clicked 5436 times!

How do I?

Count # of players who had an action with id=1?

player_id quest_id action_id time detail

0 0 0 14 (2, 2)

0 0 1 16 (2, 4)

0 0 2 19 (1, 3)

0 1 2 20 (1, 1)

1 0 2 78 (2, 1)

1 1 2 80 (3, 8)

SELECT COUNT(DISTINCT(player_id)) FROM actions WHERE action_id=1;

Page 24: CS/INFO 4154 · Beta Postmortems Similar to Alpha postmortems Report something learned from analytics perfectly fine if not very insightful e.g. players clicked 5436 times!

How do I?

Count # of players who performed an action at (2,x)?

player_id quest_id action_id time detail

0 0 0 14 (2, 2)

0 0 1 16 (2, 4)

0 0 2 19 (1, 3)

0 1 2 20 (1, 1)

1 0 2 78 (2, 1)

1 1 2 80 (3, 8)

Can’t do this yet.

Page 25: CS/INFO 4154 · Beta Postmortems Similar to Alpha postmortems Report something learned from analytics perfectly fine if not very insightful e.g. players clicked 5436 times!

LIKE Specifies looser constraints:

_ matches a single character % matches any number of characters

Example:SELECT * FROM actions WHERE detail LIKE ‘(2,_)’;

Page 26: CS/INFO 4154 · Beta Postmortems Similar to Alpha postmortems Report something learned from analytics perfectly fine if not very insightful e.g. players clicked 5436 times!

WHEREplayer_id quest_id action_id time detail

0 0 0 14 (2, 2)

0 0 1 16 (2, 4)

0 0 2 19 (1, 3)

0 1 2 20 (1, 1)

1 0 2 78 (2, 1)

1 1 2 80 (3, 8)

SELECT * FROM actions WHERE detail LIKE ‘(2,_)’;player_id quest_id action_id time detail

0 0 0 14 (2, 2)

0 0 1 16 (2, 4)

1 0 2 78 (2, 1)

Page 27: CS/INFO 4154 · Beta Postmortems Similar to Alpha postmortems Report something learned from analytics perfectly fine if not very insightful e.g. players clicked 5436 times!

How do I?

Count # of players who performed an action in quest #1 at (x,8)

player_id quest_id action_id time detail

0 0 0 14 (2, 2)

0 0 1 16 (2, 4)

0 0 2 19 (1, 3)

0 1 2 20 (1, 1)

1 0 2 78 (2, 1)

1 1 2 80 (3, 8)

SELECT COUNT(DISTINCT(player_id)) FROM actionsWHERE quest_id=1 AND detail LIKE '(_,8)';

Page 28: CS/INFO 4154 · Beta Postmortems Similar to Alpha postmortems Report something learned from analytics perfectly fine if not very insightful e.g. players clicked 5436 times!

How do I…player_id quest_id action_id time detail

0 0 0 14 (2, 2)

0 0 1 16 (2, 4)

0 0 2 19 (1, 3)

0 1 2 20 (1, 1)

1 0 2 78 (2, 1)

1 1 2 80 (3, 8)

player_id player_info

0 Windows

1 Linux

actions

players

Get all actions performed on Windows?

Page 29: CS/INFO 4154 · Beta Postmortems Similar to Alpha postmortems Report something learned from analytics perfectly fine if not very insightful e.g. players clicked 5436 times!

INNER JOIN Merges tables Example:

SELECT * FROM actions INNER JOIN players ON players.player_id=actions.player_id;

Page 30: CS/INFO 4154 · Beta Postmortems Similar to Alpha postmortems Report something learned from analytics perfectly fine if not very insightful e.g. players clicked 5436 times!

player_id quest_id action_id time detail

0 0 0 14 (2, 2)

0 0 1 16 (2, 4)

0 0 2 19 (1, 3)

0 1 2 20 (1, 1)

1 0 2 78 (2, 1)

1 1 2 80 (3, 8)

player_id player_info

0 Windows

1 Linuxactions

players

SELECT * FROM actions INNER JOIN players ON players.player_id=actions.player_id;

player_id quest_id action_id time detail player_id player_info

0 0 0 14 (2, 2) 0 Windows

0 0 1 16 (2, 4) 0 Windows

0 0 2 19 (1, 3) 0 Windows

0 1 2 20 (1, 1) 0 Windows

1 0 2 78 (2, 1) 1 Linux

1 1 2 80 (3, 8) 1 Linux

Page 31: CS/INFO 4154 · Beta Postmortems Similar to Alpha postmortems Report something learned from analytics perfectly fine if not very insightful e.g. players clicked 5436 times!

player_id quest_id action_id time detail

0 0 0 14 (2, 2)

0 0 1 16 (2, 4)

0 0 2 19 (1, 3)

0 1 2 20 (1, 1)

1 0 2 78 (2, 1)

1 1 2 80 (3, 8)

player_id player_info

0 Windows

1 Linuxactions

players

SELECT * FROM actions INNER JOIN players ON players.player_id=actions.player_id WHERE players.player_info=‘Windows’;

player_id quest_id action_id time detail player_id player_info

0 0 0 14 (2, 2) 0 Windows

0 0 1 16 (2, 4) 0 Windows

0 0 2 19 (1, 3) 0 Windows

0 1 2 20 (1, 1) 0 Windows

Page 32: CS/INFO 4154 · Beta Postmortems Similar to Alpha postmortems Report something learned from analytics perfectly fine if not very insightful e.g. players clicked 5436 times!

Count the # of actions that happened on Linux at (2,x)? SELECT COUNT(*) FROM actions INNER JOIN players ONplayers.player_id=actions.player_id WHERE player_info='Linux' AND detail LIKE '(2,_)';

player_id quest_id action_id time detail

0 0 0 14 (2, 2)

0 0 1 16 (2, 4)

0 0 2 19 (1, 3)

0 1 2 20 (1, 1)

1 0 2 78 (2, 1)

1 1 2 80 (3, 8)

player_id player_info

0 Windows

1 Linuxactions

players

Count the # of unique players that played on Windows and performed an action after time=15?SELECT COUNT(DISTINCT(players.player_id)) FROM actions INNER JOIN players ON players.player_id=actions.player_idWHERE player_info='Windows' AND actions.time>15;

Page 33: CS/INFO 4154 · Beta Postmortems Similar to Alpha postmortems Report something learned from analytics perfectly fine if not very insightful e.g. players clicked 5436 times!

Today Basic MySQL How the tables are implemented on GDIAC Open office hours

Page 34: CS/INFO 4154 · Beta Postmortems Similar to Alpha postmortems Report something learned from analytics perfectly fine if not very insightful e.g. players clicked 5436 times!

Four tables

Users

Sessions

Tasks

Actions

users

player_pageload_log

player_quest_log

player_action_log

Page 35: CS/INFO 4154 · Beta Postmortems Similar to Alpha postmortems Report something learned from analytics perfectly fine if not very insightful e.g. players clicked 5436 times!

Users: users user_id user_info

user ID (automatic)user details (if you provided them)

Page 36: CS/INFO 4154 · Beta Postmortems Similar to Alpha postmortems Report something learned from analytics perfectly fine if not very insightful e.g. players clicked 5436 times!

Sessions: player_pageload_log client_timestamp log_id user_id server_timestamp game_id version_id session_id

when the client recorded the eventoverall ID; continually incrementsuser ID (automatic)when the server recorded the eventyour game IDyour version IDID for this play session (automatic)

Page 37: CS/INFO 4154 · Beta Postmortems Similar to Alpha postmortems Report something learned from analytics perfectly fine if not very insightful e.g. players clicked 5436 times!

Tasks: player_quest_log log_quest_id quest_id log_quest_ts user_id game_id version_id dynamic_quest_id quest_detail session_seq_id session_id client_timestamp level_end_timestamp

overall ID; continually incrementsID for the task/level/questwhen the server recorded the eventuser ID (automatic)your game IDyour version IDunique ID for this specific quest instancequest details (if you provided them)which task in this sessionID for this play session (automatic)when the client recorded the eventwhen the client finished the task

Page 38: CS/INFO 4154 · Beta Postmortems Similar to Alpha postmortems Report something learned from analytics perfectly fine if not very insightful e.g. players clicked 5436 times!

Actions: player_action_log client_timestamp log_id game_id quest_id user_id action_id action_detail log_timestamp session_seq_id quest_seq_id

when the client recorded the eventoverall ID; continually incrementsyour game IDID for this task/level/questuser ID (automatic)ID for this actionaction details (if you provided them)when the server recorded the eventwhich action in this sessionwhich action in this task

Page 39: CS/INFO 4154 · Beta Postmortems Similar to Alpha postmortems Report something learned from analytics perfectly fine if not very insightful e.g. players clicked 5436 times!

Today Basic MySQL How the tables are implemented on GDIAC Open office hours