Thursday, January 23, 2014

Python Collatz Conjecture Script

One of my current ongoing projects is to teach myself to code in Python. While I have been going through the lessons in Learn Python the Hard Way, (I've been on lesson 23 for a few weeks now), I have been on the lookout for things to code with Python.

Then, the Collatz Conjecture popped up on my Google Plus feed...

The Conjecture states that for any natural number:

  • If even, divide by 2.
  • If odd, multiply by 3 and add 1.
  • Repeat these steps until you end up with 1. 
The conjecture states that as long as you are using a natural number, you will eventually end up with the number one.

Sounds like a good thing to practice coding with. Here's what I've got:

i = 0
x = int(raw_input("Please input a number> "))

while x != 1:
 i = i + 1
 if x % 2 == 0:
  x = x/2
  print "%d> %d" % (i, x)
 elif x != 1:
  x = 3 * x + 1
  print "%d> %d" % (i, x)
 else:
  print "%d> %d" % (i, x)
For every step, it prints out the step number and the current number. Example output:

Please input a number> 94
1> 47
2> 142
3> 71
4> 214
5> 107
6> 322
7> 161
8> 484
9> 242
10> 121
11> 364
12> 182
13> 91
14> 274
15> 137
16> 412
17> 206
18> 103
19> 310
20> 155
21> 466
22> 233
23> 700
24> 350
25> 175
26> 526
27> 263
28> 790
29> 395
30> 1186
31> 593
32> 1780
33> 890
34> 445
35> 1336
36> 668
37> 334
38> 167
39> 502
40> 251
41> 754
42> 377
43> 1132
44> 566
45> 283
46> 850
47> 425
48> 1276
49> 638
50> 319
51> 958
52> 479
53> 1438
54> 719
55> 2158
56> 1079
57> 3238
58> 1619
59> 4858
60> 2429
61> 7288
62> 3644
63> 1822
64> 911
65> 2734
66> 1367
67> 4102
68> 2051
69> 6154
70> 3077
71> 9232
72> 4616
73> 2308
74> 1154
75> 577
76> 1732
77> 866
78> 433
79> 1300
80> 650
81> 325
82> 976
83> 488
84> 244
85> 122
86> 61
87> 184
88> 92
89> 46
90> 23
91> 70
92> 35
93> 106
94> 53
95> 160
96> 80
97> 40
98> 20
99> 10
100> 5
101> 16
102> 8
103> 4
104> 2
105> 1

Thursday, January 16, 2014

Tales From Overguilds, Part 13

1st Granite, 1054

The Coming Of Werelizard Akul Icgasom
or
 Why you fear the night.


Well, I have an angry werelizard in my back yard. And he managed to bring a bunch of terrified troglodytes to the surface with him. Time to summon my military, and observe the fun. 

No. Wait. It seems the terrified troglodytes are fighting back.

I'll let them fight it out instead. Then my military will polish off the victor.

And Akul is all ready sporting wounds on his head, right lower arm, left lower arm, and left upper leg. Akul, you dissapoint me.

Or not. I also find an unconscious troglodyte who is unconscious and has been seriously mauled. About this point, I see a flashing pale blue U appear on screen followed by this announcement:



The human Akul Icgasom flees off the edge of the map. An angry troglodyte pursues him, but unlike Akul, it does not leave the map.

Assuming I don't have to put down any disturbances by angry troglodytes, it seems my dwarves can get back to whatever it is I was working on.

And after a brief computer problem forcing me to reboot everything, I do return to whatever it was I was working on.

Or at least I try to get back to whatever I was doing...

I read the announcement that one of my woodcutters has bled to death.

His body is laying in a pool of his own blood while an infant crawls nearby and a small group of dwarves hang out near a pond. It would be a great scene to be masterfully engraved on somebody's bedroom wall.

He's big and covered in dwarf blood.
Several of my dwarves have reported being scared by a Dwarf Eating Feral Draltha, so I have dispatched the military to kill it. I anticipate that should solve that problem.


Two of my military dwarves and a blue peacock chase down the big scary herbivore and kill it.

I hope my poor jeweler wasn't too badly injured...

My engravers continue their efforts to smooth and engrave high traffic corridors and living spaces. I currently have them working in a busy hallway connecting the farming and related workshops to my warehouse and trade level. I also have a series of alcoves carved along the sides, it is my plan to position statues along the corridor
once the engravings are completed.

And NOW there's a troglodyte chasing around a mule. Time to call up the militia (and peacock?) again. Likot Ebalkeskal showed up quickly and killed it with her *bronze battle axe*. They're much more effective not that they have real weapons.


This troglodyte makes her fourth kill (although I was hoping that the peacock would get credit for killing the draltha), if I manage to get her some armor now and more training, my milita just might be lethal yet.

I had plans for building a danger room for my military to train in, but this cycle of having to kill a dangerous animal every time I try to do something productive seems to be working too.

And before I finish my session, I am greeted with the scariest message I have seen today:

 More Tales from Overguilds.

Sunday, January 5, 2014

Celebrate Snow Days with Sock Puppets!

Cure cabin fever by conversing with homemade sock puppets. 
The "polar vortex" has parked itself in my front yard and it's too cold to contemplate opening the front door, let alone leaving the house...

So, what's the best way avoid becoming a half-crazed shut in during this blast of arctic weather? The answer is obvious- make a sock puppet and become a fully-crazed shut in!

I used an old (and only slightly worn) sock and strips of an old t-shirt for the hair and inside of the mouth. Also inside the mouth is strips of cardboard. The eyes are embroidered on with black thread.

Wednesday, December 25, 2013

Pi Anyone?

Merry Christmas, Everybody!

This year I got a Raspberry Pi, which happens to be exactly what I wanted...

For those of you who aren't in the know, the Raspberry Pi is a low cost single board linux computer, and it is very popular in hobby electronics circles.

I haven't figured out exactly what I wanna do with it, but for the time being, I'm gonna load upo Raspbian onto an SD card and hook it up to my television.

Monday, December 23, 2013

Tales From Overguilds, Part 12

Alright... where were we?

21st Opal, Midwinter, 1053

My miners are still carving out bedrooms and removing a few surface ramps. I'll take the time to start beautifying the fortress. And as admiring a tastefully arranged statue goes along way towards improving a dwarf's mood, I have asked my manager to have twenty rock statues constructed. Later these will be place in various high traffic areas. 

Now, which of my idlers should I set to engraving duty?

I set two unemployed hunters to engraving duty and designate a section of the bedroom wing to smooth. Soon one of the two loafers show up and gets to work, but to my surprise, so does my broker. And he smooths FAST. Investigating, it turns out that he is a legendary engraver. Nice.

Ghosts are cool.
I look around to see what else is going on... It seems on the surface I've gotten a chunk of the ramps dug out (finally) and a series of walls underway (again, finally). And I spot... a ghost!

My sprawling catacombs.
Who am gonna call? Nobody at the moment. But if it does become a problem, I'll just call my engraver and have a memorial slab carved.  But that does remind me, what ever happened to that plan of mine to put in some catacombs?

 There's my catacombs, and they need some work. But, that'll have to wait until my miner finished digging out the bedrooms. Otherwise, I'll never get anything done.

I let things run for a while- I make sure my workshops are still operating. I set one of my jeweler's workshop back to encrusting furniture, my engravers continue smoothing things, and my farmers complain about being out of plump helmet spawn again. Then I get the following notification:

It seems a bunch of troglodytes have arrived, too. Anyone wanna bet it's a troglodyte werelizard?

The Werelizard Akul Icgasom has come! Who the heck is the Werelizard Akul Icgasom? It'll find out next time (I promise, it'll be less than a month till the next update). Seeing as it's almost Christmas, I figure I'll upload a copy of my save game for any readers who wanna pull Akul's tail off to see if it'll grow back...

