EPIC Game Challenge

Looking to expand your Python skills? Want to put everything you’ve learned in 1D04 into something you can play and share with friends? Join the EPIC Game Challenge! The Game challenge runs twice a year and gives students the opportunity to create a Python based game to submit for competition. Your IAI’s, TA’s, and other students will attempt to complete these submissions at the end of the term.

Getting Started

Be ready to get creative and get your game on! Making a game in Python can seem intimidating at first but with the skills you already have and some extra research you too can make a fun and interactive game!

A great resource to start off on is PyGame, a library with extensive documentation that makes Python game making easier by laying down a foundation for you to work off. Check out the PyGame website to download the library and learn more!

Note:
PyGame offers a lot of graphic capability which can be intimidating but do not feel like you need to make a game that has complex graphics for it to be good. A text-based game can be just as fun and innovative, and often can be equally or more complex in terms of how the user experiences the game!

Submitting a Game and Deadline

Think you have the next best game? Want to share your game and compete with other students to win the challenge? Submit your entries via email with the subject “Epic Game Challenge” to the EPIC IAI at jamiecounsell@me.com.

Submission deadline is December 1, 2014.
Those from last semester can still submit! If any students are looking for assistance on where to start, you can contact me to arrange a short tutorial.

The EPIC Lab

Hey folks,

Since 1D04 is weighted higher than your other courses, it is important to achieve a good grade. Some students are struggling with the major lab content, and all students could use a little extra help and bonus marks.

The McMaster Epic Lab provides opportunities for students to work hands-on with some pretty sweet technology, learning about Python and seeing their work come to life in a variety of projects. For every lab you complete, you also get a 1% bonus on your final grade. Students that do all four Epic labs can get up to 4%. That’s almost a full grade point!

 

Makeup Lab Sessions

Makeup labs are available for students whose timetable conflicts with the normal EPIC time slots. There will be one makeup lab session for each of the EPIC labs (starting with Android Tablets). Please note that only required courses for engineering 1 will be considered a valid conflict, and all students attending a makeup lab session must have previously contacted Jamie for approval. Any students attending or registering for the lab without previously contacting Jamie will not be permitted to participate in the makeup lab session. Additionally, the makeup labs are scheduled on a first come, first served basis; so please consider all conflicts in advance.

 

How to Sign-Up for a time slot

  • Follow one of the links below to a project you’d like to do.
  • You will be asked to log in, or create a login name if this is your first visit.
  • To create an account you will require a valid McMaster email. (students will be required to confirm this through a link sent to their email address)
  • You will then be presented with a detailed schedule view
  • A confirmation e-mail will be sent for any bookings you make.
  • If you can’t make a lab that you have scheduled, please delete your booking or contact me.

 
NOTE:

  • Each student can only have one booking per project (This means you can only sign up once for the three weeks this project runs!)
  • You cannot change or delete your appointment less than 12 hours before the scheduled lab time
  • You cannot add a booking more than three weeks in advance
  • There is space for 24 students per time slot, and you will be working in groups of three. If you wish to work with your friends, please ensure you all sign up for the same time slot.

 

The Projects

Android Tablets   [Sept 11th – Oct 1st]

android-sidepic

In this project, you will be using Python to write two apps for Android tablets. Programming is done directly on the tablet. You will:

  • Learn about webservices
  • Utilize an API

Sign up here!


Scribbler Robots   [Oct 2nd – Oct 22nd]

scribbler-sidepic

In this project, you will be programming a small robot to complete several tasks, such as:

  • Drawing shapes
  • Exploring the environment
  • Processing images from a camera
  • Detect Objects

Sign up here!

Fischertechnik Kits   [Oct 23rd – Nov 14th]

fischer-sidepic

