Warning: Technical post ahead!
The past week has been a bit busy with talks, mail catchup and other accidentals, but I still made progress and wanted to share how it feels to rewrite Storyteller in Haxe so far...
Writing software with open source tools feels good
I SVN track my combo FlashDevelop + Haxe daily, and so I am aware what's going on and what features/fixes to expect. It is reassuring to know that if I bump into a nasty problem with any of them, I could potentially jump into the code and try to fix it. Whereas with Actionscript and Flash Builder I am at the mercy of Adobe's priorities, which might not be the same as mine.
Of course, I am still targeting Adobe AIR as the runtime platform, but I can always switch to NME, a multiplatform Flash API implementation by adjusting the code a bit. I might end up doing that anyway, since Adobe is not supporting Linux AIR anymore.
Local variable name reuse makes better code
In Actionscript, you are not allowed to do this:
// ACTIONSCRIPT
for each(var i:Thing in things) {...}
for each(var i:Thing in things) {...} // WARNING: Duplicate variable
for each(var i:OtherThing in other_things) {...} // ERROR: conflict
Now the way I program now is way simpler than I used to, and sometimes I have fairly big methods involving several loops. Being unable to reuse variable names makes me write code like this:
// ACTIONSCRIPT
for each(var i:Thing in things) {...}
for each(var i2:Thing in things) {...} // ARGH, I hope I don't write "i" by accident!
// or
var i:Thing; // ugly. I only care about "i" inside the loops
for each(i in things) {...}
for each(i in things) {...}
This is nonsense wrestling with the language. The haxe way:
// HAXE
for(i in things) {...}
for(i in things) {...} // compiles! Also, no need to type "var", "each" or the variable type.
for(i in other_things) {...} // other_things can contain a different type, it's fine.
But there's actually a bigger problem behind Actionscript's hoisting approach. Take this code:
// ACTIONSCRIPT
trace(i); // "i" will be null, but NO COMPILER ERROR!!!
var i:String;
i = "hello";
// HAXE
trace(i); // compiler error
var i:String;
i = "hello";
In small code it seems stupid to make such a mistake, but in a mass of code while you are refactoring stuff around, it's easy to end up with a reference to an uninitialized variable! Bugs like this can be hard to find, and I shot myself in the foot a few times. Haxe makes this risk go away.
Snappier IDE, snappy compiler
Flash Builder is built on top of Eclipse, and sometimes it goes haywire and becomes unresponsive. FlashDevelop has been behaving pretty well up to this point, and it feels lighter.The Haxe compiler is instantaneous so far, but let's see if it withstands the same amount of code as the Actionscript version, which used to take 11 seconds to compile (to be fair, I was using mxmlc instead of the better and faster ASC2).
FlashDevelop's code autocompletion is super slow for some reason. I hope it improves over time.
The rewrite is fun
I chose to rewrite the game instead of making a straighforward port because I wanted to take the chance of getting rid of a few core features the game is not actually using, and restructure old code that I know how to do better now. A major problem of the Actionscript version is that long stories took forever to solve, making the game unresponsive. Solving that problem involves an optimization of the core story simulator, which is the most difficult piece of code, so a major rewrite was in order anyway. Everything feels more solid now and raises my confidence in trying new features and refactoring old ones.What's next
I am waiting for FlashDevelop to catch up with Haxe 3, which provides a mechanism to embed fonts that I had to solve with a plugin for now. Additionally, it would be nice to try features like Array Comprehension, Generic Functions and a more general Map class (isn't it great to be working on an evolving language?).So for now, working on Haxe has been a pleasure! BUT the real proof will come as Storyteller's Haxe code becomes bigger and I test it on different platforms.
I like post like this, good luck with the re-writing :D
ReplyDeleteI'm curious, can you talk at some future point about your solver? Are you using a traditional AI planner or perhaps a constraint solver like Google's or-tools or just something you came up with yourself?
ReplyDeleteYes, I am planning on writing a series of articles about how the simulator actually works, one of them will even be technical.
DeleteI am not using any traditional algorithms (that I know of!) for two reasons: 1) I need the results of the simulation to be easily predicted by a human being 2) In Storyteller's stories *order matters*... sometimes hate happens before love and sometimes it's the other way around.
Reason 1) rules out mystic numeric simulations like the one used by The Prom and The Sims. 2) Ruled out all the logical solvers like prolog, which draw conclusions regardless of what happened when.
I am always trying to figure out a cleaner, clearer way of implementing the simulator, but I think the current solution can't be substantially improved. That said, every now and then an idea comes up that incrementally makes it be more flexible, general and easier to work with, so I think I will wait until the model is fixed before writing about it!
zhengjx20160730
ReplyDeletejordan retro 11
louis vuitton outlet online
oakley outlet
coach outlet
coach outlet
burberry outlet
gucci handbags
michael kors outlet clearance
michael kors outlet
cheap jordans
burberry outlet online
supra footwear
hermes outlet
michael kors outlet
replica watches
true religion outlet
adidas running shoes
louis vuitton bags
cheap jordan shoes
coach outlet
jordan 3s
toms wedges
coach factory outlet online
kate spade handbags
replica rolex watches
oakley sunglasses
ray ban sunglasses
toms outlet
coach outlet
replica rolex watches
true religion jeans
louis vuitton purses
burberry outlet
coach outlet store
mont blanc pen
coach outlet
basketball shoes
timberlands
air jordan 8
louis vuitton bags
ray ban sunglasses
ReplyDeletepolo outlet
true religion outlet
ugg australia boots
nike shoes for men
michael kors outlet online
longchamp uk
longchamp handbags
ugg boots
michael kors outlet
20161117caiyan
Hi, I agree with you. Really this blog is very informative.
ReplyDeleteipl 2017 live streaming hd
ipl point table 2017
20170526meiqing
ReplyDeleteyeezy boost 350 v2
birkenstock uk
ralph lauren sale
coach outlet online
fitflops sale clearance
mulberry
marc jacobs
adidas
louis vuitton factory outlet
adidas yeezy boost
شركة عزل اسطح
ReplyDeleteشركة عزل اسطح بالدمام
خدمات عزل الاسطح من الخدمات التى فى حاجة الية فى المكان فاذا اراد ان تقوم باعمال العزل لاى اسطح فى المصانع – المنازل – الفلل ... وغيرها وتبحث عن افضل الخدمات التى تساعد فى الوصول الى افضل ما تتمنى ان ترى علية النتائج فعليك ان تتعاون مع شركة قمم التميز التى تحقق اعلى مستوى من العزل بالاعتماد على افضل المواد المخصصة فى القيام باعمال العزل والتى استطاعت ان تتاكد ان اعمال العزل التى تتم بالخيش المقطرن والسيلتون من افضل الخدمات المثالية المميزة التى تحقق اعلى مستوى من العزل دون ان يؤدى الى ظهور اى عيب فى اعمال العزل . شركة تنظيف مسابح بالدمام
لا تكتفى شركة قمم التميز بالقيام باعمال العزل فى منطقة معينة بل تسعى الى الوصول الى اى مكان فى شرق الرياض – جنوب الرياض – غرب الرياض – وسط الرياض من اجل ان تحقق خدمات العزل لجميع عملاء الشركة الكرام .
تهتم شركة عزل اسطح بالقيام باعمال العزل الحرارى من خلال الاعتماد على افضل الطرق المثالية وافضل الخدمات المميزة فى القيام باعمال العزل بالاضافة الى ان الشركة تهتم باعمال الكشف الدورى من فترة الى اخرى من اجل ان يتم التحقق ان اعمال العزل تمت كما هو مطلوب فى المكان . شركة تنظيف خزانات بالدمام
العزل الحرارى يساعد فى حماية الاسطح من التعرض الى ارتفاع فى درجة الحرارة وتسربها عبر الجدران فى فصل الصيف بالاضافة الى التعرض الى التصدعات وعوامل المناخية المختلفة التى تتعرض الية فى فصل الصيف نتيجة لشدة الحرارة التى تظهر التشوهات فى المبانى ، بالاضافة الى ان لدينا خدمات العزل المائى من خلال الاعتماد على خدمات العزل المائية التى تتم من خلال افضل خدمات متواجدة والتى تسعى الى تحقيق افضل مستوى من الخدمة والعزل بالفوم ايضا من اهم الطرق الحديثة التى استخدامت فى العديد من الدول الاوربية لانه يساعد فى حماية المبنى من التعرض الى الحرارة المرتفعه او التعرض الى التسربات للمياة والحفاظ على المبنى من اى مشاكل وعوامل مناخية ، فاعمال العزل للفوم اختصار لكل طرق العزل والتى تساعد فى الحفاظ على المبنى .
شركة كشف تسربات المياه بالدمام
تسربات المياه مشكلة تؤدى الى التعرض الى عدد من المشكلات الاخرى ، فالاهمال فى تسربات المياه يؤدى الى التعرض الى الكثير من المشكلات التى نحن فى غنى عنة فاذا تعرض الى التسربات وتعرضت الى ظهور عدد من المشكلات الاخرى مثل سقوط الدهانات والتعرض الى مشاكل الرطوبة فعليك ان تتواصل وتتعاقد مع شركة قمم التميز المخصصه فى اعمال الكشف عن تسربات المياه
togelpelangi
ReplyDeleteThanks nice info
jianbin0919
ReplyDeletecoach outlet
adidas uk store
air max 90
cheap ray bans
canada goose coats
birkenstock sandals
burberry outlet
coach outlet online
ugg boots
polo outlet
cheap oakley sunglasses
ReplyDeletekate spade bags
michael kors outlet
ugg boots
fred perry shirts
nike shoes outlet
canada goose outlet store
canada goose outlet
ugg boots clearance
christian louboutin outlet
20171226wanglili
I like to read your article because it really helps me. Thank you for sharing this post with us.
ReplyDeleteTogel Online
Prediksi Hongkong
Prediksi Singapore
World Cup 2019 Prediction
ReplyDeleteWorld Cup Match Prediction
World Cup Match Prediction 2019
World Cup Toss Prediction
World Cup Toss Astrology
yeezys
ReplyDeletebalenciaga
golden gooses
christian louboutin shoes
nike air max
vans
jordan 6
air max 270
yeezy boost 350
westbrook shoes