Aug 16

Google Summer of Code 2016 – Final Report


Gooey with party hat, Terasology’s mascot celebrating!

Organization: MovingBlocks
Project: DAG-based Rendering Pipelines
Product: Terasology

Terasology is an open-source sandbox videogame, originally created as a Minecraft-inspired tech demo, it has grown into a powerful engine for voxel-based gameplay. The project is currently focused on architecture and extensibility, but as of early 2016 has released a first Alpha version to be a baseline engine for creating content and building gameplay.

Previously Terasology’s rendering engine was monolithic, rendering tasks were closely coupled (see diagram) and the rendering pipeline could only be altered by directly modifying the source code. Throughout summer (for my original project proposal please check here) I carefully extracted all rendering tasks, wrapped them inside into well-structured nodes and defined the OpenGL state changes that the nodes now use (diagram of the abstraction). Without changes to the visual output the engine generates, at the end of the project not only the engine can automatically reduce the number of redundant OpenGL state changes, but it can now enable third-party modules to insert their own nodes into the pipeline, something I demonstrated in the last days of the project with proof-of-concept code introducing a number of simple post-processing effects at runtime.

Finally, on final days of my project I enabled module developers to insert their own effects into the rendering engine without making substantial modifications. A video regarding to this:

Contribution Summary

Screen Shot 2016-08-23 at 05.03.15

A complete list of my commits can be found here. The pull requests that are relevant to the project:

PR ID Summary
2325  Wrapping ShadowMap and WorldReflection into a "Node"
2362  Backdrop and Skybands Nodes for DAG
2388  Post-Processing Nodes for DAG
2399  Architecture for Redundant State Elimination
2421  Finalize SetWireframe StateChange
2425  A Minor Refactor in StateChanges
2427  New StateChanges for DAG
2431  Nodes use FBOConfig to add their desired FBOs to FBM
2449  Introduces API for module developers to add graphical tweaks to their mods

The other pull requests during or before the project:

PR ID Summary
2195  Add animated water and grass options remove environment effects option
2211  Add fog volumetric fog and particle effect limit options
2286  Add auto complete for "showScreen" command
2288  Visually distinct UI elements for enabled/disabled
2316 Open up the DebugOverlay to add/remove MetricsModes

Future Plans:

  • Making module developers life easier by proposing annotations
  • There are still some nodes needs special care, planning to split them.
  • Introducing new missing state changes
  • Adding OSVR support


It was a very enriching journey. I am very grateful to have such extraordinary mentors,  Emanuel D’Arrigo, Rasmus Praestholm and Martin Steiger. There were always there for me, like a family. 😀 I also want to thank Google for arranging this programme, without their support I wouldn’t be able to meet & work with this amazing community.

Jun 16

Caduceus in ANAC 2016

Caduceus, Courtesy of Wikimedia

A blog, abandoned for more than a year now. I would argue and say “I got the so called writer’s block, which you know, you lose your creative process and unable generate valuable work”. I believe this wouldn’t be enough to trick anyone. 🙂 Nevertheless, let me start this post by hoping that I’ll find enough creativity than before to write more posts here.