In this project, you’ll be programming an industrial automation robot. You will:

  • Detect color
  • Sort blocks based on color
  • Sign up here!

    First Year Gear

    Hey folks, I’ve noticed that textbooks and other gear (iClickers, calculators, etc.) are the subject of many questions. I’ve written a quick guide on how to make sure you’ve got everything you need without burning a McMaster sized hole in your wallet.

    1   Textbooks

    Textbooks are an important part of first year, and also a very expensive part. Since there are ~1000 first year engineering students, textbooks are necessary to ensure everyone has an understanding of (or at least the resources to understand) the curriculum. That being said, Where do your textbook dollars go?not all students need to purchase textbooks from the campus bookstore. In fact, I recommend that you do not. According to Titles, the McMaster on-campus bookstore, the publisher receives about 80% of the cost. The rest of the cost is quotes as operation costs, and student services. See the fancy pie graph for a less numerical explanation. Though I believe the dollar amount received by the publisher might be a little high, it doesn’t really matter. A lot of books are available directly from the publisher, so this should theoretically save you at least 20%. There are a lot of ways that you can save time and money getting your textbooks. It is also probably good to note that you do not need textbooks the first day of class. In fact, most students I talk to find they don’t need the textbooks until several classes (sometimes even two weeks) in. Don’t be in a hurry to buy the books, unless you’re planning on getting ahead!

    Know Your Options

    There are many different buying options than the on-campus bookstore. In fact, one of the reasons textbooks are so expensive is because students continue to purchase the books from the campus store at such a high price. The most common alternatives are buying online, buying used, and buying at the Book Swap. There are also legends of easy-to-find digital copies of every first year textbook, but I can’t be sure.

    Buying On Campus

    As I mentioned before, the McMaster bookstore known as Titles will have everything you need. However, in the first few weeks, the campus bookstore will have a line of over one hundred students trying to get their textbooks. This can result in hours of waiting to even get into the store. In the latter part of the rush, the store is often out of stock on common items like iClickers, forcing students to leave without having everything they need. In first year, when you’re busy with class and everything else, this can be a major inconvenience. If you plan on buying textbooks from the store, be aware of this and make the time.

    Buying Online

    Online textbooks will often be cheaper, and can be purchased new or used. One of the most common ways to buy textbooks is through Amazon. Amazon offers a huge selections of textbooks and gives a good description of the book’s edition and condition. Additionally, McMaster students are eligible to receive six months of Amazon Prime. Activate this before you buy your textbooks, and you won’t have to pay for shipping (on Prime eligible books). If you’re looking to activate Prime, you can help me out by using my affiliate link to sign up. Some books I’ve found on Amazon can be as low as 20% the price of buying from the bookstore. Even if you don’t buy online, I recommend at least checking it out so you can see how low textbooks can be priced.

    Buying Used

    Throughout the year, there are always offers and ways to find textbooks around campus. There are several Facebook groups dedicated to the sale of used textbooks, and there’s almost always someone looking to sell first year engineering textbooks, if you’re willing to go looking. If you’re buying used, I highly recommend the Book Swap.

    The Book Swap BOOK SWAP

    The Book Swap is probably the best way for you to get your first year engineering textbooks. “Why is this at the bottom then, Jamie?” Because even though I think this is the best method, you should always know all your options first. The Book Swap is hosted every term, and encourages upper-year students to come sell their books to those who need it. A great place to get everything you need, but there will always be a limited quantity, and is subject to participation. More information about the Book Swap will be available by the time you need it!

    2   Equipment

    There is some equipment you will need for first year. This includes (but is not limited to) an iClicker, calculator, lab coat, and goggles. All of this equipment is available new and used as well. It is important to note that you will need everything listed above. Do not enter a lab without the proper equipment, and do not bring an unauthorized calculator to a test or exam.

    The iClicker Problem

    Almost every year, Titles runs out of iClickers. When this happens, students are unable to participate in “mandatory” in-class quizzes and participatory elements of some classes. Don’t worry. Professors understand this situation are accommodate those who are unable to receive an iClicker. If you are one of the students who has an iClicker, do not share it with other students, as this is treated as academic dishonesty. In time, Titles will receive more units, and all students will be able to participate in these quizzes.

    Calculators

    The official McMaster calculator is the Casio FX 991. There are several versions of these, but I recommend the MS, as it is technically the calculator quoted by McMaster (or at least, it was in my first year). Other versions of the FX 991 are allowed, and I’ve never seen a student have any problems with their calculator so long as it says FX 991 on it.

    Surviving Eng 1

    So I’ve had a few people express interest in a “how to survive engineering 1″ tutorial. Here it goes! Keep in mind that all of these tips are just an opinion, and they should – as any other advice you receive – be taken lightly. I’ll start with some more common questions, and will include some personal advice I have found to be useful in my time as a student and as a developing professional. I’m going to continue updating this based on student feedback, so please let me know if I’ve missed anything!

    1.   Picking Courses

    For most first years, there will be choices to make when it comes to scheduling and electives. There are really only two things that I think are vital to your success. The first is to avoid 8:30am classes as much as possible. It doesn’t matter if you’re a “morning person”. Trust me. That being said, if you do end up with 8:30am classes (which you likely will), you should go. The second is to ignore all advice on which electives you should take. Don’t look for bird courses, and don’t look for courses that a friend of a friend said was good. Read about the electives, and take them based on your interest. You will succeed in things that you are passionate about. Be aware of the affect a course can have on your opportunities, such as first year economics being a good idea for anyone wanting to get into Engineering and Management.

    Make sure you’re taking all the courses you need! Check out the list below for Engineering 1 required courses, and see what your timetable is going to look like. (Please disable Adblock. Support McMaster’s developers)

    Required Courses for Engineering I

    2.   Get Involved (But Know Your Limits)

    Reach out to other people. Join a club, pick up a hobby, or get involved with a charity, NGO, or student group. These all allow you to develop as an individual, while giving you a break from your normal routine. That being said, many students can commit too much. This both can affect your studies, and can end up being a cause of stress. If you find yourself in this position, don’t be afraid to back out. Your success comes first.

    Edit: (Thanks, Marko Maric)
    It is important to note that some clubs and on-campus groups require minimal commitment. These are more casual clubs and can be joined easily, requiring minimal commitment. There are some clubs that require regular participation (weekly, twice weekly, and even daily). These clubs are much more involved, and some require this participation to maintain membership. Be careful when selecting a club, and make sure you’re aware of how much time you will need to put in. The more serious clubs are generally for those who really want to submit their time to the practice.

    3.   The Hardware

    This is slightly out of place, but I have a lot of students ask about what computer they should purchase for university. Here’s my two cents. (Disclaimer: I am a developer and a Mac OSX user)

    Laptop or Desktop?

    Laptop. Mobility is more important than power.

    PC or Mac?

    Here’s where things get a little more complicated, and I recommend you look a little further than first year before making up your mind. PCs are powerful and low-cost, but are generally known to have a wider range of issues, since there are hundreds of hardware manufacturers and purchase options for machines running Windows. Macs are more expensive, but are better for some programs, due to the fact that they operate in a Unix environment. Due to the size of my explanation, I have included further details at the end of this post.

    Brand

    Brand matters. Here’s a list of the brands that I trust and avoid. Please remember that this is just my opinion, based only on personal experience.

    Avoid: Acer, HP, Sony, Dell, LG, Alienware
    Trust: Apple, Samsung, ASUS, Lenovo

    4.   Eat, Sleep Repeat

    Seriously. If there is one piece of advice that really matters, it’s this. Eating and sleeping are incredibly important [1]. All-nighters will happen, and food will be scarce at 4am while living on residence, but always make sure you prepare ahead for both. I had several friends in first year that failed to maintain a healthy sleep and eating schedule, and all suffered academically as a result.

    5.   Work Together

    Do not confuse this with “share answers” or “sit at a library and pretend you’re all working”. Find people that you connect with, and work with ones that encourage you to do better. Look for people with different skills than you, and learn from each other. Class will not teach you everything you need to know, especially at 8:30am. Therefore, keep yourself surrounded by people with similar work habits (or better). This will not just help you in first year. This will help you forever.

    6.   Learn Conflict Resolution Skills

    In the real professional world, there is no room for ego. You will be faced with many different types of people, and you will not always get along so easily with them. There are many ways to get around this, and to allow yourself to work with people that you otherwise would not get along with. It may sound weird now, but I promise you will benefit from it for the rest of your life. Too often I see new students struggling to work with each other, their professors, and their administrators. Don’t let this get in the way of your learning.

    6.   Use Your Resources

    If you want to succeed, you will not be able to do it alone. It is crucial that you are aware of resources available to you and reach out to them whenever necessary. Here’s a list I’ve compiled of student resources. There are many more available, and if you think one should be listed, just contact me!

    Academic Assistance

    McMaster Student Success Centre (lots of resources here)
    Visit an Academic Advisor

    Student Physical/Mental Health

    Peer Support Line (Confidential phone line run by trained student volunteers)
    McMaster Wellness Centre
    McMaster PULSE Fitness Centre (on-campus gym, very cheap and convenient)
    Recommendation: Learn Meditation

    International Students

    English Language Support

    Students With Disabilities

    IMPORTANT: Register with the SAS

    Continued: Mac vs. PC

    In my opinion, PCs are most useful for those going into Mechanical engineering, as CAD software (like the one you will use in first year) is seldom available on Unix machines. I have also heard they are more common in Chemical, Materials, and Engineering Physics, thought I have very little experience with these departments. PCs are upgradable, which is especially useful if you intend to have a computer for more than three years, but the upgradability of some newer PCs tends to suffer due to their small size. If you’re going the PC route, brand matters. It also matters where you buy it. Best Buy is a great place to buy a PC and get a decent warranty on it. Ask about their service plan in store. See below for brand recommendations.

    If you plan on going into Software, Mechatronics, Electrical, or CS, I highly recommend a Unix machine. This can either be a Mac, or a PC running (or dual booting) Linux. This is because any development you do should be done inside a Unix environment. PCs simply aren’t meant for development (unless you’re developing in Microsoft’s .NET or otherwise). Macbook’s are always a good Unix option, because they are much easier to become familiar with than Linux, come with a suite of applications for the average user, and have an incredible support system through Apple Care (which I highly recommend on any new purchase). Keep in mind that MacBooks will require a Bootcamp partition or an alternative for first year. For new Linux users, I would recommend Ubuntu or Mint. Both are Debian distros at their core, and will help you become familiar with Linux without sacrificing usability.

    Resources

    [1] June J. Pilcher and Allen I. Huffcutt, Effects Of Sleep Deprivation On Performance: A Meta-Analysis, Vol 19 (4) ed. , Journal of Sleep Research & Sleep Medicine, 1996.

    Objects and Classes (Tutorial 11)

    Introduction

    Objects can be one of the most difficult programming concepts to understand. Once it clicks, however, it really clicks. I recommend you read and pay close attention to the textbook, and utilize your resources until you understand objects and classes, as your upcoming evaluation will rely heavily on your understanding of these concepts.

    Before you begin, please read the Python documentation 9.2. Python Scopes and Namespaces.
    This stuff messes a lot of people up during major labs!

    Let’s get started.

    A Metaphor

    Classes are like a blueprint. They describe the traits and actions of something. Let’s look at a real life example, using a car.

    To generalize our example, we will define a car as a vehicle with four wheels and an engine. We know, however, that some cars are different. Some are different colours, or seat more passengers. Our class describes the object in general. For example:

    Class: Car

    The class definition of colour simply states:
      The car has a colour.

    And for our number of passengers:
      The car seats some number of passengers.

    Objects are created using the “class” blueprints. So, let’s say we want to build a blue car that seats 5 people. We can then fill in the blanks from our class design to create the object defined as having the colour blue, and room for 5 passengers. We’ll call this car something different than the class name. This is because we want it to be identifiable. We’ll call it MyCar.

    Formal Definition

    To stick with the terms you’ll be required to know, here’s a formal definition of what we just described. Read it slowly and make sure you understand it!

    “MyCar” is an object. This object is an instance of the class “Car”. The class defines two attributes, colour, and number of passengers. Both of which can be defined specifically for each instance of “Car”.

    Class Definition

    Here’s the basic Python syntax for defining a class:

    # Simple class definition
    class ClassName:
        <statement 1>
        .
        .
        .
        <statement N>
    

    There are a few different types of statements that we will use to create our class. I’m going to try to cover all the “types” of statements, but there are many different applications for these, which I will leave up to you.

    Defining Attributes

    In our car example, we decided that every car needs a colour. This colour can (though it does not have to be) be unique for each instance of “Car”. When we initialize an object with certain data, that is called an Attribute.

    An Attribute is a piece of data that describes the object. Since our class definition just gives us a blueprint for the object, we need to define attributes to describe the specific instance of the class in a bit more detail.

    Attributes are usually defined when we create the object. This is done using Python’s special initialization function “__init__“. (TWO underscores before and after the word “init”)

    The __init__ function is called once when the object is first created and takes a few arguments. One is “self”, which always comes first, and we will discuss later. The other two are the parameters that we will be using to specify colour and the number of passengers that the car holds.

    When we save attributes, we want to assign them to “self”. This is because of the way that Python handles objects. We can think of it as the actual object running the code. Therefore, when we give it a colour, it has to think:
        “Hey, this is MY colour, I’ll save it for my self.

    class Car:
        def __init__(self, colour, numOfPassengers):
            # This is my colour
            self.colour = colour
            # This is my numOfPassengers
            self.numOfPassengers = numOfPassengers
    
    Accessors (Get Methods)

    Once we’ve stored attributes, we will often need to get them back from the object. In the Vector example you’ve seen in lab, you need to be able to get the x and y coordinates to really make use of the class. Therefore, you will need to create a method that returns the values you’ll need to work with. We’ll apply this to our Car example, noting that we might need to check the colour of the car, or the number of passengers it seats.

    class Car:
        def __init__(self, colour, numOfPassengers):
            # This is my colour
            self.colour = colour
            # This is my numOfPassengers
            self.numOfPassengers = numOfPassengers
    
        # GET methods
        def getColour(self):
            return self.colour
        def getNumOfPassengers(self):
            return self.numOfPassengers
    

    Now how do we use these functions? The syntax for Objects and their methods is extremely important. Please make sure you understand this!

    In general, the syntax for an object’s instance is:

    Object.Method(arguments)
    

    This calls Method from Object’s Class description, and passes it the arguments if necessary. Self is always passed first, and this is done automatically. Do not pass it in, Python will handle that.

    Defining Functions

    Depending on your object class, you will often need it to perform more actions. This can be done by defining additional functions in the same way as we did above. These functions can do anything! They’re just like normal functions, but must still take in “self” in order to operate correctly. The syntax for all functions you will define in an object is:

    class Object:
        def Function(self, arg1, arg2... argN):
            # Do something
    

    “self” is determined when you call the function as follows:

    anObject = Object()
    
    #[-self--][method][-arguments--------]
     anObject.Function(arg1, arg2... argN)
    

    So if our function does anything to “self”, it is actually performing this action on the instance “anObject”. I’ve decided to go a bit more in depth about the “self” concept. It continues below. All you need to know is how to define object functions, and how to call them properly using Python syntax.

    The “Self” Concept

    No, this isn’t philosophy class. The concept of “self” in object oriented programming is possibly one of the most important concepts to understand. I’m going to do my best to describe it using a few methods and metaphors. Please let me know if it is unclear. Read this next part several times if you need to.

    Self is a concept used in Python to describe the “current object”. When you call an object’s method:

    myObject.myMethod(argument1, argument2)
    

    You can think of it as instructing myObject to perform the action myMethod using the variables argument1 and argument2. When Python goes to look at the code for myMethod, it goes straight to the Class definition (the blueprint). If we didn’t pass “self”, Python doesn’t know which object we’re talking about. When we use “self”, the identity of myObject is passed, so when Python checks the code for myMethod, it can see myMethod is utilizing some attribute of “self”, and in turn, is utilizing some attribute of “myObject”. An example from the lab follows:

    class Vector:
        def __init__(self, x, y):
            self.x= x
            self.y= y
    

    Let’s start here.

    Python passes in “self” so that it is in our scope. Otherwise, we would get an error saying it isn’t defined. When we use the statement “self.x = x”, we are saying “the value of x specific to this object is set equal to the parameter passed in”. This is basically a way of saving information inside our objects.

    class Vector:
        def __init__(self, x, y):
            self.x= x
            self.y= y
        def getX(self):
            return self.x
        def getY(self):
            return self.y
    

    Here, we add two functions to get our X and Y values. Python automatically passes the parameter “self” based on how the function was called. For example:

    # Returns the x value from vector 1
    # In this case, self is the "vector1" object
    vector1.getX()
    
    # Returns the x value from vector 2
    # self is the "vector2" object
    vector2.getX()
    

    This helps Python determine which value of x we’re returning. Remember that “self” doesn’t come out of nowhere. It is determined outside the class when you’re actually working with the methods of an instance of that class.

    If we just told Python to “getX()”, there is no way for Python to know what we want. This will return an error, and this is exactly why we require the specific syntax for calling methods of objects:

    Object.Method(args)
    

    Hopefully this clears things up. Your textbook’s chapter on this content is really well done, and I recommend reading it (I know it’s dry, but it’s worth it, I promise!) if you’re still struggling with this understanding. Next major lab will absolutely require you to understand these concepts, so make sure you know them!