jaeart.blogg.se

Nokia snake phone
Nokia snake phone











  1. Nokia snake phone serial#
  2. Nokia snake phone code#
  3. Nokia snake phone free#

So what we can do is precompute a random hamiltonian cycle at the start of each game, then have the snake follow that cycle.

nokia snake phone

The trick here is to realise that in the end part of the game, the snake will be following a planar Hamiltonian Cycle of a 2D array: None of the conventional path finding algorithms would work here, so we need a new approach. The extreme memory and speed restrictions means that we do not want to allocate any heap memory, and should run everything on the stack. To collect the food without crashing into itself.īut it needs to run in real time on an 8Mhz processor, and use around 1 KB of memory. We need an AI that can play a perfect game of Snake. This works because on arduino the heap and stack grow towards each other, like this:

Nokia snake phone free#

This function returns the amount of free memory by taking the current stack position (since v is on the stack), and taking the difference to the current heap position. Return (int) &v - (_brkval = 0 ? (int) &_heap_start : (int) _brkval) I needed to be aware of every byte of memory that I used throughout the project, and to compare my theoretical counting against actual usage I used a pretty neat trick that I found on the internet: For me, it has replaced valgrind’s memchecker tool. It’s a memory error checker and it saved my bacon several times. The sanitize=address option is new to GCC 4.8.0 and is extremely cool. Wno-char-subscripts -g -Wall snake.cpp \ Gcc -fno-omit-frame-pointer -fsanitize=address \ I had to write an ncurses output), it was very much worth it. The result was that I could do almost all the development and debugging for the PC.Īlthough this was slightly more work (e.g.

nokia snake phone

Nokia snake phone code#

I wrote the code such that the arduino-specific code was as minimal as possible, and kept in. I got it down to 3.1V before the 5V board gave up). Obviously reliability is probably an issue, but the tolerance for low voltage is well outside the official specs, so in pinch you can really abuse this hardware. I wonder why the Arduino underclocks the processor? As a second side note, for fun I tested a 5V board at 16mhz but actually fed it 3.3V and amazingly it worked. (As a side note, I searched for the particle AVR chip and it’s actually rated at 20mhz and 10mhz respectively. This is because the 5V board runs at 16mhz, but the 3.3V board runs at 8Mhz.

Nokia snake phone serial#

It uploaded correctly, but the serial output was at half the expected speed. I initially made a mistake and used the default 5V option with the 3V board.

nokia snake phone

I previously talked about the code for the display driver, and the code for the snake AI algorithm, but here I want to just tie it all together.













Nokia snake phone