Now, the news: I am happy to announce that me, Burak and Bahadır (my fellow classmates from CS462 Automated Decision Making in Multi-Agent Systems class) under supervision of our professor Reyhan Aydogan entered to Automated Negotiating Agents Competition 2016 in AAMAS 2016, Singapore and we got the first prize in the competition with our agent, Caduceus (a greek symbol which mistakenly confused by being symbol of medical field, actually it’s associated with “trade, eloquence, trickery, and negotiation“.

Our first version of Caduceus was a stubborn agent, which always offered what’s best from him and in later stages Caducues concedes to what’s best for everyone by previous observations. However in our automated tests (we used Travis-CI with Github), even being finalist in the competition was impossible because of its stubbornness. At last minute, we thought how about asking other expert agents’ opinions about the current situation and support our decision making. It appears that it worked! 🙂 As a team we will be publishing a small piece about Caduceus in this summer.

 ANAC 2016 session in AAMAS 2016

ANAC 2016 session in AAMAS 2016

Caduceus Team

Caduceus Team, senior project presentation day on May 30

May 15

Using Django with Spatialite on Debian

Screen Shot 2015-05-19 at 15.21.41

SpatiaLite is a library for extending SQLite core for efficient Spatial functions. I am currently using it, during research. It’s a bit cumbersome to install it with Django 1.8. After hours of struggling, I finally installed it on my Debian system.

In order to not waste some much hours, I wrote whole process to this gist.(64 lines)

But I want to write some of gotchas here:

  • Before starting make sure you have installed build-essential.
  • Make sure you also installed python2.7-dev package, this is required for packages that uses Python.h
  • + don’t forget to install libexpat1, libexpat1-dev, both required for compiling spatialise-tools.
  • There is a slight difference with paths during the compilation. Some of the libraries tend to look only to usr/lib, usr/includebut others just only check usr/local/bin, /usr/local/include.
  • On my local system (Mac OS X), after following steps from Django’s Docs on Spatialite, I added this to my settings.py


Apr 15

Spy-E: Idea

This semester for Agile course, Arman Garip, Can Göçmen, Deniz Sökmen, Enes Şenel and I came together as a team to develop something that I personally wanted to be involved in.

It is Spy-E!, (pronounced as sphay-hee, not spahi, that’s something else.). It’s a game!

It may seem very standard goal for today’s world, well, all of us wanted to develop a one that we play and enjoy.

First we started talking about which games we enjoy most. Starting with Metal Gear Solid series, an upcoming MGS V: Phantom Pain, mostly Deniz and I enjoyed how the stealth is used as a game mechanics. Starting from MSX2 (very old gaming console from Japan), the first game of the series, Metal Gear was the first one to include these mechanics.  Furthermore it moved to NES platform with a very bad remake of the MSX2 version. After that Metal Gear Solid (over six million copies sold) was released on Playstation. Moving the game from 2D to 3D, for me it’s a unbelievable breakthrough. (Beware that Playstation has a MIPS R3000A-family R3051 CPU with 33.8688 MHz clock.)

Screen Shot 2015-04-08 at 15.55.48

(Water reflections are amazing, for that time.)


Metal Gear Solid: VR, (extra missions, which are a great expansion also to the story.) the main character of the series, Snake trains in a VR environment for a greater threat, a device which can launch a nuclear missile to every location on earth. (Summarising a very big franchise with a one sentence 🙁 ) You learn about stealth and weapons in those missions.

I met with MGS franchise, long time ago with MGS 3: Snake Eater via my PS2. One of our random conversations with Deniz, he convinced me to play the whole series to understand the whole franchise.

Long story short, we decided to make a game that has a theme like MGS:VR, except you are not a super-genetically-engineered soldier. Your character will be a anonymous person who wishes to be a Spy to be used by a fictional government to steal enemy intelligence from well-protected enemy headquarters. You should be able to avoid enemy soldiers, surveillance systems to be stay undetected.

It was a pity for MGS: VR to not be able to build your own levels. After you beat all of them, you probably get bored after a while. We decided to include an level editor to Spy-E for that reason.

We started developing Spy-E last month with agile methodology. Each week(sprint) we are required to show our additions to the project and discuss about the requirements with our instructor.

About the engine(is it in-house or third-party?), screenshots, models and more, in next post.

Feb 15

Magic Tricks in iOS Development

Yes, magic :-),

I started working in a firm that develops solutions for events like congress etc. As you know, in professional life, you need to deliver your products on the time. If you are doing repetitive tasks for the products, you definitely need to do some magic tricks.


My first recommendation before telling you my magic tricks, for the iOS developers(this is true for other developers as well) is to understand requirements, priorities very well. What is the most important thing to do first? A feature or half-finished mobile app that is delivered on time.

Secondly write clean code, you know very well why. Ask Uncle Bob.

And now magic trick number one: Most of time I got frustrated by lack of automation for taking screenshots of your application inside Xcode. Well I found a workaround, which is above my expectations.

It’s called Snapshot.(I highly recommended it. Kudos to its author.) It generates the screenshots of your app by executing a UI interaction script. Author of Snapshot, Felix Krause, also has small tiny components that can be combined with fastlane to automate the whole deployment process.

I am using Swift for a while and I want to recommend you the third party libraries that I use, and all of them are magical.

  • JSON.swift, very simplistic NSJSONSerialization wrapper by Dan Kogai
  • Async.legacy, Syntactic sugar in Swift for asynchronous dispatches
  • SQLite.swift, by Stephen Celis, saves you tons of headaches if you are using SQLite in your project. Plus has a very well-written documentation.

My final advice is, even though the 3rd party libraries are tempting at first, later you can get headaches too. Please be careful while choosing a 3rd party library. It may be buggy, make sure that you really need it.

The libraries that I shared with you above, are the ones that I really like. If you find a bug in any library that you use, please don’t forget to report it or fix it and send your patch to the author.  It will be very useful for other suffering developers.

And may the force be with you!

Dec 14

Protocols to Closures in Swift

After releasing Socivy in a very short time, it required some refactoring in the API level. Since MVC pattern is in the foundation of the iOS development, without touching UI components, I can directly refactor only API part of the project.

Well, I highly used protocols in my implementation. For instance, if user makes a request to get available routes in the system, it uses already constructed SocivyAvailableRouteAPI to make fetch routes from the API. It handles the requests asynchronously and returns the response by calling delegate function like routeRequestDidFinish(), this is enormously helpful for me to separate controllers and models however, after increases in our API methods, unfortunately it increased protocols and unnecessary repetitions.

Not only this, increased a spaghetti code, it also affected the compile time. A big advantage was that everything was explicit, and implementation was pretty fast, it helped  our tight development schedule.

I will be adding a chatting feature for Socivy for the end of the semester for CS392 course. Before starting the feature, I thought it would be better to refactor the code and use closures and Factory and a kind of Facade pattern to reduce redundancy and decrease number of classes.

Because of the architecture of SocivyAPI security, it requires re-logins sometimes. Whenever an API request fails due to expired session, it should automatically restore and continue the calling the action and trigger the callback to update the user interface. I subclassed NSURLConnection, added completionHandler and errorHandler:

  • completionHandler: (response:NSMutableData->())?
  • errorHandler: (error:NSError->())?

