Archives 2005 - 2019

Behavior trees as an alternative to state machines

published Aug 04, 2013 02:15   by admin ( last modified Aug 05, 2013 02:23 )


How do you model what can and cannot be done and what should be done from a certain position in a game?One way is with state machines, but another way is with behavior trees:
 

Welcome to a series of blog articles about my experiment (read: stumbling around) of marrying data-oriented, memory-streamlined behavior trees with a second representation to ease creation and modification during development.


Read more: Link - #AltDevBlog » Introduction to Behavior Trees

 

"My liner notes for spore/Spore Behavior Tree Docs - Chris Hecker's Website"

Understanding Behavior Trees | AiGameDev.com

Björn Knafla's whole series:

  1. Introduction to Behavior Trees
  2. Shocker: Naive Object-Oriented Behavior Tree Isn’t Data-Oriented
  3. Data-Oriented Streams Spring Behavior Trees
  4. Data-Oriented Behavior Tree Overview
  5. #AltDevBlog » Behavior Tree Entrails

 

Libraries in javascript found via Google:

BehaviorTree.js | JavascriptOO.com

Machine.js

 


Crypto libraries and speed in client side javascript

published Aug 03, 2013 04:16   by admin ( last modified Aug 03, 2013 04:16 )

This page has some speed tests:

Speed Test Simulate-threading

I am not up to speed (so to speak) on what performance repercussions the different settings for AES has, as presented on the page, but the forge library stands out as being five times faster at encryption and 2,5 times faster at decryption than any other library (as tested on a Linux Firefox 22.0 on a one core Celeron) and ten times faster than CryptoJS.

A library not included in the test that may be worth checking out is cifre.


Riker ipsum - generate lorem ipsum texts from Riker's Star Trek lines

published Jul 30, 2013 11:16   by admin ( last modified Jul 30, 2013 11:16 )

Python module. The lines seem to work in any order, quite entertaining!

 

Generates random text using real English - taken from random samplings of the entire catalog of dialog spoken by Commander William Riker in every episode of Star Trek: The Next Generation.


Read more: Link - RikerIpsum - Lorem Ipsum: The Next Generation


Clustering in python with KNN (K nearest neighbor)

published Jul 27, 2013 07:34   by admin ( last modified Jul 27, 2013 07:34 )

CSS library for dynamic effects

published Jul 21, 2013 03:33   by admin ( last modified Jul 21, 2013 03:33 )



Ever notice how small flourishes and subtle transitions dramatically increases the value of the experience you enjoy with an app or site? Designing and developing UIs for the mobile web is tricky, but it's extremely difficult to do that while delivering something that performs at 60fps.


Read more: Link - Effeckt.css


What javascript encryption library performs well on phonegap?

published Jul 18, 2013 09:35   by admin ( last modified Aug 03, 2013 04:53 )

Summary:

  • crypto-js seems 20% faster on an Android 2.3.7 phone on the ARM platform than sjcl.js.
  • It is 15% faster on Android 4.04 tested on a Lenovo K1
  • On an Android 2.3.3 Virtual Device running Atom ontop of a Core2 Duo, it is twice as fast, and about the same for running ARM ontop.
  • Tested with the browser in Phonegap/Cordova 2.8.
  • (From a newer blog post of mine) In preliminary browser (not phonegap) tests on Android, on this test page Speed Test Simulate-threading, Stanford handily betas CryptoJS, with forge beating them both

 

There is a jsperf comparing encryption/decryption speed in javascript:

http://jsperf.com/encryption-decryption-comparisons/6

