[Riddle] simulation of genetic behaviors in population
There are things, that aren’t interesting because they are complicated but because they have simple solutions. Today I will present one of those riddles, that comes from the book “THE SELFISH GENE” by Richard Dawkins. You can find there more of such stuff and all is presented from biological point of view, far away from informatics.
Consider this problem: in population, in given situation, species may behave in two ways: as a fighter or as a coward. Fighter always wins fight with coward. This behavior is set by a single gene, if a specie behave in a way that give him advantage, then he is in a better position and will have more descendants. For us it means, that his gene have better chance to spread in population.
Assume, that species don’t remember behavior of other species and that they can’t predict it. Score function, that says, how profitable the behavior is will be needed – we will use arbitrary numbers, like in the book: let’s attribute +50 points to win, 0 to fail, -10 to waisting time, -100 for serious damage.
- Coward meets Coward, the winner gets +50 points, both of them get -10 points for waisting time (they could do something valuable instead). Those -10 points are here, because cowards waist time on trying to make their opponents scary, if they can’t do that they run away,
- Coward meets Fighter, the winner gets 50 points, the looser gets 0 points, as we said, fighter always wins with coward,
- Fighter meets Fighter, the winner gets 50 points, the looser gets -100 points for a serious damage.
At the beginning there are only cowards — nothing interesting for us. When fighter (obviously a mutant) appears in population, then he is in a privileged position, his genes spreads quickly. Situation changes when fighters become dominant part in the population, then it’s much better to be a coward.
At first it looks like amount of fighters and cowards will changes periodically. In fact it will go into a stable ratio (there is a lot of math here, but it’s not important here).
The goal is to display at each generation the percentage of cowards and fighters in population (this should sum to 100% ofc). There is a given number of generations to show and initial generation (again in a form of percentages of cowards and fighters).
“Najwyższy czas na małą, kurwa, zmianę”
Po siedmiu latach w Krakowie przenoszę się do Wrocławia.. i to jest coś kapitalnego, dlatego chciałem się z wami tym podzielić :) Znalazłem też nielichą pracę, a na badaniu okresowym lekarz nie wykrzyknął nic w stylu “OMFG Pan jest taaak chory na jakieś śmiertelne coś”, co też uznałem za dobrą monetę :)
..ale tak na prawdę, to najfajniejsze jest, że zmieniłem (trochę) podejście do życia, że wszytko jest jakieś takie fajniejsze..
..a Ślązaczki to jakie śliczne są :))
Can you play music with your AVR USB programmer?
Abstract
I can:) I have STK500 compatible device, plugable to USB port and in this post I would like to show you, how to play some sounds with this stuff. It doesn’t play with a high quality, but it’s not the point.
Check my flow here. If you don’t hear anything then please turn the volume up! It’s a bit to quiet.
Super-resolution algorithm implemented in Python
Abstract
Super-resolution algorithms are family of algorithms used to obtain higher resolution image from set of images in lower resolutions. It’s important to notice, that by using those methods the higher resolution image contains more information (is more detailed) in opposite to resizing (and debluring) algorithms.
This technique can be applied in many domains, e.g. to images from military, meteorologic or astronomic satellites, pictures taken by medical equipments like tomographs or X-ray machines. Those techniques can be also extended to use in 3D scenery.
We will shortly describe super resolution algorithm proposed by Irani and Peleg and its implementation in Python programing language. Included code may be distributed under the BSD license.
Bellow is the image, that contains one of low resolution captured images (lower part) and estimated higher resolution image (upper part). For easier comparison of details, low resolution image was resized by using Lanchos3 algorithm to fit dimensions of estimated image.
Making a robot, part 1
Abstract
Robots are cool but they are also difficult to build, so I divided this goal on a couple of tasks and today I would like to present first step: drive.
In this note I would like to show a simple “car”, that can only move forward and backward. On this stage it’s nothing special, but I’m going to use it as a base for more interesting projects.
In next posts I would like to present control mechanism and sensors but there will be also “brain” — a circuit with AVR processor.
Hardcoded images in source of PHP engine
Abstract
Have You ever think, what happened when server sends an image? Usually it needs to grab it from file system or creates it dynamically (e.g. by using GD or PIL library) but there is also another option: image hardcoded in source. This idea is what I will describe today.
Mentioned image may stay in source as a regular array, fields of this array are bytes of its content. If it isn’t clear for you let’s imagine that you open image in hex editor — you will see content of it, all bytes in a form readable for human. You can copy them into source file, every byte as a field in array. Then, if you will iterate thought it, you will get exactly the same data as those, stored in the original file.
I will show you, how it’s done in PHP source, then I will show my implementation based on this. It will be a simple HTTP server, that serves image in that way.
There will be a lot of code from different files, so we need compact way to refer to them — I will use vim’s syntax:
path_to_file/file_name +line_in_file
At the end of introduction I would like to say, that this post is written just for play with PHP source, to sniff it, don’t thread it seriously.
Coating things with copper by using galvanisation
Abstract
Galvanization is a simple way to coating metal things with copper, today I will present you, how to do that at home, without expensive equipment. You can use it to protect trinkets from corrosion or for decoration. This process is also common in the industry (for various of materials, methods and cases). You may want to visit Wikipedia to get more information about galvanization.
Above are some of the examples, that I made (the nail was covered about 6-7 years ago):
Simple 32bit Intel Linux compiler, part 1
Summary
This compiler works with subset off l33tlang’s assembler and produces as an output binary file that can be executed on Intel386, 32bits compatible processors, on Linux platform. It’s written in C, in objective way.
Abilities
- compiling procedures
- usage of Linux interrupts (now only one is implemnebted)
- artithmentic operations (now, only addition)
- stack operations
How to build simple, home-made speaker
Today I will present my own, cheap and simple home made speaker. It sounds pretty good but quietly, even if I turn volume to maximum.
Domain Specific Language in Ruby used as a Virtual Machine
Abstract
Post describes a simple DSL language (in Ruby), that is used as a virtual machine, for a simple assembly language. This assembly language was used by me a couple of months ago, when I created a simple programming language — there are already implementation of its VM written in C (by czarodziej) and in Python (by me).