Read KenArnold's take on Java Generics
Bruce Eckel was writing about Generics long ago and problems created by Erasure
Neal Gafter was trying to explain erasure
I have not read the Generics thing seriously till now .. i started some pdf from Gilad Bracha .. now i need to find it out
Thursday, June 30, 2005
Monday, June 27, 2005
Pathfinding - Part 1
In many games, you need to find path to a particular object. Suppose its a predator-prey game and predator need to go to the location of prey. Suppose this is a tile based game.
In this part, we will consider that there is no obstacle between predator and prey.
In a simple path finding we could increment(or decrement) predators x and y positions until both of them coincide with prey's.
ie
The problem with above method is that, it doesnt give a direct line between predator and prey.
For eg, in fig, predator will move in x and y direction, until one of them conincides. Then it will move in other direction. ie in the above pic, y got coincided first, then x increases.
You can avoid this problem by using Bresenham's algorithm.
In Bresenham's algorithm, we find out which is large ie x distance or y distance, and will increment the larger one much faster than the other. ie
which is an approximation of line.
Next part - How to move around if obstacles are present.
In this part, we will consider that there is no obstacle between predator and prey.
In a simple path finding we could increment(or decrement) predators x and y positions until both of them coincide with prey's.
ie
This is pretty much simple and doesnt require much cpu power.
if predator.x < prey.x:
predator.x++
elif predator.x > prey.x:
predator.x--if predator.y < prey.y:
predator.y++
elif predator.y > prey.y:
predator.y--
The problem with above method is that, it doesnt give a direct line between predator and prey.
For eg, in fig, predator will move in x and y direction, until one of them conincides. Then it will move in other direction. ie in the above pic, y got coincided first, then x increases.
You can avoid this problem by using Bresenham's algorithm.
In Bresenham's algorithm, we find out which is large ie x distance or y distance, and will increment the larger one much faster than the other. ie
This would look like
deltaX = prey.x - predator.x
deltaY = prey.y - predator.y
if abs(deltaX) > abs(deltaY):
delta = deltaX
else:
delta = deltaY
xincr = float(deltaX)/delta
yincr = float(deltaY)/delta
while round(predator.x) != prey.x and round(predator.y) != prey.y:
predator.x += xincr
predator.y += yincr
//draw
which is an approximation of line.
Next part - How to move around if obstacles are present.
Wednesday, June 22, 2005
My Driver is moving
Sad .. my driver neo is going to Dubai in two weeks. Neo was a nice driver, he is okay except when riding bike with one hand and biting nail with other. Chennai was good .. i realize it now . Maybe bangalore is better, i will realize it later. My dear driver, life is going to be hard, for you.. me.. everybody.
"Life is better with O Henry, than with Ohm's law" .. so true
"Life is better with O Henry, than with Ohm's law" .. so true
Monday, June 13, 2005
The road ahead
Mobile applications are hot these days. A typical smart mobile phone runs Symbian OS, Java etc. What makes these phones different from PC's are that they have lesser processing power. So specially crafted Os's, applications are needed to run on them. So companies like Symbian have caught up a lot lately. Now the interesting thing is, the processing power of mobile phones are increasing. It wont be long they have powerful processor and other hardware. Then what will happen to these companies? .. The current PC software providers then will have far more
experience in making software than these guys. So will all these companies just diminish? .. if you see some mobile phones already runs linux these days. Will Linux take over Symbian??(not that it matters much) .. I have to admit that i have little knowledge of most of the things i speculated here .. maybe im wrong .. time to do a google search.
experience in making software than these guys. So will all these companies just diminish? .. if you see some mobile phones already runs linux these days. Will Linux take over Symbian??(not that it matters much) .. I have to admit that i have little knowledge of most of the things i speculated here .. maybe im wrong .. time to do a google search.
Thursday, June 09, 2005
So long and thanks for all the fish
People who know me also know that I go hysterical whenever I hear the word fish. So what is with fish and me? To understand that, you should understand how I lived my considerable portion of life...
I lived near coastal area... (Near Arabian Sea to be exact). Its hardly one or two km’s to the Sea from my place. So fish is something you can’t neglect there... It’s like air if you think in someway. People are usually so used to fish that they will probably vomit if they don’t get fish for the meals.
Here goes my not so uncommon day
Breakfast: Puttu (yeah you can call it rice cake!) + Fish curry. Note: it would be better if it’s the previous day’s fish curry... And that too try to eat it in chatti (the earthen vessel)... hmm I see a lot of people recoil in disgust
Lunch: Boiled Rice + fish curry + fish fry + some grass (you can replace vegetable in place of grass, but I prefer to call it grass)
Tea: Bread + fish curry or fish fry (it’s a really nice combination ... try it once)
Dinner: Boiled Rice or Kanji (rice + water mixture) + fish curry + fish fry
By now you should have got a good understanding of my diet.
Over these years, I’ve grown liking towards some kinds of fish. Mainly I like all the smaller fish. It’s interesting to note that all the veteran fish eaters I know of, like big fishes. Many people like fresh water fish. I’ve tried some fresh water fishes... its good to eat occasionally, but not a replacement for saline fish. I also like exotic (exotic for you:) things like squids, prawns, crabs, mussels etc. Our place is known for mussels I guess (I didn’t find it in many other places). Mussel pickle is a delicacy.
Here goes my liking of how fish should be prepared
Fish curry: Use *lot* of coconut. The curry should be yellow-orangish color. Use tamarind... if you get green mangoes, much better...
Sometimes I also eat the coconut less version, its called puli + mulaku (tamarind + red chillies)... it’s good for puttu or kanji.
Fish fry: Fry it well, Fry it in a pan... it shouldn’t be half baked... also don’t deep fry, because you will loose the flavor. Small fishes are good with bread.
I could go on ranting on fishes... so am stopping this here... (You are free to drool:)
I lived near coastal area... (Near Arabian Sea to be exact). Its hardly one or two km’s to the Sea from my place. So fish is something you can’t neglect there... It’s like air if you think in someway. People are usually so used to fish that they will probably vomit if they don’t get fish for the meals.
Here goes my not so uncommon day
Breakfast: Puttu (yeah you can call it rice cake!) + Fish curry. Note: it would be better if it’s the previous day’s fish curry... And that too try to eat it in chatti (the earthen vessel)... hmm I see a lot of people recoil in disgust
Lunch: Boiled Rice + fish curry + fish fry + some grass (you can replace vegetable in place of grass, but I prefer to call it grass)
Tea: Bread + fish curry or fish fry (it’s a really nice combination ... try it once)
Dinner: Boiled Rice or Kanji (rice + water mixture) + fish curry + fish fry
By now you should have got a good understanding of my diet.
Over these years, I’ve grown liking towards some kinds of fish. Mainly I like all the smaller fish. It’s interesting to note that all the veteran fish eaters I know of, like big fishes. Many people like fresh water fish. I’ve tried some fresh water fishes... its good to eat occasionally, but not a replacement for saline fish. I also like exotic (exotic for you:) things like squids, prawns, crabs, mussels etc. Our place is known for mussels I guess (I didn’t find it in many other places). Mussel pickle is a delicacy.
Here goes my liking of how fish should be prepared
Fish curry: Use *lot* of coconut. The curry should be yellow-orangish color. Use tamarind... if you get green mangoes, much better...
Sometimes I also eat the coconut less version, its called puli + mulaku (tamarind + red chillies)... it’s good for puttu or kanji.
Fish fry: Fry it well, Fry it in a pan... it shouldn’t be half baked... also don’t deep fry, because you will loose the flavor. Small fishes are good with bread.
I could go on ranting on fishes... so am stopping this here... (You are free to drool:)
Subscribe to:
Posts (Atom)