Getting Started with CLOT

From Warzone Wiki
(Difference between revisions)
Jump to: navigation, search
m
Line 56: Line 56:
 
* In the Google App Engine Launcher, there's a button named Logs.  Click this to open up a window that shows information about what the app is doing.  You can write to this log in the app by calling logging.info()
 
* In the Google App Engine Launcher, there's a button named Logs.  Click this to open up a window that shows information about what the app is doing.  You can write to this log in the app by calling logging.info()
 
* test.py gives you a blank function that you can test code out in.  You can activate it by hitting the "/test" page in your browser.
 
* test.py gives you a blank function that you can test code out in.  You can activate it by hitting the "/test" page in your browser.
 +
 +
[[Category:CLOT]]

Revision as of 14:28, 24 December 2012

CLOT is a framework that allows players to create their own automated ladders or tournaments. This page walks you through how to get started making your own.

Contents

How it works

Fundamentally, CLOT is source code that powers a website. The website primarilly serves the following functions:

  • Allows players to join and leave the CLOT
  • Creates games between players who have signed up to the CLOT
  • Determines and displays the state of the tournament or ladder (shows player's ladder ranks or draws a tournament bracket, for example)

The framework provided is only a skeleton that provides a very simple implementation of a ladder. It simply matches up players randomly, and gives out ranks based on who won the most games. It's expected you will modify this to implement your own system.

Google App Engine

The framework provided is set up to work under Google App Engine (GAE). GAE is a great choice for the following reasons:

  • All of the website components (database, logging, e-mail, cache, indexes, etc.) are all integrated into one package making setup and sharing of code easy.
  • GAE takes care of deployment and scaling for you, making the site practically maintenance-free.
  • It's free! As long as traffic doesn't get out of hand (which it shouldn't for a CLOT website), GAE doesn't charge anything.

If you don't want to use GAE, you can always port CLOT to your preferred hosting environment.

Installation

This section shows you how to set up a CLOT website on your own computer so you can start developing your own.

  1. Download and install Python 2 (http://www.python.org/download/)
  2. Download and install Google App Engine SDK for Python (https://developers.google.com/appengine/downloads)
  3. Download CLOT from https://github.com/FizzerWL/CLOT (click the Zip button at the top and then extract it to a directory)
  4. Run the Google App Engine Launcher
  5. Select File -> Add Existing Application
  6. Enter the name of the directory you extracted CLOT to
  7. Select the app and click Run. Wait a moment as it starts.
  8. Click Browse to launch the website in your local browser.

That's it! You're up and running. Now you can play around with the website, crack open the code, and figure out how it all works.

Understanding the Code

The most important file of the starter code is clot.py. This contains two key functions: createGames and setRanks.

createGames is called periodically to check for new games that need to be created. The sample provided just retrieves all players in the database, figures out who isn't currently in a game, and creates Strategic 1v1s randomly between them. You should replace this function with your own logic that determines what game settings and player configurations should be used.

setRanks is also called periodically to update each player's rank. The sample provided just counts how many wins each player has had and then gives players ranks based on their number of wins. This is the simplest ladder ranking algorithm, but you can plug your own in. If you're making a tournament, you might not need this function at all.

There's a templates subdirectory that defines all of the html that powers the website. base.html defines the overall look and feel of the site. It's a good idea to edit the <title> element here to give your site its own name.

There's a static subdirectory that defines files that never change. Here you can place things like images you want to host. You'll probably want to adjust the stylesheet here to give your site its own look and feel.

Another file to check out is urls.py. This defines how web addresses map to the different Python files. If you want to add a new page, this is where you'll do it.

cron.py is called every 6 hours. This is what calls createGames and setRanks, but it also does some other maintenance as it checks for games that have recently finished.

Development Tips

  • In the Google App Engine Launcher, there's a button named SDK Console. Under the SDK Console, you'll see the Datastore Viewer which lets you view and manipulate what's stored in the CLOT database.
  • In the Google App Engine Launcher, there's a button named Logs. Click this to open up a window that shows information about what the app is doing. You can write to this log in the app by calling logging.info()
  • test.py gives you a blank function that you can test code out in. You can activate it by hitting the "/test" page in your browser.
Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox