Can the gaming industry affect how we approach psychology? In the previous post, I wrote about how using a gaming controller gives us rich input data. What about games themselves? Can they provide us with interpretable data?

What better way to learn about the capability of games than to make them yourself? I decided to try my hand at game programming, and given its dual use in both experiment and games construction, the Pygame library was a logical start. I programmed the classic game 'Tetris' from scratch:

As I was programming, an idea came to mind: The way to get a higher score is to clear 4 rows at once by preparing for a line piece (see the 0:39 mark in the video), resulting in the eponymous 'tetris'. Being interested in probability learning, I wonder, if we manipulate the probability of the line piece, or make it's appearance contingent on something else, is the participant (or rather, the gamer) going to learn it and adapt his strategy? How long the participant takes to start moving the piece, whether the player hits 'down' to land the piece faster, whether the piece's rotation is vacillated, are all metrics that might also give us an indication of the player's confidence in their strategy.

However, what I am most interested in is perceptual precision. What is a game that could test that? I thought of the classic game 'Missle Command', where players have to account for the targets' velocity and try to intercept it. That is a bearing/orientation judgement, isn't it? I went about making a modified version of the game this time, instead of a simple recreation:

Curiously, I found that I could essentially just borrow snippets of code from a previous paradigm I programmed, which would mean that the same analyses could be done form the game data as well. It could be argued that gamifying experiments this way leads to less control, and noisier data. Perhaps, but there are also ways to minimize that. Notice that the player has to go back to the centre to initiate each 'trial', and to apprach the left or right placeholders for the 'cannon' to appear. Standard attentional and probability manipulations could very easily be applied here (e.g. exogenously cueing either side or making one choice the superior one). In addition, the game allows us to test variables we haven't yet looked at experimentally, such as adjustments in time, or the probability of target trajectory/velocity. Not to mention, it's just much more fun to play!

What might be of interest, though, to actually release such games publically, with the aim of collecting a mass of data. Something that works natively in a browser would do the trick. Pyjs, can be used to convert from python to javascript. I wrote a little mouse detection paradigm in Pygame, and converted it to run in a browser using the pyjsdl package.

Click here for the code (note how pyjsdl is imported as pygame) and an online demo.

Of course, what tour of gaming is complete without the classic 'Pong'? This time I tried something different. I used HTML5 canvas elements instead of pygame.

Click here to play Pong!.

In the midst of debugging the code, I realised that the AI could be made to return the 'ball' at specific angles, again enabling us to use Pong to perhaps test bearing/trajectory probabilities. Additionally, the way to make it difficult for the opponent is to try to hit the ball with the edge of the paddle, but that runs the risk of missing the ball altogether. How does one make this trade-off? Also, mouse-tracking is surprisingly good in-browser, and even though some precision in timing is lost as compared to running a program on the desktop, it is easier to deploy once coded (basically anyone with an internet browser can run it, although the current implementation requires a mouse).

So, can games be put to good use in psychology? Undoubtedly! That is, assuming proper planning, i.e. code the game yourself! For those interested in improving their coding abilities, I suggest trying out game programming: I learnt alot of coding tricks undertaking this exercise, and there's nothing that makes you want to be more streamlined in your coding like seeing your game runnning sluggishly!

Disclaimer: All music/sounds used are purely for demonstration purposes and are property of their respective owners.