Basically if request returns successfully or with an error, it will be handled by these handlers. Another problem was the data validation, NSMutableData must be a convertible to a valid JSON object. For that, I implemented a Model layer that gets exactly same handlers but this time completionHandler gets JSON as parameter. In that layer, I also handled session expires, it automatically re-logins after the validation, so no need for extra care for all methods that require authentication.

However, delegates must be removed after these, since the protocols are removed. For instance:

It is currently on ViewController side:

With closures, I think it is much cleaner than delegates, you can handle different cases, much better than delegates. On the other hand, you should never do this:

This is not very expressive, and would eventually lead to a callback hell.

Nov 14

Star Wars in Office

I promise Murat Kırtay, I will watch all of them 🙂

Oct 14

On Security, Socivy

A big coincidence that last year, I wrote a post about securing a RESTful API, well this year, I experienced the same challenge, but this time in Socivy, we implemented the actual things that I mentioned in that post.

Screen Shot 2014-10-24 at 01.30.18

This semester, because of the price increases in our shuttle service, old OzU-EMS, as Socivy team, we decided to do something about it. I attended to the Student Union’s meetings, which they came up with a solution. It was making a call centre that find drivers and passengers, and match them.

We thought that it’s a very inefficient and frustrating work. On that time, it was necessary to this manually, because there were not any available solutions. At 00:30 AM, we decided why not, let’s write something. A simple car-sharing app that has the popular stops in it and can send notifications to the passenger and driver. I started the initial designs of the iOS app for it. Well, the whole development process is a long story, which we did everything that can be possibly wrong and learn it by doing. I am planning to write it whole development process in detail some time.

After finishing our web site, and hitting almost 6.000 page views, it was time to write an API for our system. Since privacy related data(phone numbers, passwords, plate number etc.) transferred throughout our system, we thought it’s necessary to take some actions for it. We put a SSL layer, both to our web page and API. However we were uncertain about deciding:

  • Saving email and password in the app or not.
  • Sending the data over HTTP parameters or in headers
  • Obfuscate or not (we are scared about decompilation of APK packages of Android)
  • Storing our API keys inside the code or in a file or in an encrypted file
  • Should we care about replay attacks which can exploit our API

Well, first thing about security, your protocols should be hidden. It’s very obvious to see that nobody knows how to do it best. By saying best, I know that it’s impossible, but we don’t want to left our front door open to bad people. For this reason, sorry I wish I could tell you all the technical details. 🙂

Even though, it is not a commercial application, but we wanted to make it in level that it can compete with them in terms of security.

  • SSL is necessary, for lot’s of reasons.
  • You should send your parameters in POST data or HTTP headers, not in parameters.
  • Obfuscate it, if you can. if you don’t want your precious algorithm to be stolen, store it to your remote server.
  • Well, it depends. You should be aware of that if someone installs your app and jailbreaks his/her iPhone. They can get access to the file that you provide. It’s better to an encrypted file, instead of putting inside the code.
  • Even if you have SSL, you can get frustrated about replay attacks. You need to find a way to eliminate that. You can put the timestamp while using the API, but it can be trivially changed by hand. I recommend you to find a way to make requests expire, you may use tokens.

Bonus: What is Socivy? How to pronounce it? (it is not sokivay, soçayvi, sochaywi)

Until next time!


Jun 14

Automating Terminal Experience with Aliases

Even though, I think terminals are kind of ancient tool, it is unquestionably useful when you are accessing to a remote server and etc. Despite the fact that I know how to add aliases for my ssh connections(thanks to Murat Kırtay), I really hated to go through to my .zshrc configuration to edit it to add an alias.

First I wrote a very basic alias adder script and placed it to the /Users/tdgunes/Utils folder. (I am sorry that I didn’t find the time to make it completely modular and clean for other people.)

After putting this into Utils folder named as new_alias.py, go to your .zshrc file. And add this at the end of the file:

Now it will become so easy to add other python files. Go to my terminal utils gist, you can download the other scripts. For instance, you can automate your ssh logins by just adding the script (named as add_ssh.py) to your aliases and then when your alias is called, by filling user name and the host name, your password twice and it will put to your keychain, so you don’t need to write your password every time when you login to a remote server.

Happy hacking!

Jun 14

At 2:00 AM to 4:00 AM = A Pong on Arduino

In 2013 Fall, I bought a TFT LCD Screen for my Arduino Uno (r3), in order to increase the level of fun I get from electronics. Especially after EE203 course, it is fun to play with something that works without making you crazy at the end of the day (check this hotel-safe circuit, that I built for course project. Painful hours.).


I got rid of all of the cables of my hotel safe project that were attached to the breadboard. By looking this schema, I connected my TFT LCD Screen to my Arduino Uno. I tested it with TFTDisplayText example. At 2:00 AM, with an unknown inspiration, I put a small challenge to myself to make the game Pong playable throughout the serial port.


For the code you can get it from this gist. Have fun with electronics at last. 🙂