Another Blender Model

今天调了好长时间的光线,还是有错误,郁闷。

有点想放弃 rika 引擎了,开始查 Unity,翻 ZBrush。无意间碰到这个 miku blender model 就导进来看看,居然一次就通过了,相机和模型都正确渲染,有点出乎意料。

想了想,决定还是继续弄吧,不过进度确实太慢了。

miku

The Haskell syndrome

Haskell language only benefits programmers / researchers who write in it, not necessarily the end users or even library users, in particular, me.

I tried to use darcs, it's too slow.

I tried yi, it's too slow. It's amazing how a text editor can be that slow.

I could not use Happstack, I didn't understand its type.

I still can not use iteratee, since based on my skill, I can't justify the roi.

I don't understand most of the blog posts on planet haskell.

Something's not right.

Well I know I'm stupid, but maybe a language this smart is not helping at all.

Deferred shading

My stupid deferred shading algorithm seems to come together piece by piece, need to fix some non trivial bugs in the math lib to get it to work.

I really like the idea of deferred shading, it's an example of wholesale / data driven algorithm. Just love it.

1.png

More on Nana

There's no problem running nana (the Eutperea no TH port) on a simulator, but I just can't get it to run on a device.

It looks like a problem with IORef, but I had no problem with it before. It might be that the buffer is just too short, or that the remoteIO is running on a separate thread, I don't know yet.

Or is the IORef overhead be too large? Can it be solved by a faster CPU? I'm using a second generation iPod Touch, which is about twice as slow as the latest iPhone 3GS.

Anyway, I found a way to freeze an iPod touch though (restart required), just use remoteIO with IORef ...

Porting Eutperea

bamboo

a script I use to auto update remote repo after a push

# .git/hooks/post-receive


# create another branch
# then whenever a push is made to master,
# current branch is merged with master

cd ..
env -i git merge master

nana

OK, I need Eutperea, but ghc-iphone doesn't compile the ghci component, which is required by TH / Eutperea, so I had to port it, code name: nana.

The great CCA can't be used, so nana would be 20x slower then Eutperea, fuck.

I also did some research in SuperCollider and CSound. Porting CSound is practically impossible, since it uses python as build scripts. My cheap effort on building SuperCollder xcode project also failed miserably.

PureData is probably another option, but after a few hours with the CSound book, I really start to like it, and when I like something, it's hard to look at something else, like the way I found python, ruby and haskell.

I have yet to see any discussion on Eutperea, but imho it's one of the finest piece of haskell code ever written.

CNNIC

I sent another email to bugzilla on the topic of removing CNNIC CA from the default trusted root CA list. I have recommended Firefox to many non technical people, and wanted to do at least something for them.

Sleep mode

I'll be in no internet mode (a.k.a sleep mode) until I finish my next project. It's gonna take me some effort, but I've done enough research for it and it's time to get it out.

Project name: Hime.

My algorithm and design for the Google AI Challenge

In short: modified min-max + STM

I know multithreading is not allowed, but still I programed it in a way such that it has the potential to scale to arbitrary cores. There's one benefit even on the current system, that is the worker thread is detached from the main thread, so I can kill the worker thread when time is running out, I get an incorrect solution, but the program will not be rejected by the system.

I read the min-max tutorial on their website, and the article on wikipedia, from my understanding, it's just a function of:

1
2
3
4
eval :: State -> Int
eval = undefined

measure = eval my_state - eval your_state

Then this number is used as a measurement to pick the best move.

I had to tweak it in the following ways:

eval your move twice:

eval my_state and eval your_state have to be used independently, since two players move concurrently, how the other moves is unknown respectively. I cheated by calculating your state twice, where the latter takes into account this particular move of mine being considered.

dynamic depth of recursion

Depending on the size of the board, the number of moves I can look ahead various. This is a potential timeout. I simply hardcode a function ( Int -> Int ) that takes the number of free spot on the board and returns a recursion depth, that's been passed to the main worker function.

TVar board

Since the goal of this recursive thinking is to figure out if a free spot is worth to move to, i.e. comparing it's current weight to the weight we get from measure, there has to be a way to reference the original spot and set a value to it when the function thinks that this route actually worth more then it was previously considered. My solution is to put the board to a TVar and pass this reference around along with a pivot of the spot being considered.

(Bonus) The actual eval function

I first hacked up my own algorithm to determine if a spot leads to more space. After some tweaks, it started to perform pretty well, despite the fact I don't know why it works exactly, and there's no hope for me to reason the correctness of it. After some look around, I found out the proper name for the algorithm is call Flood Fill. Then I implemented a smaller, cuter version of flood fill, and it turned out that, despite being correct, it sucks.

Implicit or explicit -ly, I'm just too cheap to go with correctness.

That's pretty much it, btw, my data structure:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
data V2 = V2
{
x2 :: Int
, y2 :: Int
}
deriving (Show, Eq, Ord, Ix)

data Spot =
Me
| You
| Space Int
| Wall
deriving (Show, Eq)

type Grid = Map V2 Spot

data Board = Board
{
grid :: Grid
, bounds :: (V2, V2)
}
deriving (Show, Eq)

Pretty stupid, whatever.