Giter Club home page Giter Club logo

text_adventure's Introduction

Practice Design Patterns through implementing a text based adventure game

This collaborative project aims at getting a feel for design patterns and what problems they try to solve.

If you're interested in joining us on this adventure, you can find us at https://codebuddies.org/ (we're in the #python and #text-adventure channels in Slack).

Instructions

First assignment

  1. Fork the code. (Or, if you've requested collaboration access in the #text-adventures channel on the CodeBuddies Slack, you can git clone the repo directly.)
  2. Checkout the 0.1 tag by typing git checkout tags/0.1.
  3. Create a new branch based on this tag by typing git checkout -b [YOUR_NAME]_character. Make your changes while in this new branch.
  4. Commit your changes. Once you're happy with your code, create a pull request -- or, if you've been added as a collaborator, simply git push up this branch. (The first time you push, you'll have to type git push --set-upstream [branchname]).

Your task is to implement the MyCharacter class found in text_adventure/entity.py. The update method contains print statements explaining how the character should behave, and Workflow.png will give you some hints on what order things should be happening in.

WARNING: This code is going to throw an exception initially - there are some things missing.
Your mission is to find and fix those items!

You can find an example of what the output might be like in expected_output.txt.

Our FIrst Design Pattern: Finite State Machine

After you've implemented your solution, check out the state_machine branch and try to see if you can rework your code following that pattern.

Hangout reportback notes

24/7 hangout link: https://codebuddies.org/hangout/9rasmyL5rp9igiDyZ

June 3rd, 2017

@dangillet:

We reviewed together the naive way of implementing the problem and then we went through the Finite State Machine pattern. It allows us to remove a level of if statements, and keep all the logic about one state in a single place.

I've pushed 2 branches. One is https://github.com/codebuddiesdotorg/text_adventure/tree/state_machine and shows the basic implementation of the State machine for Python. It could be made more formal by using an Interface Class from which all the states derive. But as Python is a dynamic language, it's not really worth the effort.

I've pushed in another branch https://github.com/codebuddiesdotorg/text_adventure/tree/alt_implementation an alternate implementation using the fact that Python being dynamic, you can change the class of the Entity dynamically to have the desired implementation depending on the current state. I would not necessarily recommend doing it this way. I've discovered it while reading the Python Cookbook, 3rd edition. http://chimera.labs.oreilly.com/books/1230000000393

What I'm going now to do is merge the state_machine branch into master. From there we decided for practice to implement one or two more states. As we will do it all differently, we will rename our class whatever we want. Currently it was MyCharacter. I would suggest you take a name describing the kind of character you're going to implement. It could be a Dog, a Vampire or whatever floats your boat. As a fun experiment we will then merge all these classes and their states together and instantiate one of each character type to see them living in the world.

After that I think we will move on to really work on the foundation of the text based adventure game.

text_adventure's People

Contributors

dangillet avatar lpatmo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  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.