The two libraries that come out neck and neck on my Linux workstation x86 Chrome browser are the Stanford Javascript Library (http://crypto.stanford.edu/sjcl/) and Crypto-js (https://code.google.com/p/crypto-js/). But how do they perform on the older browser component in Phonegap/Cordova 2.8, on different versions of Android?

I have tested with Phonegap 2.8 on two Android Virtual Devices with Intel Atom, actually running on my Intel Ubuntu 12.04 x86 workstation, with Intel's KVM trick installed (Speeding Up the Android* Emulator on Intel® Architecture | Intel® Developer Zone) to up the performance of the emulators. The Android Phonegap app was configured to open the jsperf url directly in the config.xml.

When running under Android 4.2.2, the two libraries are again neck and neck, but on Android 2.3.3 on an Atom AVD, Crypto-js is twice as fast. See this screen shot (Yeah, I should have run it on a tablet AVD so the screenshot would fit, but I didn't, sorry):

Crypto-js did 50.28, and sjcl.js did 24.56, the latter almost exactly half of the former.

 

However on a real ARM phone, ZTE Blade running Android 2.3.7, the difference is only about 20%, and on Android 4.0.4 on an Lenovo K1 the difference is about 16%.

Footnotes: The "Block tea" library also performs well on Android 2.3.3 on Atom (less on ARM), but it says on the jsperf page that it is less secure so it might be like comparing apples to oranges. Furthermore crypto is hard and I don't know if there might be differences in quality between the different libraries. I also wonder if the AVDs are correct in that Intel Atom influences javascript performance differently than ARMs.


A dictionary database for Java

published Jul 14, 2013 11:46   by admin ( last modified Jul 14, 2013 11:46 )



jSlovo is among fastest database engines for dictionaries. It is available for any platform where Java can be used (Windows, Linux, Apple, Android). It is mainly designed for the use with free dictionaries and thesauruses.


Read more: Link - JSlovo multiplatform dictionary


Target densityDpi for Android browser scaling

published Jul 14, 2013 06:22   by admin ( last modified Jul 14, 2013 06:22 )



device-dpi: Use the device's native dpi as target dpi. low-dpi: 120dpi medium-dpi: 160dpi, which is also the default as of today high-dpi: 240dpi : We take any number between 70 and 400 as a valid target dpi. Fix http://b/issue?id=2071943 So how do I use it? Like this, for example:


Read more: Link - Philosophical Games: Customize Android Browser Scaling with target-densityDpi


How to add an external editor to Eclipse

published Jul 10, 2013 11:45   by admin ( last modified Jul 10, 2013 11:47 )

Go to:

Window->Preferences->Editor->File Associations

...to register your external editor for a specific file type or file types.

 

Then go to:
Window->Preferences->General->Workspace and check the checkbox "Refresh using native hooks or polling"

...to make Eclipse aware of changes in the files whie you are editing. This setting is important since otherwise you will have to close the external editor in order for Eclipse to pick up the changes which will make backing out of changes with the undo buffer impossible (since you've closed the editor once you realise something is wrong).
 

 


Read more: Link - Adding an external editor in Eclipse — VIM Zone


Javascript state machines

published Jul 08, 2013 04:25   by admin ( last modified Jul 08, 2013 04:26 )

ifandelse/machina.js · GitHub

jakesgordon/javascript-state-machine · GitHub

When you lose control of the javascript code and the code controls you, it's time to refactor. But into what? It is tempting to go with one of the MVC frameworks, with different definitions of the letters. But as I was looking at my code and thought "What is the simplest way of representing this?", it seemed to point in the direction of a state machine. Will report back with news.


Make text bigger on phonegap

published Jul 03, 2013 03:35   by admin ( last modified Jul 04, 2013 03:34 )

On phonegap, pages had much smaller text than when being viewed in the system web browser on Android. The following change in the viewport rectified that:

 

target-densitydpi=medium-dpi


Read more: Link - javascript - Phonegap Application text and layout too small - Stack Overflow


Superstop - get rid of animations in gifs in Firefox

published Jul 03, 2013 03:19   by admin ( last modified Jul 03, 2013 03:19 )



SuperStop is very simple: it adds a Shift+Esc shortcut that stops active WebSocket connections, XMLHttpRequests, and any animated images, regardless of the state of the Firefox Stop button. This matches the behavior of the Esc button in versions of Firefox prior to Firefox 20 (see bug 824248).


Read more: Link - SuperStop :: Add-ons for Firefox


Speed up Android devices on Linux by an order of magnitude

published Jul 02, 2013 10:35   by admin ( last modified Sep 25, 2013 11:59 )

When installing the Android development tools from Google, I read that hardware acceleration for the Android Virtual Devices (the Virtual phones on screen that you can test your software on) would not be avilable for Linux.

 

However Intel says it is available. I have tested it and I now fully believe their claims that you can speed up your testing device by a factor of five or ten! Follow the link below to check how to do it.

 

It's basically:

sudo apt-get install qemu-kvm libvirt-bin ubuntu-vm-builder bridge-util

 

If you are an Android* developer who is unhappy with the performance of the Android emulator, then this document is for you. Over and over again, we have heard from many Android developers that the emulator is slow and painful to work with, but this should not be the case!


Read more: Link - Speeding Up the Android* Emulator on Intel® Architecture | Intel® Developer Zone


lz-string, javascript to cram more data into localstorage

published Jul 01, 2013 11:55   by admin ( last modified Jul 01, 2013 11:55 )

Without it, I got 2300 items of my data into Chrome, with it  I got 6300, well probably more but I did not need more.

 

lz-string was designed to fulfill the need of storing large amounts of data in localStorage, specifically on mobile devices. localStorage being usually limited to 5MB, all you can compress is that much more data you can store.


Read more: Link - lz-string: JavaScript compression, fast! - pieroxy.net


Domain White List on Android 2.3 on newer phonegaps (e.g. 2.8)

published Jun 29, 2013 10:40   by admin ( last modified Jun 29, 2013 10:43 )

Summary:

Add this class: https://github.com/android/platform_frameworks_base/blob/master/core/java/android/webkit/WebResourceResponse.java

delete the line that says:

import android.net.http.Headers;
...it is not used anywhere.

 

Newer versions of Codova/Phonegap does not support domain white listing when running the resulting app on Android 2.3 devices. The error message is:

Could not find class 'android.webkit.WebResourceResponse', referenced from method org.apache.cordova.CordovaWebViewClient.getWhitelistResponse

Reason is that is looking for the WebResourceResponse class and cannot find it. Just download it from github at the afore mentioned address, and put in your source tree.

The incompatibility with Android 2.3 seems to have crep t in in Phonegap 1.9, according to a comment on this blog post:

http://richdotnet.blogspot.se/2012/07/create-your-first-phonegap-project-with.html


Set up a Java environment for Cordova/phonegap development on Ubuntu 12.04

published Jun 28, 2013 10:05   by admin ( last modified Jul 10, 2013 02:43 )

Installing Cordova (Phonegap)

I added these to my ~/.bashrc

PATH=$PATH:/path/to/where/i/put/it/adt-bundle-linux-x86-20130522/sdk/platform-tools:/path/to/where/i/put/it/adt-bundle-linux-x86-20130522/sdk/tools
ANDROID_BIN= /path/to/where/i/put/it/adt-bundle-linux-x86-20130522/sdk/platforms/android-17

I'm not saying this is the best way but it worked for me

 ./create /path/to/new/directory com.yourproject yourproject

You must not use spaces in the last part (even within quotes), because then it fails like this:

jorgen@battle:~/workspace/android/phonegap-2.8.0/lib/android$ ./bin/create /home/jorgen/workspace/android/testproject2 net.jorgenmodin.test "A name with spaces in it"
An unexpected error occurred: "$ANDROID_BIN" create project --target $TARGET --path "$PROJECT_PATH" --package $PACKAGE --activity $ACTIVITY &>/dev/null exited with 1
Deleting project...

 

Install Java 7

Download it from Sun, follow the instructions from the highest rated answer on this page: installation - How do I install Oracle Java JDK 7? - Ask Ubuntu

 

But add the following:

 sudo update-alternatives --install "/usr/bin/jar" "jar" "/usr/lib/jvm/jdk1.7.0/bin/jar" 1

I had no jar command, if you already have one it may work however the fastjar program did not understand phonegap's switches so it is not an option.

 



 

Install the JDK


The emulators never launched, with no explanation.

 

You can start an emulator from the command line, by going inside the sdk directory and inside tools and then run

./emulator -avd <emulatorname>

That informed that there was a segmentation fault, and core dumped

By adding the verbose switch, these were the last two lines:

emulator: Initializing hardware OpenGLES emulation support
Segmentation fault (core dumped)

 

So, googling for that leads to this page:

http://stackoverflow.com/questions/13997771/android-emulator-segmentation-fault

 

Which says to do like this

mv tools/lib/libOpenglRender.so tools/lib/libOpenglRender.so.xxx

 

Which then made verything work.

 

Self-signing an apk

If you want to try out your apk on different devices, without connecting them with a USB chord to the development computer, you need to sign the apk. Otherwise it will simply just fail to install. This page shows how to self sign an apk:

Generating Keys - Android Wiki

I used the option

keytool -genkeypair -keystore keystorename -storepass keystorepassword -keyalg RSA \
  -validity $((25 * 365)) -alias keyalias -keysize 2048 \
  -dname "CN=J Random Hacker, O=HackerCo, L=Anytown, ST=Anystate, C=US"

and then

jarsigner -verbose -keystore keystorename apkfilename keyalias 

keytool and jarsigner commands were already installed on the laptop (different from my workstation), it may be different for you. On my workstation I had to do

 sudo update-alternatives --install "/usr/bin/jarsigner" "jar" "/usr/lib/jvm/jdk1.7.0/bin/jarsigner" 1

In Eclipse there is support for signing in the Android Tools context menu.


Thanks for the "until" command in the python debugger

published Jun 28, 2013 03:05   by admin ( last modified Jun 28, 2013 03:05 )

Stepped into a 3000 iteration loop today while debugging python code. How do you get out of that? Turns out there is an "until" command in the debugger that will type next for you until it's about to hit a line further down in the program. Or more precisely:

 

The until command is like next, except it explicitly continues until execution reaches a line in the same function with a line number higher than the current value


Read more: Link - pdb – Interactive Debugger — Python Module of the Week


Seem like udev should be able to detect if power cord is in

published Jun 27, 2013 07:30   by admin ( last modified Jun 27, 2013 07:30 )

Should be worth looking at

 

SUBSYSTEM=="power_supply", ENV{POWER_SUPPLY_ONLINE}=="0", RUN+="/usr/bin/powersave true" SUBSYSTEM=="power_supply", ENV{POWER_SUPPLY_ONLINE}=="1", RUN+="/usr/bin/powersave false"


Read more: Link - Howto: Powersaving tweaks with a udev rule - HOW TO & FAQ Guides - Neowin Forums


Menu for changing text size in jquery mobile

published Jun 27, 2013 05:27   by admin ( last modified Jun 27, 2013 05:27 )

Note to self, this worked grat:
 Link - Edit this Fiddle - jsFiddle


How to re-skin elements that weren't around when jquery mobile skinned

published Jun 27, 2013 04:24   by admin ( last modified Jun 27, 2013 04:24 )

Send a "create" event. I sent ot to the parent element and it works.

 

Normally jQm will enhance elements during the page init event. If you add/remove/manipulate the page after that event has fire you'll need to trigger the enhancement via code. Try adding this line after your append statement. $("#grillaCaps").trigger("create");


Read more: Link - jquery mobile dynamic buttons in grid lose format/style after first “render” - jQuery Forum