<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title> &#187; Nicola Bortignon &#8211; Living on the Edge</title>
	<atom:link href="http://www.nicolabortignon.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.nicolabortignon.com</link>
	<description></description>
	<lastBuildDate>Thu, 17 May 2012 10:20:35 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Bring back AIR on Linux</title>
		<link>http://www.nicolabortignon.com/bring-back-air-on-linux/</link>
		<comments>http://www.nicolabortignon.com/bring-back-air-on-linux/#comments</comments>
		<pubDate>Fri, 03 Feb 2012 22:01:30 +0000</pubDate>
		<dc:creator>Nicola Bortignon</dc:creator>
				<category><![CDATA[AIR]]></category>
		<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://www.nicolabortignon.com/?p=359</guid>
		<description><![CDATA[Those who know me well know I&#8217;m not a big fun of Linux. Let&#8217;s say it&#8217;s not my favourite OS out there, nor can I undestand some of the ideological ideas behind Linux adoption. My choice of operating system is more business oriented: If you need work done, pick the best tools out there, whatever [...]]]></description>
			<content:encoded><![CDATA[<p>Those who know me well know I&#8217;m not a big fun of Linux. Let&#8217;s say it&#8217;s not my favourite OS out there, nor can I undestand some of the ideological ideas behind Linux adoption. My choice of operating system is more business oriented: If you need work done, pick the best tools out there, whatever system they may run on. If it happens to be Linux, that&#8217;s ok. If it is Windows, that&#8217;s fine too, and so on &#8230;</p>
<p>So, even though I&#8217;m not a Linux ambassador, I&#8217;m disapointed over the tratement Adobe gave to the Linux users. In particular, I&#8217;m referring to the decision of discontinuing the support for the Adobe Runtime (AIR) on that platform. The latest version is 2.6, and during a time when big changes are being introduced (stage3d, native code, etc) the gap is getting wider day after day.</p>
<p>As a professional developer, even though I don&#8217;t work in Linux, the products I develop regularly end up on Linux platform across the globe. Removing Linux as one of the target platforms reduces number of potential customers, and in the end hurting income.</p>
<p>My support for AIR on Linux is not because I want to take sides in an ideological war, it&#8217;s a pragmatic choice. I need AIR on Linux for keep my business running.</p>
<p>I think there is a reasonable share of the market behind Linux still waiting to be explored. This is my way of publicly requesting Adobe reconsider their decision, and to reinstate the AIR Runtime on Linux.</p>
<p>This letter is written under no copyright restrictions, and available in the Public Domain. If there are developers out there that agree with me, rather than only linking to it, show your support by copying it to your own website or blog, or write your own version of the letter.</p>
<div align="center">
<div style="width: 486px; text-align: left;">
<pre></pre>
<pre></pre>
<blockquote>
<p style="text-align: center;"><em>From its release, AIR has been presented as a multiplatform solution. From its release, AIR has been presented as a multiplatform solution, inheriting the &#8220;write once, deploy everywhere&#8221; philosophy from the Flash platoform. This was for us, the developers, arguably the key feature of the Runtime.</em><br />
<em> Even with the recent updates by Adobe to the platform&#8217;s strategy, we, the developers, can read between the lines; you still desire to target as many platforms as possible.</em></p>
<p style="text-align: center;"><em>Unfortunatly, one platform is being overlooked; the AIR runtime is no longer mantained for Linux desktops. The last version available is 2.6, and the gap between that release and the current version is getting wider day by day. This is sad, especially seeing the lack of farsight by Adobe shown by no longer investing in such a promising ecosystem as Linux.</em></p>
<p style="text-align: center;"><em>We, the developers, believe that Adobe should resume delivering updates to AIR on Linux. We invested in what we considered in the beginning to be a multiplatform desktop solution, we want this statment be true again.</em></p>
</blockquote>
</div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.nicolabortignon.com/bring-back-air-on-linux/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>The Pineapple Technique &#8211; Chapter 1</title>
		<link>http://www.nicolabortignon.com/chapter-1/</link>
		<comments>http://www.nicolabortignon.com/chapter-1/#comments</comments>
		<pubDate>Sun, 22 Jan 2012 20:35:32 +0000</pubDate>
		<dc:creator>Nicola Bortignon</dc:creator>
				<category><![CDATA[Music]]></category>
		<category><![CDATA[Team Management]]></category>
		<category><![CDATA[Task Managment]]></category>

		<guid isPermaLink="false">http://www.nicolabortignon.com/?p=339</guid>
		<description><![CDATA[Chapter 1 [42 min workout] 1 - Lovebirds feat. Stee Downes &#8211; Want You In My Soul &#8211; Original Mix &#8211; Winding Road Records 2 &#8211; Fritz Kalkbrenner  - Layer Cake &#8211; Original Mix &#8211; Soul 3 &#8211; Maceo Plex &#8211; Under The Sheets &#8211; Original Mix &#8211; No.19 Music 4 &#8211; Nicone, Sascha Breamer &#8211; [...]]]></description>
			<content:encoded><![CDATA[<h2><a href="http://www.nicolabortignon.com/thepineappletecnique/ThePineappleTecnique_01.mp3"><br />
Chapter 1 [42 min workout]</a></h2>

<p>1 - Lovebirds feat. Stee Downes &#8211; Want You In My Soul &#8211; Original Mix &#8211; Winding Road Records<br />
2 &#8211; Fritz Kalkbrenner  - Layer Cake &#8211; Original Mix &#8211; Soul<br />
3 &#8211; Maceo Plex &#8211; Under The Sheets &#8211; Original Mix &#8211; No.19 Music<br />
4 &#8211; Nicone, Sascha Breamer &#8211; Dreamer &#8211; Edu Imbernon Remix - Stil Vor Talent<br />
5 &#8211; Romano Alfieri &amp; Luca Bear &#8211; Leave the Valley &#8211; Original Mix &#8211; Break New Soil<br />
6 &#8211; David August &#8211; Hamburg Is For Lovers &#8211; Original Mix &#8211; Dynamic<br />
7 &#8211; Siwell &#8211; Watching Above the Horizon &#8211; Original Mix &#8211; Sphera Records</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nicolabortignon.com/chapter-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
<enclosure url="http://www.nicolabortignon.com/thepineappletecnique/ThePineappleTecnique_01.mp3" length="101958084" type="audio/mpeg" />
		</item>
		<item>
		<title>Create Plants vs Zombies Clone: Week 2</title>
		<link>http://www.nicolabortignon.com/deliver-faster-or-die-trying/</link>
		<comments>http://www.nicolabortignon.com/deliver-faster-or-die-trying/#comments</comments>
		<pubDate>Sat, 31 Dec 2011 14:14:14 +0000</pubDate>
		<dc:creator>Nicola Bortignon</dc:creator>
				<category><![CDATA[Gaming]]></category>
		<category><![CDATA[Fast Prototyping]]></category>

		<guid isPermaLink="false">http://www.nicolabortignon.com/?p=297</guid>
		<description><![CDATA[Deliver faster or die trying The second week flew by quickly, with all seven days spent entirely doing research in several fields concurrently. When plagiarizing an existing game, there are a few tasks which are already done for you; you don&#8217;t need to rethink the wheel, it&#8217;s almost finished. In our case, I know there [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Deliver faster or die trying</strong><br />
The second week flew by quickly, with all seven days spent entirely doing research in several fields concurrently.</p>
<p>When plagiarizing an existing game, there are a few tasks which are already done for you; you don&#8217;t need to rethink the wheel, it&#8217;s almost finished.</p>
<p>In our case, I know there will be “Goodies” and “Baddies”. There will be resources produced by the Goodies (in the case of PvZ, the sun produced by sunflowers) that are used to place new allies (plants). The playing field is laid out in a grid, which the Baddies march into.<br />
Although the mechanics are quite simple, humans are programmed complicate things (overengineerng is the most common example of this plague).</p>
<p>The time I didn&#8217;t spend on game design was thrown away on finding a purist way to make the game multiplatform. Experience has taught me that multiplatform by technology is not a big deal, you are always constrained by the technology promoters. Personally, I was (and still am still) a Flash Architect.<br />
Adobe has claimed many times that Flash is a multiplatform technology. Unfortunately, this definition is not accurate, and it&#8217;s becoming less accurate day by day. Flash is a famous example of how hard it really is to develop technology that is truly multiplatform.<br />
When I say &#8216;Flash&#8217;, I&#8217;m usually referring to the Flash platform in general, comprised of the language (ActionScript 3), the virtual machine (Flash Player, AIR), and the tools provided. The last option, tools (which includes ide, authoring, etc.), should also be considered when evaluating a technology as multiplatform; not only the consumer, but also the developers need to be taken into account.<br />
The Flash decline (if we can call it that) as a multiplatform solution started with the buzzing war if HTML5 paladins lead by Steve Jobs as Apple decided not to include Flash Player on their iOS devices. I&#8217;m not going to discuss this matter further, as many battles have already been fought upon this topic, of which I&#8217;m sure you are already aware.</p>
<p><span id="more-297"></span><br />
Over time, Adobe started cutting platform resources, and a few AIR branches (first AIR on Linux, and later Flash on mobile devices), while other branches were potentiated, such as the iOS Packager (an LLVM translator for targeting iOS devices)<br />
My point is, embracing a technology has it&#8217;s risks. Putting all your faith in a technology controlled and developed by others (especially by corporations that put profitability above all else) is foolish. You must face this fact: a technology will rarely (if ever) answer to all your needs. If you think all your problems can be solved by one single technology, there is something wrong.<br />
I&#8217;d like to quote my university teacher of Concurrent and Distributed Systems. He believes that languages and technology in general are just elaborate ways to represent simple things that modern developers don&#8217;t want to deal with. Rephrasing that, it all ends up as a series of bits, what differs is how you choose to generate them. Keeping this final purpose of all technology in mind can help avoid extremism and unhealthy attachments and to specific technologies, and keep you from getting overwhelmed when those technologies change.<br />
What I came up with was a typical architectural approach (although, I must admit that my decision was biased).<br />
One of my virtual mentors is Cliff Hall, the creator of the PureMVC framewok (promo time, <a title="PureMVC Book" href="http://puremvc.org/content/view/185/1/">his book</a>  was released a couple of weeks ago, and I highly recommend it). PureMVC has been ported to over 15 different languages,<br />
and it can virtual target in one of his incarnation any device out there.<br />
PureMVC offers a middleware architectural layer: as long as you write code with the framework&#8217;s philosophy in mind, you are not bounded to the underlying technology. This allows for framework abstraction and a language agnostic approach.<br />
The MVC pattern allows you to isolate dependencies of the language&#8217;s API to only the visual parts (mediators handling the View) and few lines in the Model proxies (the ones that deal with the OS or i/o operations).<br />
Back to the game, using such a framework over-complicates things at the bootstrap phase, but as long as you know the way, you get faster day by day, and the feeling of being safely bounded within the framework encourages you to reduce iteration circles.<br />
True game developers will tell you not to complicate things by introducing architectural frameworks, but as long as you want to target a wider marketplace, an abstraction layer must be introduced to speed things up; PureMVC was my choice.<br />
Back on the game side, I strongly prefer using a runtime scripting language. It happens quite often that large projects lead to high compilation times. Last Monday morning, I decided to track how much time I spent waiting for the compiler. The result? About 30 minutes for one standard work day.<br />
I was looking for an in-game tool to quickly arrange things without recompiling every time.<br />
I’m a fan of Unity3d, and one of the best first impressions that a flash developer notices in the IDE is the play button. You just push it, and your game starts running.<br />
One more time i spend hours in deciding how to reach this result. I was tempted to write my own virtual machine within the technology I pick, or just go for an existing one (note: up to now, I have still not revealed which one, or more, technologies I have chosen).<br />
My final choice was LUA. I don’t want to spend too much time talking about LUA itself, let me just say that I was rude towards LUA in the beginning. I’m not a fun of the language itself, but I’m immensely fascinated by the community around it that keeps pushing it day by day to the Olympus of scripting languages!<br />
But this was another digression. The post title was about fast delivering, and up until now I have been showing off how I introduce delays to the project.<br />
So the remaining three days of the week I decided to speed things up and start working on the game.<br />
As a first action, I forced myself to write out the goals of the week. Always write explicit aims, even if it is a solo project. This is a inner exercise to force yourself to keep the project rolling along. Always set deadlines on short-term goals. There’s no need to decide now that I want this game out 12/12/2012, but there’s a great reason to set the spritesheet stress test for next Friday at 12:00.</p>
<p><strong>My goals were:</strong></p>
<ul>
<li>test the basic rendering engine on an iOS/Android/Playbook OS/Windows Phone 7, and stress-test the rendering engine with 100 plants + 100 zombies + 400 bullets</li>
<li>implement a collision detection system</li>
</ul>
<p>&nbsp;</p>
<p><strong>And the results:</strong></p>
<p>I tested it on an iPad2, and an iPhone 3g. I think I got the chance to work with the top and the lower tier devices running iOS at the moment. It works on both, but unfortunately, the lack of support for Open GS 2.0 on the iPhone 3g slowed things down a lot, and I was not able to reach higher frame-rate during the stress test (stack @10fps).</p>
<p>Now i have two choices, cut out the 3g support and go for the 3gs as a baseline, or just reduce (tweak) the loads in case the games run on a 3g device.</p>
<p>On the android side it was madness. Performance was higher than expected testing on phones with 2.2,3.0 and 4.0. But the fragmentation of colorspace and resolutions scared me a lot. I didn’t think about it at first, but responsive layout design wasn’t enough in such a case. Here is a deeper <a title="Apps Devices Breakpoints" href="http://www.zeldman.com/2011/12/29/state-of-the-web-of-apps-devices-and-breakpoints/">analysis of my frustration </a><br />
On the Playbook side I was satisfied enough; great performance even if a weird aspect ratio.<br />
No chance to put my hands on a WP7 device, nor to the Sony S1 &amp; S2.<br />
On the implementation side, the collision system was pretty nice to introduce. I first got into rough box collision with a O(n*m) algorithm complexity (where n are number of shots to test each ticket time, and m the number of zombies). It works but with unacceptable performance.<br />
I later went for a radial collision detection. Faster, since the case were there is no collision is higher than the case were there is. But still not efficient enough.<br />
I decided to exploit the grid structure of the game and implement an R-tree collision system, first using both of the two dimensions, and later using only one dimension (the X axis, since shots fired on one row can hit only zombies in the same row).<br />
The result was quite fast, so I decided to stop my refining process for the moment (even though I’m sure that with a linked list data structure I can increase the performance further)<br />
In the following screenhot, the plants (mushrooms) come from <a title="Tado's Funghi" href="http://tadoshop.bigcartel.com/product/funghi-4-resin-figure">Tado&#8217;s Funghi</a> collection, while the zombies (scarecrows) are a CreativeCommons spritesheet, both are used here as placeholders.</p>
<p><img class="aligncenter" title="Screenshot PvZ week 02" src="http://www.nicolabortignon.com/wp-content/uploads/2011/12/image01.png" alt="Screenshot PvZ week 02" width="500" height="370" /></p>
<p>In the upcoming days I want to research the marketplace opportunity. I’m particularly interested in the Rim one since it seams Plants vs Zombies was not ported there. I&#8217;m also looking forward to digging into these <a title="Steam Statistics" href="http://store.steampowered.com/hwsurvey">steam statistics</a> &gt;&gt;in order to decide early on how to distribute time resource over single desktop version development.&lt;&lt;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nicolabortignon.com/deliver-faster-or-die-trying/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Create Plants vs Zombies Clone : Week 1</title>
		<link>http://www.nicolabortignon.com/create-plants-vs-zombies-clone-day-1/</link>
		<comments>http://www.nicolabortignon.com/create-plants-vs-zombies-clone-day-1/#comments</comments>
		<pubDate>Tue, 13 Dec 2011 14:33:50 +0000</pubDate>
		<dc:creator>Nicola Bortignon</dc:creator>
				<category><![CDATA[Gaming]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Games]]></category>

		<guid isPermaLink="false">http://www.nicolabortignon.com/?p=282</guid>
		<description><![CDATA[So, I decided to clone Plants vs Zombies. In my defense, I quote Picasso, ”Bad artists copy. Good artists steal,” but I’m not here to justify myself. It all starts with my girlfriend &#8211; which is an important note to make, in case someone some day decides to take legal action against me, I want [...]]]></description>
			<content:encoded><![CDATA[<p>So, I decided to clone Plants vs Zombies. In my defense, I quote Picasso, ”Bad artists copy. Good artists steal,” but I’m not here to justify myself.</p>
<p style="text-align: left;">It all starts with my girlfriend &#8211; which is an important note to make, in case someone some day decides to take legal action against me, I want to record to show it was all her fault!</p>
<p>It happens quite often that in order to stop her bothering me while working, I throw the iPad on the table and let her enjoy some “random game” time.</p>
<p>Unfortunately, there is one random game which does not always get picked randomly: Plants vs Zombies. She easily gets addicted to it, despite having finished it several times. Now she asks me to provide her with new games, but seems that the hole left by PvZ is cannot be filled; not by red flying birds, nor by chandeliers that fall on a malformed frog (isn’t it?).</p>
<p>In 4 words: I am f**ed up!</p>
<p>Chaining myself in front of the Popcom/EA head quarters begging for a sequel led to nothing but a waste of time. It&#8217;s at this point I get the idea: Do it yourself.</p>
<p>I’ll also spice up the project by throwing in some constraints and presenting it as a social psychology experiment. Let’s call this Socially Driven Game Development (dev note – TDD is old fashioned, right?!)</p>
<p>There are two lessons to be drawn from Notch’s Minecraft hype; First, you must keep feeding and getting feedback from the community around your game, and in case you don’t have one, you must do your best to get people involved and feel they are part of the project. The second lesson is that mining seems to be the only thing people want to do from dawn &#8217;till dusk, but for this project, that lesson can be ignored.</p>
<p>So I decided to clone Plans vs Zombies, and share the progress in a daily, on-line diary, letting people inspire design decisions; from gameplay to graphics, from music to additional content.</p>
<p>In addition I&#8217;ll add one or more constraints, such as:<br />
- Limit the time I work on project &#8211; No more than two hours per day or ten hours per week (this forces me consider this as a side project)<br />
- Recap the day&#8217;s work every week – sharing any progress and development, as well taking in feedback regularly<br />
- End every post with a question &#8211; sometimes a Yes/No question, sometimes a poll, and sometimes a so-called “open-question”<br />
In the spirit of the last rule, I give you the project&#8217;s first question:<br />
What is lacking from Plants vs Zombies?</p>
<p>Scroll straight down to the comments section and write your ideas. After that, scroll back up here and keep reading my thoughts on the matter (mostly superficial views)<br />
- Not homogeneous across platforms (I found out that iPad version has features that iPhone doesn&#8217;t, and vice versa, like Zen Garden)<br />
- Not available on a few platforms &#8211; Not a big issue, but I bet the Blackberry and Nokia markets are potentially fertile markets that aren&#8217;t explored enough.<br />
- Not a real growing path &#8211; Except gaining all the plant types, there&#8217;s really no other motivator to keep playing. Suns are not permanent through matches, money is not useful after you bought all the items from the shops.<br />
- Longevity is miserable in less than 5 hours.<br />
- It lacks an “entrepreneurial view” &#8211; Come on, I don’t want to be stuck in my backyard all my life. I want to conquer the world with my plant army!</p>
<p>Your turn now, see ya tomorrow</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nicolabortignon.com/create-plants-vs-zombies-clone-day-1/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Motivate Developers</title>
		<link>http://www.nicolabortignon.com/motivate-developers/</link>
		<comments>http://www.nicolabortignon.com/motivate-developers/#comments</comments>
		<pubDate>Mon, 15 Aug 2011 13:27:59 +0000</pubDate>
		<dc:creator>Nicola Bortignon</dc:creator>
				<category><![CDATA[Team Management]]></category>
		<category><![CDATA[Life style]]></category>
		<category><![CDATA[Psycology]]></category>

		<guid isPermaLink="false">http://www.nicolabortignon.com/?p=256</guid>
		<description><![CDATA[&#160; I have always considered the summer brake as a good period for self-evaluations more than year-end when too many external factors blind your analytic skill. Doing this i found very useful writing down the list of what i consider motivating for a developer trying to extract some boolean questions for auto test your motivation [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignnone" title="Demotivated Developer" src="http://www.nicolabortignon.com/wp-content/uploads/2011/08/team.jpg" alt="" width="700" height="256" /></p>
<p>&nbsp;</p>
<p>I have always considered the summer brake as a good period for self-evaluations more than year-end when too many external factors blind your analytic skill.<br />
Doing this i found very useful writing down the list of what i consider motivating for a developer trying to extract some boolean questions for auto test your motivation level.</p>
<p>As a project manager, or architect you don&#8217;t have the privileges to handle all the following factors that usually refer to managers and ceo, but it&#8217;s always interesting try to put on others&#8217; shoes to better understand feeling and reasons.</p>
<p><span id="more-256"></span></p>
<h2>Get rich or die trying</h2>
<p><img class="alignleft" style="color: #444444; font-family: Georgia, 'Bitstream Charter', serif; line-height: 1.5; border-style: initial; border-color: initial; margin-top: 4px; margin-right: 24px; margin-bottom: 12px; margin-left: 0px; float: left; display: inline; border-width: 0px;" title="Maslow Hierarchy of Needs Image" src="http://upload.wikimedia.org/wikipedia/commons/6/60/Maslow%27s_Hierarchy_of_Needs.svg" alt="" width="347" height="258" /></p>
<p>This is one of the most controversial point: <strong>money</strong>. According to the</p>
<p>Maslow&#8217;s Hierarchy of needs this is really a basic factor of everyone happiness. Point is that developers don&#8217;t want to be reach, they just want to be rewarded proportional with their efforts. Money is a good trading indicator. It is also the only attribute that let you objective compare your job with others&#8217;. Don&#8217;t think to your developers as people that just want to be rich exploiting your company, but don&#8217;t do the error to think them as volunteers. <strong><em>You must be sure to remove money as a developer problem</em></strong>. So CEO, consider the idea to compensate well your employers. This also let you decide to do benefits according to the singular developer effort inside the team.  Also don&#8217;t try to standardize the salary with role categories against each one developer capabilities. Developers are different, with different backgrounds and different motivation, mimic false fair because you are just not able to say &#8220;A is better than B so A deserve more money&#8221; marks the fact you are not the right person for the CEO role (decision maker first). Also bonuses must always be motivated in front of the entire team, for at least two reasons:</p>
<ol>
<li>You can be wrong, discussing with team on reason why A gain a +10% this month can lead to better knowing if A really deserve the bonus due to the reason you have in mind or not. (Again this request a NOT-FALSE-FAIR team, that is, in this blog post, assumed as pre requirement)</li>
<li>In case you are right, this let other see the Cause-Effects of bonus strategy. Sound like dog training, i know, but it works in the same way. The dog catch the ball and bring it back, the dog got the biscuit</li>
</ol>
<p><span style="font-size: small;"><span class="Apple-style-span" style="line-height: 24px;">Otherwise you know what will happen, even the most motivated developer in the world just take apart quitting your company and move to a greener garden. It&#8217;s simply, it&#8217;s not about work itself, or something against you, it&#8217;s just the inner happiness mechanism described by Maslow that subconsciously demotivate your employer</span></span></p>
<h2>Stillness or excessive dynamism</h2>
<p>A not so easy balance to reach inside your team is finding the middle between stillness and dynamism.</p>
<p>Stillness is the feeling that time is passing and the decision are not taken, the event just flow away, and you are somehow try to chasing that without success. Developers in general are not meant to takes decisions, project managers do, but they easily feels if the project manager is doing his work properly or not. A developers should not takes care of what happens with the customers except for technical reason, so in the case you are a project manager, be transparent and try to handle your dev team with a constant flow. Variations from outside are always dangerous and lead to uncontrolled changes.</p>
<p>On the other hands we have the excessive dynamism that is the opposite way to react to the main project management problems (lacks of requirements, unrealistic deadlines, etc). The behavior of an over excited project manager usually starts with an excessive number of meeting, a progressive relaxation of the team norms and a degenerative flood of useless questions like &#8220;What is needed? How long does it take? How big is this problem?&#8221;. You got where&#8217;s the problem: you can shift responsibility over the developer. Developer can take your work, once, twice, but really, no more than three times in an year. If you are unable to manage a project ask your developer to do for you is not the solution, especially if the additional effort required is not payback (see previous paragraph)</p>
<h2>A poor work environment</h2>
<p>This is not a physical matter, e.g. place where it&#8217;s too loud, there&#8217;s no privacy, you get lots of interruptions etc.. This is also about your digital environment: slow builds, slow unit tests, slow desktops etc. They suck productivity and reduce enthusiasm. A bad environment can destroy motivation or at the very least be a distraction.</p>
<p>If there&#8217;s something that stop your developer flow for more than 10 minutes you must find out where&#8217;s the problem and fix it or ask someone to fix. Tools are made for speedup process not for slow it down, so if you are using SVN please be sure that all know how to use it, if you are super proud of your new compilers suite be sure that all developers know the new tools and how to use it, etc etc etc.</p>
<p>The best way to do that is to keep an internal document where all this information is stored (yeah, consider doing this even if you are a solo) and start delegate to someone the role of administrator. Delegate means explicit the new role request, don&#8217;t just ask him to &#8220;fix this please&#8221; or &#8220;look into this issue, there&#8217;s something that doesn&#8217;t work&#8221;. Be clear and explain always the issue and why it must be fix. If you are a developer you must point it out sooner all the situations that stop your workflow. A good work environment is a necessary requirement. Developer are by nature &#8220;programmed&#8221; for not wasting time so why force them doing&#8230;</p>
<h2>Passive and Active Learn</h2>
<p>Unless your work can be done by a robot, i&#8217;m sure you are learning something from your daily work. There are two way in doing this, the passive way, while you iterate over the project problems solving, and the active way that include the awareness of the learning process.</p>
<p>Active learning must be sponsored somehow from the company you work for. As Team Manager you must include in the weekly timing few times for active learning. Developers love to learn &#8211; new languages, new tools, new frameworks even if not required by upcoming project. Soon or later you&#8217;ll need this knowledge. Don&#8217;t be so fool, developers can just survive with passive learning, it&#8217;s like put a newbie on a plane and ask him to pilot it. It success only in films, in real time you crash at the ground. It&#8217;s the same with developers. You can put them on a project if they have not the knowledge to effort it, there a small effort you can ask to them on the learning curve, and in any case someone must know where&#8217;s the parachute before the project crashes.</p>
<h2>Make it fan</h2>
<p>Developers in general love to solve problems in a controlled environment &#8211; whether it&#8217;s how to integrate a new features, which algorithm is better for a given situation, etc ..<br />
Know your developers and align the challenge to their attitudes, team will learn from others&#8217; skills. Set a monthly challenge and reward the winner. This will force developers take part while they are working on main project, enhancing their multitasking skill, it is also a good chance to learn from different solutions. Review results leads to a wider consciousness of team members.</p>
<h2>Let them be proud</h2>
<p>Have you ever listen how your developer describe their work to third person (not skilled in IT)? Are they going to say something like &#8220;I&#8217;m working on the new revolutionary application for &#8230;. &#8221; or are they say something like &#8221; Uhh, to boring to explain &#8230; &#8221;</p>
<p>Developer must be proud of what they are working on, only in this way they&#8217;ll fell the work they are doing as a personal grow, not only as the boss bank account work.</p>
<p>Choose your project wisely, mix developers attitude with needs, try to underline the thing to be proud within any project ,and ask developers to find it out and abstract from the single project. Shift and focus the attention to the important thing</p>
<p>As a conclusion i&#8217;d like to add an additional point: <strong>listen to your developers</strong>.</p>
<p><em>&#8220;When a developer speaks, someone should listen. When several developers are saying the same thing, someone should listen and act . . .quickly&#8221;</em></p>
<h2>Test your motivation</h2>
<p>Ok now you know my personal view on the topic, following now some boolean question (this give a turin taste to the test). Note down the number of positive answer, and check your motivation range.</p>
<p>A) <strong>Financial (5pt)</strong></p>
<p>A1. Is your monthly salary equal to the global salary?</p>
<p>A2. Are your salary including benefits in percentage of company year revenues?</p>
<p>A3. Are lunch and/or dinner included in your contract?</p>
<p>A4. Is there any perks including local activities (Gym,Swimming Pool,Parties)?</p>
<p>A5. Are additional hard time tasks payed back?</p>
<p>B) <strong>Project Management (5pt)</strong></p>
<p>B1. Did you rarely face lack of requirements ?</p>
<p>B2. Did you rarely face unrealistic deadlines?</p>
<p>B3. Did you rarely face shifts in deadlines ?</p>
<p>B4. You never take decision that someone else should takes.</p>
<p>B5. Nobody takes decision you must takes.</p>
<p>C) <strong>Work Enviroment (5pt)</strong></p>
<p>C1. Company provides you hardware and software needed for daily development tasks.</p>
<p>C2. Do you have your private working space ?</p>
<p>C3. You are not interrupted during your dev phases.</p>
<p>C4. Surrounding environment is quiet enough for your needs.</p>
<p>C5. There&#8217;s enough coffee for developers need (believe me, this point value is really high).</p>
<p>D) <strong>Personal Motivation (5pt)</strong></p>
<p>D1. I take part of something i&#8217;m pride of.</p>
<p>D2. I&#8217;m part of a team, and my ideas are taken seriously</p>
<p>D3. I learn in the last year at least two fundamental skills i&#8217;ll include in my resume</p>
<p>D4. I was encourage participating in community developer events (user groups, code camps), blogs (share links across the team), books (monthly bookshelf anyone?) and conferences.</p>
<p>D5. Chance to develop personal project within working hours.</p>
<p style="text-align: center;">
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nicolabortignon.com/motivate-developers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Adobe Air 3.0 Captive</title>
		<link>http://www.nicolabortignon.com/captive-adobe-air-3/</link>
		<comments>http://www.nicolabortignon.com/captive-adobe-air-3/#comments</comments>
		<pubDate>Sun, 14 Aug 2011 16:05:07 +0000</pubDate>
		<dc:creator>Nicola Bortignon</dc:creator>
				<category><![CDATA[AIR]]></category>
		<category><![CDATA[AIR 3.0]]></category>
		<category><![CDATA[New Features]]></category>
		<category><![CDATA[Runtime]]></category>

		<guid isPermaLink="false">http://www.nicolabortignon.com/?p=225</guid>
		<description><![CDATA[Finally Adobe Air 3.0 was committed to the labs. There are some really cool features in this new milestone release. The one i&#8217;d like to talk today is Captive. How many times did you face issue on installing and executing air apps in non administrator system? Isn&#8217;t this one of the main reason why Zinc [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.nicolabortignon.com/wp-content/uploads/2011/08/galactus.jpg" alt="Wrap your air app and framework together - Artwork by Reuno.net" /></p>
<p>Finally <strong>Adobe Air 3.0</strong> was committed to the <a title="Adobe Labs - Adobe Air 3" href="http://labs.adobe.com/technologies/flashplatformruntimes/air3/">labs</a>.<br />
There are some really cool features in this new milestone release. The one i&#8217;d like to talk today is Captive.<br />
How many times did you face issue on installing and executing air apps in non administrator system? Isn&#8217;t this one of the main reason why Zinc found his way on our heart?<br />
Well, adobe seems to grant the developers wishes let us wrapping together Air file and the runtime. The final result is a deployed compiled executable file (.exe for Windows or .dmg for OSX).<br />
No room for linux though!<br />
<span id="more-225"></span></p>
<h2>Following a detailed list of the captivity feature/characteristics:</h2>
<p>&nbsp;</p>
<ul>
<li>you can compile <strong>only for the OS family you are running the adt compiler</strong>, so if you want to create both .exe and .dmg version of your software you need to run both the operative system, and do the compile operation twice</li>
<li>process is very close to the Native Process compilation we saw in 2.6, so<strong> there might be chance to see</strong> this feature included <strong>in Flash professional in short time</strong></li>
<li>captive compiled executable apps <strong>can target native processes</strong> part of the api</li>
<li>captive compiled executable apps <strong>can run without administrator privileges</strong> (somehow not far from how zinc does)</li>
<li>captive compiled apps <strong>can be execute from externals support</strong>, but not from remote resources like network storage (at least at this stage, i&#8217;m sure there will be changes on this side)</li>
<li>captive <strong>doesn&#8217;t improve performance</strong> of your app. This comes from an oddish simplifications Adobe did while presenting captive. Captive doesn&#8217;t works as the iPhone packager did. There&#8217;s no cross compilation or byte code translation into native code. It just wrap all the AIR frameworks libraries with your (still exists) swf file. Open, at your risk, the compiled file to dig into.</li>
<li>captive feature also works for <strong>android application</strong>. This side isn&#8217;t under my radar of interest. I&#8217;m just curious if this let you &#8220;deploy&#8221; newer framework version on older device. I&#8217;m imaging wrapping with Captive the 3.0 framework and deploy the resulting APK to the oldest android devices .. kaboom!</li>
</ul>
<div><span style="font-size: small;"><span class="Apple-style-span" style="line-height: 24px;"><br />
</span></span></div>
<h2>How it works? Gimme the code!</h2>
<p>At this point there&#8217;s nothing too much esoteric to do.. just run the adt command line tool. In order to do that you must:</p>
<ol>
<li>Download the <a title="Adobe AIR SDK how to" href="http://kb2.adobe.com/cps/495/cpsid_49532.html">AIR SDK</a> and extract as explained here</li>
<li>Target the right swf version. 13 is the SWF version that corresponds to AIR 3, so you need to tell the runtime what version of the APIs you want to use. While compiling with mxmlc just add the compiler argument &#8220;swf-version=13&#8243; or on your favorite ide just dig for something like  &#8221;Project Properties,&#8221; then &#8220;Flex Compiler.&#8221; In the &#8220;Additional compiler arguments&#8221; box, add &#8220;<strong>-swf-version=13</strong>&#8220;.</li>
<li>(Optional) open terminal and navigate to your sdk folder. Navigate now to bin/  change privileges of the ADT file using<em> </em>command <em></em><em><strong> </strong></em>
<div id="code">chmod 775 adt</div>
</li>
<li>now from the same folder you can run adt using the command, please note the bundle string that identify the desktop target (against the Android option apk-captive-runtime ). The other ADT options are the common parameters.<br />
<table border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td>
<div>
<div>
<div id="code">adt -package SIGNING_OPTIONS -target bundle SIGNING_OPTIONS &lt;output-package&gt; ( &lt;app-desc&gt; FILE-OPTIONS | &lt;input-package&gt; )</div>
</div>
</div>
</td>
</tr>
</tbody>
</table>
</li>
</ol>
<div><span style="font-size: x-small;"><br />
</span></div>
]]></content:encoded>
			<wfw:commentRss>http://www.nicolabortignon.com/captive-adobe-air-3/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Bitwise Operations and Manipulations in AS3</title>
		<link>http://www.nicolabortignon.com/as3-bitwise-operations/</link>
		<comments>http://www.nicolabortignon.com/as3-bitwise-operations/#comments</comments>
		<pubDate>Sat, 23 Apr 2011 10:05:43 +0000</pubDate>
		<dc:creator>Nicola Bortignon</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://localhost:8888/wordpress4/?p=1</guid>
		<description><![CDATA[On the path of beeing the As3 world master scripter there is something important to know about number manipulation. Even if we are normally dealing with the as3 Number type such uint, int and Number as normal object (java type wrapper like), we can take advance on how the integer number are rappresented and handle [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.nicolabortignon.com/wp-content/uploads/2011/05/11.png" alt="Bitwise Operation Machine" /><br />
On the path of beeing the As3 world master scripter there is something important to know about number manipulation.<br />
Even if we are normally dealing with the as3 Number type such uint, int and Number as normal object (java type wrapper like), we can take advance on how the integer number are rappresented and handle by the flash player.</p>
<p>The base concept, as &#8220;Bitwise&#8221; may suggest, is to use the bit representation of the number.<br />
A number can be represented in an infinite number of ways. The representation we are used to is called decimal, or base 10.<br />
The binary, or base 2, number system is the one that computers use to represent numbers in memory. Since we&#8217;re dealing with base 2, there are only two digits available, namely 0 and 1. Each digit is multiplied by successive powers of two to obtain the number&#8217;s overall value.</p>
<p>Following some of the useful/interesting implementation of the art of handle bit.</p>
<p><span id="more-1"></span></p>
<h3>Multiplication and Division by 2 (or multiple of 2)</h3>
<p><span style="font-weight: normal; font-size: 13px;">bitwise left and right shift</span></p>
<pre class="brush:as3">// this is the normal way to divide or moltiply y for a multiple of
// 2 (0,1,2,4,8...)

y *= Math.pow(2,x);
y /= Math.pow(2,x);</pre>
<pre class="brush:as3">// this is the bitwise way to divide or moltiply,
// note that the X is the number of positions to shift the number

y &lt;&lt;= x // Multiplication by 2^x
y &gt;&gt;= x // Division by 2^x</pre>
<p>Even if is possible only to moltiply/divide number by 0,1,2,4,8,16 and so on, consider that the bitwise function is faster up to 3.5 times of the usual one.</p>
<h3>Cast using bitshift</h3>
<p>Since the bitwise operation results in an integer value (int or uint) we can use the bitshifter also for casting Number to int (uint)<br />
This is 10% fastwer of the normal casting. This also can be used to emulate the math.floor on a double ;)</p>
<pre class="brush:as3">// Normal casting
x = int(1.232)

// casting with bitshifting
x = 1.232 &gt;&gt; 0;</pre>
<h3>Swapping int with the Xor Operator ( ^ )</h3>
<p>&nbsp;</p>
<p>The Exclusive disjunction, also called exclusive or (symbolized XOR or EOR), is a type of logical disjunction on two operands that results in a value of true if exactly one of the operands has a value of true. A simple way to state this is &#8220;one or the other but not both, but i&#8217;m sure you still know this. What probably you don&#8217;t is this advance and smart use of the XOR.</p>
<p>Assume that x and y are two int (uint) already sets.</p>
<pre class="brush:as3">x = x ^ y;
//  x is equal to x^y       y is equal to y
y = x ^ y;
 //  x is equal to x^y       y is equal to (x ^ y )^ y == x
x = x ^ y;
// x is equal to (x ^ x) ^ y  == y     y is equal to x</pre>
<p>like explained in the comment you actually swap two variables without using an auxiliar one and this is also 1.4x times faster!</p>
<h3>Other interesting operations</h3>
<p>The modulo operator (%) can be easily replaced by an additive mask (with the AND &#8220;&amp;&#8221; operator).<br />
In other words, the number we need to use as our mask in order to perform a modulus operation on 2n is simply 2n &#8211; 1. To illustrate this, the following pairs of statements are all equivalent to one another:</p>
<pre class="brush:as3">x = y % 8;
x = y &amp; 7;

x = y % 32;
x = y &amp; 31;

x = y % 256;
x = y &amp; 255;</pre>
<p>The only difference is that using the mask is 6x faster than the normal modulo.<br />
For the same reason, using this way do determinate if a number is Even or Pair is much faster!</p>
<pre class="brush:as3">isEven = (i &amp; 1) == 0;  // if i is even return true, elsewhere false.</pre>
<p>the following one is probably the best one on encreasing performance side, it is 25x faster than the original Math.abs()</p>
<pre class="brush:as3">//version 1
i = ( x &gt;&gt; 31) ? -x :x;
//version 2
i = (x ^ (x &gt;&gt; 31)) - (x &gt;&gt; 31);</pre>
<p>Comparing two integers for equal sign</p>
<pre class="brush:as3">eqSign = a ^ b &gt;= 0;</pre>
<p>Sign flipping using NOT or XOR</p>
<pre class="brush:as3">i = ~i + 1;
//or
i = (i ^ -1) + 1</pre>
<h3>Bitmasks Theory</h3>
<p>&nbsp;</p>
<p>So what masks are? they are exactly what you think they are, a way for masking something and show the rest. There are mainly 3 functions on using bitmask:</p>
<p><strong>Masking bits to 1</strong><br />
To turn certain bits on, the bitwise OR operation can be used.Knowing that Y OR 1 = 1 and Y OR 0 = Y. Therefore, to make sure a bit is on, OR can be used with a 1. To leave a bit unchanged, OR is used with a 0.</p>
<p><strong>Masking bits to 0</strong><br />
To change a bit from on to off using the OR operation bitwise AND is used. When a value is ANDed with a 1, the result is simply the original value, as in: Y AND 1 = Y. However, ANDing a value with 0 is guaranteed to return a 0, so it is possible to turn a bit off by ANDing it with 0: Y AND 0 = 0. To leave the other bits alone, ANDing them with a 1 can be done.</p>
<p><strong>Querying the status of a bit</strong><br />
It is possible to use bitmasks to easily check the state of individual bits regardless of the other bits. To do this, turning off all the other bits using the bitwise AND is done as discussed above and the value is compared with 0. If it is equal to 0, then the bit was off, but if the value is any other value, then the bit was on. What makes this convenient is that it is not necessary to figure out what the value actually is, just that it is not 0.</p>
<p>So for exemple if you want to know the value for the 5th bit of a 8-bit number just AND it with a 00010000 mask.</p>
<h3>Bitmasks Implementations in as3</h3>
<p>The main havy use of bitwise operation in as3 is refeared on handling color data.<br />
As you probably know there are mainly two type of colour on flash the 24 bit (with 3 channel, and 8bit (255 value) for each color channel) and the 32 bit (that add the Alpha channel with its 8 bit value). Working with colors can be really painfull if you don&#8217;t keep in mind that they are only bits! So forget substring doublets, forget the 10-base arithmetic and start using what you learn on the lines above.</p>
<pre class="brush:as3">// EXTRACTING COMPONENTS
//24bit
var color:uint = 0x336699;
var r:uint = color &gt;&gt; 16;
var g:uint = color &gt;&gt; 8 &amp; 0xFF;
var b:uint = color &amp; 0xFF;

//32bit
var color:uint = 0xff336699;
var a:uint = color &gt;&gt; 24;
var r:uint = color &gt;&gt; 16 &amp; 0xFF;
var g:uint = color &gt;&gt;  8 &amp; 0xFF;
var b:uint = color &amp; 0xFF;</pre>
<pre class="brush:as3">// COMBINING  COMPONENTS
//24bit
var r:uint = 0x33;
var g:uint = 0x66;
var b:uint = 0x99;
var color:uint = r &lt;&lt; 16 | g &lt;&lt; 8 | b;

//32bit
var a:uint = 0xff;
var r:uint = 0x33;
var g:uint = 0x66;
var b:uint = 0x99;
var color:uint = a &lt;&lt; 24 | r &lt;&lt; 16 | g &lt;&lt; 8 | b;</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.nicolabortignon.com/as3-bitwise-operations/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Left Leaning Red Black Tree Implementation in AS3</title>
		<link>http://www.nicolabortignon.com/an-as3-left-leaning-red-black-tree/</link>
		<comments>http://www.nicolabortignon.com/an-as3-left-leaning-red-black-tree/#comments</comments>
		<pubDate>Wed, 08 Dec 2010 16:37:34 +0000</pubDate>
		<dc:creator>Nicola Bortignon</dc:creator>
				<category><![CDATA[Algorithms]]></category>
		<category><![CDATA[Data Structures]]></category>

		<guid isPermaLink="false">http://www.nicolabortignon.com/?p=113</guid>
		<description><![CDATA[One of the most interesting Data Structure out there is probably Tree. As the name may suggest, it&#8217;s about arranging item keeping in mind the typical tree shape ( reversed with the root on top,leafs on buttom). In this blog post i&#8217;ll try to cover the basic aspects of Trees, proposing a new implementation of [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.nicolabortignon.com/external_file/LLRBTree.JPG" alt="A bonsai" /><br />
One of the most interesting Data Structure out there is probably Tree. As the name may suggest, it&#8217;s about arranging item keeping in mind the typical tree shape ( reversed with the root on top,leafs on buttom).</p>
<p>In this blog post i&#8217;ll try to cover the basic aspects of Trees, proposing a new implementation of the Red-Black Tree.<br />
<span id="more-113"></span></p>
<p>If you arrived here, you probably know what a Red Black tree is, and why is an interesting data structure, just to refresh a little bit here following a quick overview:</p>
<p><strong>Requirements (invariants)</strong></p>
<p>1) A node is either red or black.<br />
2) The root is black.<br />
3) All leaves are black.<br />
4) Both children of every red node are black.<br />
5) Every simple path from a given node to any of its descendant leaves contains the same number of black nodes.</p>
<p>These introduced constraints against the less bounded binary search trees, let the Red-Black tree longest path from the root to any leaf beeing no more than twice as long as the shortest path from the root to any other leaf in that tree (balanced). This result in algorithm cost of search tend to O(log(n)). The downside is the insertion and delete cost of O(log(n)) too. I must say that is still a fair trade.<br />
The real downside of RB tree is the complexity of the algorithm behind it, that is hard to implement. Usually languages have they own basic implementation of data structures (major languages at least), if not already implemented there are some problems:</p>
<p>- books usually hide part of the implementation (sometimes they just skip and leave the hard work to the reader, since it&#8217;s an high risk task this is not a good idea)</p>
<p>- remove and insertion must provide the Recostruction and Coloration,that are the fixup process, to keep the Tree in the right form. In the original structure draft by Rudolf Bayer in 1972 wasn&#8217;t specified the effective implementation of the delete operation, so  through years there was many implementation, usually with many lines of code, and different approaches.</p>
<p>Before getting into the new RB implementation i must add some explanation about  language related issues.</p>
<p><strong><em>AS3 hasn&#8217;t any generics way to handle data. </em></strong></p>
<p>Generics is the ability to specify a type that will be used within a class without explicitly defining the type. Generics is the way this practice is know in Java world, for oldschool C++ the keyword is Template. In general writing code using generics let you manage one data structure for different type of objects without knowing exactly with object type will be later used.</p>
<p><em>(there is an interesting article on why as3 needs generics <a href="http://alecmce.com/as3/why-we-need-generics-in-as3">here</a>) </em></p>
<p>This means that we are unable to implement a general solution (read data structure), but we should typed and force typing just to get better performance (if you are thinking to handler generics object, believe me it&#8217;s a bad idea &#8211; dynamic type checking is always a bad idea on semi-compiled languages).<br />
So main point is to custom the generic code i wrote (and attach at the end of the blog entry) customizing to your specific purpose. (just search for the &#8220;object&#8221; and replace with your &#8220;type&#8221;.</p>
<p><strong><em>AS3 hasn&#8217;t any ready to use implementation of the comparable concept. </em></strong></p>
<p>This is not only a language lack, it&#8217;s about also the way developer think to the question.<br />
Main problem is that data structures usually deals with object, in doing this algorithms (search, order, insertion) take advance of the fact that object are comparable between each other.<br />
In java this concept is well implemented/exposed by the overridable method compares and the comparables interface.<br />
Unfortunatly again this is not a best practice used in the AS3 words.<br />
Let say, that dealing with data structure will force you to find a way to represent the concept that object are comparable and how to take a decision about the fact that A comes from B and not viceversa.</p>
<p><strong><em>AS3 hasn&#8217;t the concept of overloading method. </em></strong></p>
<p>This is slightly different from set default value to function formal values.<br />
The lack of overloading usually leads to an higher branches complexity (if-then-else levels).<br />
In my implementation i prefered to split overloaded methods into different methods instead of collapsing into one method with higher branches complexity.</p>
<p>So when you&#8217;ll download the implementation at the end of this blog post remember to:</p>
<p>1) strictly defined the type of values that LLRB tree handles (now is set to object, just search and replace it)<br />
2) choose a way to compare objects (actually i&#8217;m use int as keys, so you can easily define that keys A &lt; B &lt; C, at this point Collision is not handled, if you try to insert object with key B again into the tree, this simply override the B-object already in)<br />
3) be good with my implementation, in java would look much elegant, but as3 as some limits i must workarounded.</p>
<p><strong>What is a LLRB Tree</strong></p>
<p>Finally  straight to the point.<br />
In September 2008 (surprised for the recent date ?! ) <a href="http://www.cs.princeton.edu/~rs/">Robert Sedgewick</a> (a pillar in Computer Science panorama) proposed for the first time the Left leaning tecnique to color the Red Black Tree, introducing  additional invariant that all red links must lean left except during inserts and deletes.</p>
<p><img class="alignright" title="Statistics on Averange and worst case" src="http://www.nicolabortignon.com/external_file/LLRBStats.png" alt="" width="400" height="359" /></p>
<p>What may look like a &#8220;simply&#8221; modification leads to great results:<br />
- A <strong>random</strong> successful search examines <strong>lg(N) – 0.5</strong> nodes.  While the normal RB has a worst case where the search takes C * lg(N) where C is a constant &gt; 1.<br />
- The average size of left subtree exhibits log-oscillating behavior in growing tree<br />
- <strong>Experimental studies have not been able to distinguish these algorithms from optimal.</strong><br />
- Simplify the isomorphism from 2-3 and 2-3-4 tree: the left- leaning versions of 2-3 trees and top-down 2-3-4 trees differ in the position of <strong>one line of code</strong>.<br />
- Simple implementation (that&#8217;s true for me at least. Just 250 loc for the entire data structure and 120 for the core only, while a normal RB tree request around 400 for the core only.</p>
<p>Here the classes:</p>
<p><a href="http://www.nicolabortignon.com/external_file/LLRBTreeDS.zip">LLRB DataStruct   (2.9kb)</a></p>
<p>Here a firestarter piece of code:</p>
<h5>
<pre class="brush:as3">// CREATE A TREE
var tree:LLRBTree = new LLRBTree();
// ADD AN OBJECT
tree.put(key,object);
// SEARCH FOR AN OBJECT
tree.find(key);

// REMOVE AN OJBECT, returns the object removed
tree.remove(key);

// OTHER INTERESTING METHOD
tree.deleteMax(); // find and remove the higher element
tree.deleteMin(); // find and remove the lower element
tree.max(); // find the higher element
tree.min(); // find the lower element
tree.height() // the height of the tree.</pre>
</h5>
<p>Here a not so much interesting benchmark about time elapse in serching ordered data structures with a binary search (for array and vector) and llrb tree search. (Not a fan of this kind of benchmark, but ppl enjoy it, so here you are.)</p>
<table border="0" cellpadding="2">
<tbody>
<tr>
<td width="125" height="60" bgcolor="#ccc">
<div>
<p>N° of Elements</p>
</div>
</td>
<td width="106" bgcolor="#ccc">
<div>LLRB<br />
(Object generics)</div>
</td>
<td width="70" bgcolor="#ccc">
<div>Vector<br />
&lt;Typed&gt;</div>
</td>
<td width="104" bgcolor="#ccc">
<div>Array</div>
</td>
</tr>
<tr>
<td bgcolor="#e5e5e5">
<div>50000</div>
</td>
<td bgcolor="#e5e5e5">
<div>1</div>
</td>
<td bgcolor="#e5e5e5">
<div>4</div>
</td>
<td bgcolor="#e5e5e5">
<div>7</div>
</td>
</tr>
<tr>
<td bgcolor="#efefef">
<div>100000</div>
</td>
<td bgcolor="#efefef">
<div>1</div>
</td>
<td bgcolor="#efefef">
<div>9</div>
</td>
<td bgcolor="#efefef">
<div>21</div>
</td>
</tr>
<tr>
<td bgcolor="#e5e5e5">
<div>500000</div>
</td>
<td bgcolor="#e5e5e5">
<div>1</div>
</td>
<td bgcolor="#e5e5e5">
<div>15</div>
</td>
<td bgcolor="#e5e5e5">
<div>47</div>
</td>
</tr>
</tbody>
</table>
]]></content:encoded>
			<wfw:commentRss>http://www.nicolabortignon.com/an-as3-left-leaning-red-black-tree/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Number in AS3</title>
		<link>http://www.nicolabortignon.com/numbers-in-as3/</link>
		<comments>http://www.nicolabortignon.com/numbers-in-as3/#comments</comments>
		<pubDate>Sat, 20 Nov 2010 12:57:13 +0000</pubDate>
		<dc:creator>Nicola Bortignon</dc:creator>
				<category><![CDATA[Actionscript 3]]></category>
		<category><![CDATA[Numerical Calculus]]></category>

		<guid isPermaLink="false">http://www.nicolabortignon.com/?p=83</guid>
		<description><![CDATA[As programmers we are used to deal with numbers every day. We feel good with math, since there are no shading, and any assertion can be only true or false. What we usually don&#8217;t know is that computers make errors. They do it lots of time, even on basic calculation,where every an human usually dosn&#8217;t. [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.nicolabortignon.com/wp-content/uploads/NumbersInAS3.jpg" alt="Dice Cube" /><br />
As programmers we are used to deal with numbers every day.<br />
We feel good with math, since there are no shading, and any assertion can be only true or false.<br />
What we usually don&#8217;t know is that computers make errors. They do it lots of time, even on basic calculation,where every an human usually dosn&#8217;t. Knowing this will let us handling the sad problem.</p>
<p>Even if ActionScript 3 offers us only 3 basic data Types (int, uint and Number) that is , compared with other Languages really a small number, we still suffer the same problem, since is not a language problem, but simply how computers rappresents numbers.</p>
<p><span id="more-83"></span><br />
<strong>The Floating Point rappresentation.</strong></p>
<p>In Math we usually work with Real numbers (the R set) that are an infinite set of number, where number can have an infinite number of digits (basicly periodical and irrational). Let&#8217;s think to PI or the result of fraction like 1/3 to image fews.<br />
Good exemple to get this idea is to think to a number, than divide by 2, and iterate this: I challange you finding an end to this.<br />
A calculator has a limited number of significant digit, that let us figuring out that we can&#8217;t rappresent every number in R.<br />
There are also some &#8220;minor&#8221; problem on how a number is rappresentend inside a calculator, that is the base: we count in base 10 (we have 10 fingers we can count on, in past other base was picked like 60 and 12, both smarter than base 10, due to the bigger number of natural divisor of the base), calculators work in base 2 (since the electronic behind easily works with 2-state voltage condition).<br />
Both the above reason lead to the floating point rappresentation, that even if is not the only existing rappresentation is the most used. (Other two major rappresentions are Fixed point and integer).<br />
The advantage of floating point rappresentation over others, are the wider range of values it can rappresent.<br />
Since the concept of Floating point was formulated first time, many standards was proposed, IEEE decided to make their own standard set of rules for what was recorded in 2008 as IEEE 754 FP rappresentation scheme.</p>
<p>The idea is to use 4 main format, based on the avaiable bit (note: i&#8217;m not used to make plural of words like &#8220;bit&#8221; ), that are 16 (Half), 32 (Single), 64 (Double), 128 (Quadruple).<br />
The avaiable bit are divided into 3 groups: Sign, Exponent, Significant. First group &#8220;Sign&#8221; is composed by one bit only, 0 if the number is positive, 1 if negative. Exponent group contains 8 bit of the 32 in Single format and 11 bit of the 64 in double format. Exponent (in the 8bit case)  can assume 256 different values (2^8): 0 and 255 are reserved number, while the other values rappresent number between -126 and 127 (a tecnical note: this process is called polarization of the number and don&#8217;t request a bit as sign, they just move the interval from 0-254 to -126 and 127 in the decoding phase)</p>
<p><img src="http://www.nicolabortignon.com/wp-content/uploads/64_bit_floatingPoint.png" alt="Floating Point 64bit Rappresentation" /></p>
<p>The bit left (23 in the single rappresentation and 52 on the 64 bit rappresentation) are used for the Significant group. It rappresents, as name can suggest, the significant digits of the number normalized. This number is also called &#8220;mantissa&#8221;. The process of normalization is needed for avoiding different rappresentation of the same number.<br />
For exemple the number  30 can be write as 3*10^3, or as 300*10^-1, forcing the normalizationis the only way to know that 30 can be rappresented in Fp only as 0.3 * 10^2.</p>
<p>So now we have all our parts to star moving our &#8220;real life&#8221; number into floating point rappresentation.<br />
A general number can be rappresented as fl(x) = sgn(x)(0.a1a2&#8230;an)b^p</p>
<p><strong>The Problems with FP.</strong></p>
<p>We said that we have a limited number of bits. this automaticly set an upper bount to our desire of mapping real world number into a calculator. Without any standard rappresentation we can easily know that n bit can rappresent up to 2^n-1 number (where any number is +1 from the previous).<br />
Living in the &#8220;integer&#8221; world is not so cool, and soon we need our point.</p>
<p>This is where floating point world start.</p>
<p>On 64bit double precision, upper bound is 1.79769313486231e+308 that is the result of a all-1 mantissa and the maximum exponent.Lower bound (in the absolute meaning, so the closest number to 0) is 4.9406564584124654e-324.</p>
<p><img src="http://www.nicolabortignon.com/wp-content/uploads/floatingPointDistribution.jpg" alt="Floating Point 64bit Rappresentation" /></p>
<p>As you can see in this image, the upperbound is marked both on the Minus and on the Plus side, the next value major than the Upperbound is marked as Infinity (+inf and -inf). This is a marked set of bit that floating point notation use for keep consist some operation (like multiply a number for infinity resulting in infinity)</p>
<p>What really metter is the distribution of number rappresented by the curve, and the hole between any floating point number in that.<br />
This is also called FP relative accuracy where &#8220;Accuracy&#8221; refers to how close a measurement is to the true value.</p>
<p>Just run the following as3 code.</p>
<p><strong> </strong></p>
<pre class="brush:as3">var e = 1;
var k = 0;

while((e+1) &gt; 1){
	e /= 2;
	k++;

}
trace(e *= 2,k);
trace( "The number 1: ", 1);
trace( "The closer smaller number to 1: ", 1+e);
trace( "The useless addition; ", 1+e/2);</pre>
<p>We actually found the closest number to 1, and we also proof that any try to add number minor than this number is useless.<br />
This magic number is called EPS, and rappresent the space between two close FP number. Any number between don&#8217;t exist in calculator.<br />
We are facing precision loss of the result.<br />
This affect all the basic operation, and some property we normaly use are not longer valid.</p>
<p>Associative property is not valid in FP:</p>
<p>(x+y)+z != x+(y+z)<br />
(x*y)*z != x*(y*z)</p>
<p>(ie x = −2^100, y = 2^100, and z = 1.)</p>
<p>Distributive propery is not valid in FP:</p>
<p>x*(y+z) != (x*y)+(x*z)</p>
<p>(ie x = 0.5, y = largest possible number, and z = 1)</p>
<p>Simmetry is not valid in FP:</p>
<p>x*y != y*x</p>
<p>(ie x = 0.4 , y=0.3)</p>
<p><strong>Conclusion</strong><br />
Working with Floating Point operations can be legal in principle, but the result can be impossible to represent in the specified format, because the exponent is too large or too small to encode in the exponent field. Such an event is called an overflow (exponent too large), underflow (exponent too small) or denormalization (precision loss).</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nicolabortignon.com/numbers-in-as3/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Gone in 15 seconds Contest &#8211; Chapter I</title>
		<link>http://www.nicolabortignon.com/gone-in-15-seconds-contest-chapter-i/</link>
		<comments>http://www.nicolabortignon.com/gone-in-15-seconds-contest-chapter-i/#comments</comments>
		<pubDate>Sat, 24 Jul 2010 14:38:23 +0000</pubDate>
		<dc:creator>Nicola Bortignon</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://localhost:8888/wordpress4/?p=39</guid>
		<description><![CDATA[Introduction: Summer evenings may be so borings, we all know the &#8220;lazy dog layed on sofa&#8221; habit takes over! So why not gettin involved into an as3 contest? Contest&#8217;s name comes from the well know trash-movie, with a lower time limit (15seconds is the time before flash player goes in timeout). So, what are you [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: left;"><img class="alignleft" style="float: left; margin: 0 5px 0 0;" src="http://www.nicolabortignon.com/external_file/gone15secs.png" alt="Gone in 15 sec" /></p>
<p style="text-align: left;">
<p style="text-align: left;">
<p style="text-align: left;">
<p style="text-align: left;"><strong>Introduction:</strong></p>
<p>Summer evenings may be so borings, we all know the &#8220;lazy dog layed on sofa&#8221; habit takes over! So why not gettin involved into an as3 contest?<br />
Contest&#8217;s name comes from the well know trash-movie, with a lower time limit (15seconds is the time before flash player goes in timeout).</p>
<p>So, what are you suppose to do? Write code that  solve the following problem in less than 15seconds.<br />
Well, the main aim of the contest is to reach the lowest time, the upperbound limit is just to let you know that a brutal force approach will not work this time!</p>
<p><span id="more-39"></span><br />
<strong>Updates:</strong></p>
<p>Deadline moved to 16th August</p>
<p><strong>Goals of the contest:</strong></p>
<p>1.Share knowledge<br />
2.Recognize math as still a key skill, even on the daily work (i&#8217;ll come back on this as much as i can)<br />
3.Get a chance to try a &#8220;think-before-code&#8221; approach to a complex problem.<br />
4.Spend, I hope happy, hours on Optimizations, Data Structures and Algorithm complexity Topics.</p>
<p><strong>Contest topic:</strong></p>
<p>In math, as in Science in general, there are some still not solved problems.This means that we can&#8217;t give an answer to a particular question.<br />
One of this problems comes from Lothar Collatz. His conjecture asks if for every n (with n an integer number) the iteration</p>
<p><span class="smile"><img class="aligncenter" src="http://www.nicolabortignon.com/external_file/NumberedEquation1-1.gif" alt="Gone in 15 sec" /></span></p>
<p>always returns to 1. Actually this is formally undecidable even if there was (and still there is) a high number of mathematic minds that keep trying to give the problem an answer.<br />
For your luck, this is not the contest&#8217;s task.</p>
<p><strong>Contest task:</strong></p>
<p>Using the Collatz rule, and starting for ie with 11, we generate the following sequence:</p>
<p><em>11 -&gt; 34 -&gt; 17 -&gt; 52 -&gt; 26 -&gt; 13 -&gt; 40 -&gt; 20 -&gt; 10 -&gt; 5 -&gt; 16 -&gt; 8 -&gt; 4 -&gt; 2 -&gt; 1</em></p>
<p>we can call this a chain of 15 steps that leads to 1.</p>
<p>Write a function</p>
<pre class="brush:as3">collatz(upperBound:Number):Number</pre>
<p>returned value i need the number N < upperBound that produces the longest chain between all the numbers from 1 to upperBound.</p>
<p><strong>Submissions Testing:</p>
<p>Every submission will test with <a href="http://www.gskinner.com/blog/archives/2010/02/performancetest.html">Grant Skinner Performance Test v.2</a></p>
<p>There will be just a call to the funzion like collatz(n) where n will be a secret number (between 5 and 11 millions). The reason why this number will keep secret till the end of the contest is to avoid specific assumptions (that are in somehow possible, knowing the starting number).<br />
The test will run on a MacBookPro 2006 (2.3ghz &#8211; 2gb ram), on flash player (regular not debugger version) 10.1.53.64</p>
<p>With daily upgrade, i&#8217;ll publish the results from submitters, like this way:  nicolabortignon &#8211; 14.999ms. Top five positions will not display the timing, this means that all the top 5 positions timing is &lt; than 6th. Top 5 positions will not order, so we will know the winner (and top 3) only at the end of the contest. I hope this push you to keep searching for a better solution even if you are on top.<br />
I warmly suggest you not to share the entire submitted code, since the contest will be close; i really like instead to see you discussing (here on comments or wherever you prefear) about the work in progress so feel free to exchange suggestions.</p>
<p><strong>Sumbissions Rules</strong> (inspired by mikechambers):</p>
<ol>
<li>Code must be sended to (<em>info[at]nicolabortignon .com</em>) by 24:00, PST, Sunday, August <del datetime="2010-08-05T05:43:25+00:00">8th.</del> 16th</li>
<li>Code must be written in ActionScript 3.</li>
<li>All .as file must including the Name and contact information from the author.</li>
<li>Code must be release under an <a href="http://www.opensource.org/licenses/mit-license.php">MIT license</a> (includer on the header of the main .as file)</li>
<li>Try to comment out as much clear as you can the code</li>
<li>If the value returned from the function is wrong, submission will not get in consideration</li>
<li>Code that dosn&#8217;t compile will automaticly exclude the author from the contest  (so pls double check if it compiles before sending).</li>
<li>Code must authoring on Flash CS3 or aboves (Flex dependency will not allow).</li>
<li>External Libraries included in the code must be attached to the submission.</li>
<li>Code cannot require any additional tools, pre or post processing steps.</li>
<li>Code will publish at the end of the contest.</li>
<li>Devs may submit more than once and less than 5 times (this should let you change your mind on the approach, but not too many times).</li>
</ol>
<p><strong>Suggestions:</strong></p>
<p>As said, brutal force is not a competitive solution, btw you can start from that (setting your player timeout over 15s)<br />
Many papers, documents, even books, were written on this topic, usually some of them suggest algorithms to solve the problem. Try to use this resources in the right way, not paste and copy: i&#8217;m quite sure that lots of submitted proposal will more optimized that the general algorithms proposed in that references. So i can say that a thief approach will not put you on top.</p>
<p>Finally keep in mind that we don&#8217;t need the most elegant code, we just need the fastest :)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nicolabortignon.com/gone-in-15-seconds-contest-chapter-i/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
	</channel>
</rss>

