Meh ...
from coffee to code
Monday, April 7, 2014
Friday, August 23, 2013
Having fun with MCU's
I almost forgot I had a blog :)
Have to get back to writing some code soon, or else I might die of mental degeneration. But I managed to work on something that is completely unrelated to java programming.
I sometimes like to work with the MSP430 Microcontroller by TI. Those are little chips that can be programmed to do certain tasks. Most people have probably heard of the Arduino, which is an open source platform based on an Atmel AVR Microcontroller. I personally prefer using the msp430 because of three reasons.
Have to get back to writing some code soon, or else I might die of mental degeneration. But I managed to work on something that is completely unrelated to java programming.
I sometimes like to work with the MSP430 Microcontroller by TI. Those are little chips that can be programmed to do certain tasks. Most people have probably heard of the Arduino, which is an open source platform based on an Atmel AVR Microcontroller. I personally prefer using the msp430 because of three reasons.
- its dirt cheap. the launchpad was 4.30$ when it was released featuring 2 included microcontrollers and a programmer
- its insanely low power. if properly programmed, those things can run off a coin cell for years
- GREAT community over at 43oh, which is helpful when confronted with problems that are beyond your grasp of electronics, which, for a person that writes programs in java, python etc, tends to happen quite often
you can see and or hear it in action in this clip
its just a microcontroller with 4 external components, a 4.7k resistor, 1 2N3904 NPN transistor to drive 1 speaker salvaged from an old laptop and a led to tell me that everything is working fine after i started it.
for anyone owning a launchpad, just grab the code, for anyone else, grab a launchpad first, they're fun :)
Friday, October 26, 2012
More progress
Realizing where the Y axis starts mights seriously help debugging. Most of my logic builds on and origin of xy top left while some api's really want xy bottom left. Eitber way, soft scrolling if working now. Even
on android.
Monday, October 15, 2012
Hello from android
Finally came around To write some more code for my roguelike :)
Writing in english on a german phone is quite annoying though.
Monday, August 27, 2012
Dungeons, dungeons everywhere ...
Sometimes it comes to mind if placing every single tile by hand could be more time effective and yield a better dungeon. but it wouldn't be that much fun, would it?
At the moment i am also a little bit fed up with Eclipse Juno. I use Eclipse since i started programming, but it seems to get slower with every release. As well as eating tons of ram. I might downgrade to an older release until this is fixed.
But first i promised to explain how i actually generate those dungeons.
Generating dungeon like struktures, especially 2D is quite simple. the way i do it is by creating a integer matrix and seeding every field either full or empty using a noise function which is basically java.util.Random.
After all fields have been initiallized with what looks pretty much like white noise, i run multiple iterations of a cellular automaton over the matrix.
for every cell of the matrix i count the 8 cells around it as well as the cell itself. if 5 or more cells are solid, the processed cell turns or stays solid. if less then 5 cells are solid the cell itself turns empty.
5 to 8 iterations of this create a smooth dungeon without single pixels in the void or other artifacts.
now i have a beatiful dungeon that is nice to look at but useless in the context of solvability. The naive algorithm used to create the dungeon does not ensure that the dungeon is solvable e.g. you can move from point a to point b. There might be walls that make the dungeon unsolvable so we need an approach to fix this.
My first solution was to place 2 starting points in the dungeon. those starting points are placed at two fixed position depending on dungeon size. The position will then move randomly until the start and goal point fullfil two conditions. the first condition is that the start [ or goal point ] is in free space. The second condition is solid ground right under this point.
This way the start and goalpoints _wiggle_ themselfes into position until those conditions are met.
Then i need to check wether the dungeon is solvable or not. This is done using a simple Astar implemenation. My first attempt completly ignored heuristiks because i deemed them unneccessary to determine if the start and goal points are connected. Because of a flaw in my algorithm this didn't work and you can see the results a few posts below. Luckily i found a few Astar implemenations on the internet and was able to bend it to my will. If the dungeon is not connected i simply generate a new one using the next seed i get from the PRNG.
Now i have a dungeon that looks nice and is connected. I fixed up a small routine to render those. I also added another cellular automaton that fills the dungeon with some vegetation. As of now it just places some entities on the map with a specific ruleset, but in the future i want to place those entities randomly on the map and then let the entities life. Water, for example, could pool up in certain areas, create moist places that lead to _shroomy_ surfaces on the ceiling or to grass growth etc. I have to get a few additional ideas what to add, but once you have an infrastructure to add those entities and then implement a simple ruleset how they behave, its quite simple to add more.
This way an otherwise sterile dungeon will look more organic and thus more believable.
I also have to work on the sprites, the grass texture, for example, is a placeholder i took from minecraft hoping i won't get sued before i replace it with something i can draw. I am also getting better at using Gimp.
In the end it pays off to write a little code rather then doing it all by hand. i can now generate dungeons that are virtually endless in size. the example pics are quite small, mostly because a browser would have problems displaying them otherwise and i have a very slow upload. Since google does not want 8192 x 8192 pictures uploaded to a blog, here are the dropbox links for anyone who wants them [ 0 , 1 , 2 , 3 , 4 ]
Here are now some screenshots. Its in no way a game, those are just renders to a BufferedImage to test the dungeon creation algorithm. Maybe this turns into a game, we'll see.
If it does i think i found the right library to do the job.
LibGDX looks awesome. Write code once and deploy it on any Desktop, Android and Browser, maybe even iOS soem time in the future. It also enjoys a very active developement [ making it hard to find an up to date tutorial ] and has great documentation.
Hope you enjoyed this. Good night :)
Tuesday, August 7, 2012
Finally
Now those are some nice connected dungeons :)
i will tweak the start point generation to be more _random_ but for now i like the results
i will tweak the start point generation to be more _random_ but for now i like the results
Monday, August 6, 2012
A*Star fail
Hey,
just wanted to make a quick post, finally found some time for recreational programming again ^^.
Here is an implementation of the A*Star algorith WITHOUT heuristics.
this might still need some work. Its meant to be a cave generator for a plattformer at some point, but as you can see, its still a very early prototype consisting of a prng and a cellular automaton
just wanted to make a quick post, finally found some time for recreational programming again ^^.
Here is an implementation of the A*Star algorith WITHOUT heuristics.
this might still need some work. Its meant to be a cave generator for a plattformer at some point, but as you can see, its still a very early prototype consisting of a prng and a cellular automaton
Subscribe to:
Posts (Atom)



















