Wednesday, December 30, 2015

I became a Python zealot!

Some time ago I started solving coding puzzles from codingame webpage. I mentioned it in a previous blog entry. I am doing all the puzzles in Python as a way to learn this language. Currently I have done all easy, all except one medium, half of hard and half of very hard. You can find solutions on my github account.

Thing that I would like to share with you today my dear reader is my findings about Python language.

Let me give you some background:

I learned some basics Pascal in a high school (using the Free Pascal IDE, yes the blue one pictured below!) and created a master mind game (you can admire this marvellous piece of work here).


Then I started my studies - Control Engineering and Robotics and learned C and C++. It was during medieval ages, harsh and dark times without vectors, list and all other shiny things kids play with these days. I prepared my own double-linked list, stack, queue through the pain and hard work.

On a second year, way before it was introduced on lectures I started working with microcontrollers and after short stint using asembler (I still have one of the programs I wrote, check it HERE) I switched to programming them in C. At that times the mighty AVR Studio 4 was considered a state of the art IDE, with no code completion and ugly looking font! All of this skewed me away from the objective C++ and made me favour C.

After the second year of studies I started additional field of studies - Computer Science. There I have learnt that C# is a great way to write programs with windows, buttons and so on. I also got to know collections, generic types and a world without pointers. On the other hand I was introduced to image processing library called OpenCV (during glory days of C api with IPLImage and manual memory managment <yay>). What is funny is that you can still found a lot of advices and code examples related to old OpenCV APIs. During that times I just coded - if there was a task, I did it, did not have any favourite language - I used what was best suited - C for micros, C++ for image processing, C# for windows apps. I did not know about unit tests, refactoring, clean code theories, version control systems (!) and other things. There were just problems that had to be solved. If the problem was small enough I was able to finish it fast, if it was rather large I was suffering because of my unawareness of  proper code management techniques. I drifted far away from the main point that I was planning to make - during all that time I did not find my go to language.

Diving into Python

Last year a friend (thanks a lot Marek!) convinced me to try Python. At the beginning I was sceptical as I thought that the same thing can be achieved with C# or C++ with heavy usage of standard library (especially with new things from C++11). Boy I was wrong! During this year I wrote some programs with Python:
and solutions for codingame puzzles:

After the last one especially I came to conclusion that Python is a great language to start your programming journey. This is somehow important to me as I am teaching programming at the Poznan University of Technology. Earlier, I was teaching students how to solve problems using C/C++ programming language and I did it with passion. Nowadays I am doubting if it is the best way and it is because of Python. I tried to convince my colleagues about Python superiority but they are stubborn so I will try to convince YOU, the reader. Try solving following problems in C++, while I will do them in Python and we will compare the solutions in the instalment of this series (I sent the questions to a few friends and if they accept I will post their solutions too). Here we go:

* you can use any collection you find appropriate for the task (vector / list / other). Same goes for strings / arrays of chars.

1) lets assume we have to collections and would like to print values in the following format:
value_0_from_first_collection, value_0_from_second_collection
value_1_from_first_collection, value_1_from_second_collection
etc

2) lets assume we have a text and we would like to print it without the first and the last sign. In addition print text length.

3) we have a collection of values and we would like to prit it without the first and the last value. In addition print collection size.

4) we have a function that has to return:
a) two values,
b) three values.
How would you implement that?

5) for collection of your choice do:
a) print all values,
b) increase each value by 10,
c) remove last element,
d) remove n-th element,
e) print value alongside its index,
f) check if value x is in collection,
g) check if all values are smaller than y.

6) having a text count how many letters are lower-case and how many are upper-case

7) is there any situation that you do not use indentation?

8) are you using standard arrays (static or dynamic) at all (like: int a[5] or int* b = new int[5])?

TL; DR

My programming history was presented. It is full of entertaining and absorbing adventures (who would contempt some asembler and pascal code!) that you should read carefully. Also Python is the thing right now. At the end I ordered you a homework that you have to do and post the solution in the comment section below!

Saturday, December 19, 2015

The Witcher 3: Wild Hunt - Hearts of Stone review

I thought that the previous blog entry about Witcher 3 was sole exception from technical oriented topics that I planned to discuss here. But the CD PROJEKT RED did it again. They created expansion that is in my opinion much better than the original game, which was a masterpiece on its own.

Most elements (graphics, control system) of the game are the same. You can find details in my previous review. Treat this as an incremental review - I will only mention elements, which are improved:

!!! WARNING - spoilers incoming !!!

Plot

Original story was good. That is all, just good. Here on the other hand the writing is the best part. The main story of the expansion is well written with some twists and a lot of connections to the real world. It is loosely based on polish legend about Pan Twardowski and some characters are looking and acting as they are polish szlachta (difficult to explain - check wiki). The best quest is in my opinion the one where you go to the wedding with your old friend Shani to party hard while sharing your body with ghost. A-W-S-O-M-N-E-S-S to the limits. This part has a lot of cut-scenes and dialogues so it is not your typical action RPG, but rather point and click adventure, but it is fabulous. I could be a little bit biased as I have re-read all the books about Geralt prior to playing Heart of Stone and just enjoyed every second it this universe. Even just riding around, sightseeing on my trustworthy roach was enjoyable. Of course in comparison to mentioned epic wedding quest some others can look bleak, but the overall writing level is much better than the original Witcher. On a side note - there are some some really funny jokes, which in polish version are somehow specific to Poland like joke delivered by typical Janusz or an offer to take a lone in foreign currency.

Characters

Some characters were great in original game (best pal Zoltan), while some were not up to that level (especially the antagonists - they were just meh). Here we have great and even greater characters. Olgierd von Everec, the immortal nobleman, Gaunter O'Dimm, the devious mystery man, Vlodimir - the crazy wraith, oh-so cute Shani and Iris von Everec - Olgierds wife that you met in other dimension - all of them are convincing and you can sympathize with them. I really considered my words when talking with them and was really engaged in what I was doing. It should be noted that the game is well balancing the serious moments and characters with funny ones. On a side note - after I finish the game I eagerly checked who was Gaunter O'Dimm, what other players found out and more. I spent some additional time reading about other choices, and getting better info about characters.

Sound

The voicing of polish version is great, especially Gaunter O'Dimm and a song that village children sing about him. You can check even better (played during the final, more psychodelic one) version here:


Music and actors made me curious how it fares in different language. As I enjoyed how dwarfs (english Zoltan is better than polish one!) and Novigrads villans sounded in original game (even if it was difficult for me to understand them fully), the expansion characters are much better in polish in my opinion.

Fighting

Minor thing, but surely an improvement. The fights in Witcher are solid and just good. The combat is responsive, but the bosses and minibosses are not posing a challenge, does not have special powers that makes you fight accordingly. That changes in the expansion. Even though the focus is on story, the combat was much more rewarding. Learning how to fight the caretaker was fun and killing him without taking any damage felt great!

Time required to finish

I have to mention it - the expansion was advertised as offering 10 additional hours of playing, but it took me much more than that. Maybe it is because I was doing everything really slowly and enjoying every bit of it.

TL; DR

Hearts of Stone expansion is an improvement over original game in almost every aspect it was lacking. I can give it only one rating:

Over 9000! Kappa