Games I made in a Python class: play them

A few weeks ago I finished my third free online Coursera course: An Introduction to Interactive Programming in Python.

I enjoyed it a great deal. I used to do a lot of programming, but it’s been a long time. I’d never done Python before but didn’t find it a difficult language to get my head around.

It was challenging, though. They covered a lot in the video lectures in each of the 8 weeks, moving very quickly through topics. There were quizzes and programming assignments every week. The amount and depth of work for a free course was considerable.

It focused on interactive programs – that is, games you can play – which was sort of new for me. It was also my first foray into object-oriented programming, which is well-suited for games. This was a challenging change of mindset at first but by the end I really got into it.

We created all our games in an online tool so that we could submit them for peer gaming. You can play the games I created, if you like. Here are a couple of the later ones. After clicking each link you’ll get a screen with the code on it; click the Run button (the one in the upper left with the little arrow) to play the game. Note that these probably won’t work in Internet Explorer, but they should work in Chrome, Firefox, or probably Safari.

Pong. Yep, the game with the two paddles and the bouncy ball. This is made for two players. The player on the left uses the W and S keys to move their paddle up and down; the player on the right uses the Up and Down arrow keys to move theirs. Note that we didn’t implement complicated bounces off the corners of the paddles; the ball either bounces back if it hits the front of the paddle or counts as a miss. There’s a  button to let you restart the game and score.

Memory. This is a single-player game where you turn over two cards at a time by clicking on them with the mouse. If the two you pick match they stay turned over; if they don’t they flip back when you click the next card. The object is to try to match them all in as few clicks as you can. Again, there’s a restart button.

Blackjack. A simple version of the classic card game. A single player plays against a dealer. You can hit (get an additional card) or stand (let the dealer take some); the winner is the closest to 21 without busting (going over). Dealer wins ties, and hits as long as he’s showing less than 16. After a game finishes, hit the Deal button for a new game.

RiceRocks. A simple version of the classic arcade game Asteroids. This one took us two weeks. Single player, but with fancy images and sound (which the course supplied). Use the Left and Right arrow keys to rotate your ship, use the Up arrow key to thrust forward, and the Space bar to shoot. You have three lives. Sorry, no hyperspace or flying saucers. After playing you’ll need to hit the Reset button on the code screen (the back arrow, the last button) or close the browser tab to make the sound stop. Sorry.

There’s a lot of geeky enjoyment built into these games. Enjoy.

RiceRocks

Another Cousera course: Python

I just can’t stop taking Coursera classes. I mean, they’re free. Who doesn’t like to learn for free?

Well, you might not all like to spend your few spare hours learning a new computer programming language but that’s what I’m doing this time. I’m a couple of weeks into An Introduction to Interactive Programming in Python, and have already done two quizzes and submitted an assignment. It’s been a long time since I did proper programming but I’m really enjoying this so far.

It’s wonderfully geeky too. Our first, very simple, project involved this:

shrubbery_212

 

The second, more involved, program involved this:

Coursera: Introduction to Mathematical Philosophy

This week I started my second Coursera course: Introduction to Mathematical Philosophy.

It actually started a couple of weeks ago so I need to catch up. I’ve only done the first week but am already finding it both mentally stimulating and sort of funny.

Here’s what I’ll learn:

  1. Infinity (Zeno’s Paradox, Galileo’s Paradox, very basic set theory, infinite sets)
  2. Truth (Tarski’s theory of truth, recursive definitions, complete induction over sentences, Liar Paradox)
  3. Rational Belief (propositions as sets of possible worlds, rational all-or-nothing belief, rational degrees of belief, bets, Lottery Paradox)
  4. If-then (indicative vs subjunctive conditionals, conditionals in mathematics, conditional rational degrees of belief, beliefs in conditionals vs conditional beliefs)
  5. Confirmation (the underdetermination thesis, the Monty Hall Problem, Bayesian confirmation theory)
  6. Decision (decision making under risk, maximizing expected utility, von Neumann Morgenstern axioms and representation theorem, Allais Paradox, Ellsberg Paradox)
  7. Voting (Condorcet Paradox, Arrows Theorem, Condorcet Jury Theorem, Judgment Aggregation)
  8. Quantum Logic (orthocomplemented lattices, projections, Gleason’s Theorem, probability and logic)

Image

Coursera: Data Analysis complete

I just finished an 8-week online data analysis course that challenged my brain more than has been done in a very long while. I wrote about this course on my personal blog some weeks ago. Now that I’ve completed it I’ve realised that discussing it definitely belongs here in my science blog.

I took it via Coursera, a relatively new online source of free, compressed, university-level training. The quality of educators involved is very high. My course in data analysis was taught by Jeff Leek, a Ph.D. and associate professor in biostatistics at Johns Hopkins University.

coursera

The course was much harder than I expected. I mentioned that after my first week, but it got really difficult later on. I had to learn a whole new statistical programming language (R), build on a lot of stats I took at uni many years ago, and learn many advanced numerical concepts besides. Moreover we learned how to know when to use different techniques; it becomes an art as much as a science.

We had to do an online multiple-choice quiz each of the eight weeks, and two lengthy written peer-graded assignments. The assignments were quite practical: for example, use Samsung phone accelerometer data to predict, from phone sensor readings, whether the person holding it is sitting, walking, standing, etc.

It will be a few more days before I get the score for the final assignment but I did well enough to know that I’ve passed already regardless of that grade. I’m hoping (though not expecting) to get a pass with distinction.

One of the best parts of the Coursera platform is that there is an extensive discussion forum for each course. It was like having a virtual study group of thousands of people around the world to bounce ideas off of, discuss the lectures, brainstorm how to tackle the assignments, and chat and bitch about the difficulty. There were plenty of people who felt entitled and complained about errors or things that were unclear. I was of the opinion that those people needed to think about how they were taking a detailed course of great complexity from a globally-recognised expert over the internet for free.

I’m planning to take another Coursera course later in the year; topic is to be determined. I recommend it highly, but caution those who think it will be a simple pastime.