Quit yer yappin', I wanna torture me a Werelizard! (Dwarf Fortress File Depot download link)



Monday, December 9, 2013

Frankenstein's Army (2013)

Near the end of World War 2, a team of Russian soldiers find themselves battling an army of reanimate corpses turned into horrific killing machines built by the deranged descendant of Victor Frankenstein.

Actually, the plot is simpler than that, it's basically a slasher film where the killers hack their way through soldiers rather than fornicating teenagers. With the added bonus of a mad scientist ranting towards the end. Plus, the monsters are actors in costumes, which unfortunately feels like a novelty these days.

If you love all things horror, then this movie is pure fun with a side order of imaginatively scary monsters. If you like plot and story however, it's a bit thin in those departments. Even worse is the film's use of  shaky cam. It doesn't make the movie feel any more real, as if it was footage released from old Soviet archives. No, it just gives me flashbacks of playing Wolfenstein 3D as a teenager. Filmmakers who may be reading this please take note: skaky cam is a perfectly fine filmmaking technique that should never be used again. EVER.

What's that? You say "But I have a legitimate reason to use shaky cam..."

No. No you don't. No Shaky Cam.

Despite these shortcomings, I enjoyed this movie. It's the perfect type of movie to watch late at night with a bunch of friends with the lights out. Or if you can't decide between watching Enemy at the Gates or Hellraiser.



Official Site
Imdb

Wednesday, November 20, 2013

Tales from Overguilds, Part 11



Winter, 1053



A diplomat has left unhappy. Well isn't that too bad. Maybe if my expedition leader/legendary miner wasn't still recovering from being mangled by that  troglodyte last season...

But thanks to the bronze and steel bars I traded from the caravan last season I can finally forge some real weapons. Now my militia happily chiffonade troglodytes with real battle axes rather than use the cheap wooden ones they used on the troll.

Now, all I need to do is....  wait, what?

#@&%, he was legendary, too!


That does explains why he wouldn't meet with the outpost liason. Ineth was found dead in the public barrack where he had been recovering from his injuries. Who the heck was on give food & water duties? I suppose it's time to build some catacombs before we get ghosts.


I'll have my new miners get right on that. Just as soon as they finish digging out my bedroom wing.


And, I'm greeted with another announcement. My mayor (I've got a MAYOR? When did that happen. Did you guys know I have a mayor?) has mandated the construction of a crown. The dwarves sure didn't waste any time electing a new leader, did they?
I wonder what she's making with all that?

Yay! My weaponsmith has been taken by a strange mood, and was last seen carrying some silver bars to the forge that she just claimed. I hope to have a legendary weapon soon... I haven't had one of those since I had got a goblin bone ax in the 2d version.

After a little bit of waiting and a draltha reverting to a wild state and mauling a baby to death, I have:

Finally! An artifact that's not useless!



Rabed Melist, a silver spear! Now I might just train up a speardwarf.

More Tales From Overguilds