Giter Site home page Giter Site logo

tictactoe-demo-app's Introduction

About this codebase

This is an example of how to write an API using Django views to implement a public tic-tac-toe service.

For now, please don't copy it or run it yourself unless you have my permission. Lincoln and Drew have my permission!

Overview and structure

  • This is a Django project, with one Django app embedded.

  • If you read the Django project's settings, you'll see there is no database and most default features of Django such as CSRF protection and the ability to locate templates have been disabled. Tread carefully, and feel free to enable Django features as-needed.

  • As you edit the codebase, run the tests with:

bash run_tests.sh
  • Dependencies are defined in requirements.txt. The run_tests.sh script assumes you will create a virtualenv in env/.

  • Most code changes will be done in tttproject/tttapp/gamelogic.py.

Tic-tac-toe implementation notes

  • This implementation treats a board state as string.

  • It uses minimax to find the best move to take. It is somewhat slow and redoes a large amount of work. Look for TODOs if you need to optimize for performance.

Data validation notes

  • Data is validated directly in the Django view function.

Testing notes

  • Currently, unit tests only cover the underlying gameplay, rather than also covering the HTTP (Django) views. If you re-add tests for the Django views, you probably will need to add a DATABASES value so that the Django test runner can use the test database. Alternatively, you may be able to use a RequestFactory and pass that to the Django view function.

Try the online demo

There is a demo instance available at https://aqueous-dawn-16235.herokuapp.com/.

Try it with this sample board: https://aqueous-dawn-16235.herokuapp.com/?board=+++++++++.

tictactoe-demo-app's People

Contributors

paulproteus avatar

Watchers

 avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.