Archive for May 2009

On Computers Modelling People

Our pastor is a foreman and today in church he told us this story:

One day a couple of years ago, a job I was working on with, oh, about 60-65 guys was behind almost two months. I got a call from the office, apparently they wanted to see me right away. I went to them and they told me to give 20 guys the pink slip.

“Why?” I asked, “We’re two months behind!”

“The computer said to,” they answered calmly.

“But have you seen the mountain of pipes we still have to put in this building? We’re behind as it is we need these guys!”

“Doesn’t matter. Computer says to fire ‘em, out they go.”

So, reluctantly, he went and gave the 20 men their pink slips and last checks.

This is where computers should not be used: to model people. It’s one thing to keep a schedule on a computer, it’s quite another to do something because the computer (which definately did not have all the data) said to. Computers are perfect for mathematical modelling like is used for  hurricane prediction, ice core planning, and other scientific fields, but a computer cannot model the human mind. They are not yet that powerfull. My pastor’s point was a completely different one, but my point is this: Businesses should not use computers to map progress of a project. They should have people do it. People can handle the complexities of it more efficiently than any computer that a business has access to. Storing the current status of a project on an intranet is a perfectly fine and usefull thing to do, but having the computer determine the status of a project is a bad idea. In this instance the job took almost 6 months longer than it was supposed to. More than likely nobody will ever read this, but during this story I got several pointed glances from my pastor. I was just glad I don’t do project or cost/benefit modelling! Our pastor could stare down Chuck Norris.

What ShadowBane did right

Before I begin you need a little background:

I have played almost every MMORPG in existence. Everquest I & II, Asheron’s Call, WoW, Shadowbane, Anarchy Online, EVE Online, Runescape, etc. The list goes on but I can’t think of any more now. I am by no means a new MMOer. The three games I have spent the most time on are Anarchy Online, WoW, and ShadowBane.

Now continuing:

ShadowBane is the greatest MMORPG ever created. Ever. Posting nethack scores doesn’t count. MUDs are good, but the old SB RolePlay servers were at least as good. So, here is what makes ShadowBane the best MMORPG ever, and why it didn’t pwn WoW.

  1. Deep, deep lore. Lore is everywhere. Almost all the items have lore. The few NPCs that there are have lore. Every freakin’ thing in the game has lore. I have never been so drawn into a computer game (not counting Morrowind).
  2. Free PvP. After noobland (a small island off the coast of the main continents), there are only 2 no-PvP zones. To some people, this was a turn off. As a PvP lover, this was heaven.
  3. Thieves could actually steal. Yes, that’s right. If you played a thief, you got the Peek and Pick Pocket powers. So even though thieves routinely get their butts whooped in PvP (until you get dual Vorgrim Daggers), they were still fun to play.
  4. Sneak turned you invisible. And there was no friggin’ way for other players to see you! None! Zip! Nada! The only Sneak-breaker is an AoE! Scouts, and the Bounty Hunter runes (which I spent 3 weeks camping before finally scoring a ninja loot) let you see them, but until they are HIT they remain invisible to everyone else.
  5. The classes were well balanced and made sense. Yes, as i mentioned in #4, Scouts can see sneaking people. Priests could raise dead, Necromancers could raise skeletons. Druids had nature magic and were the primary AoEers. Assassins were high-dps. You get the picture.
  6. The races were exagerated. It cost skill points to play certain races, such as the Vampires and Aracoix. But with good reason. Vampires have no MP, but instead use HP for everything. That sounds bad, but they also get the Vampire’s Kiss ability, which lets them drain HP from pretty much anything. And Aracoix could fly. I’ll give you time to read that a few times. THEY COULD FLY!!!!!!!!!!!! What other MMO lets you do that from the start of the game (FlyFF doesn’t count!).
  7. The land was big, but not too big. Just big enough that you could run across it (because there was no transport system other than Runemasters, who could insta-port you from city to city), but wouldn’t want to. Flying could take you across oceans and get to places no one else could.

And now why WoW killed it:

  1. At launch, a couple of crackers teleported the one safehold (aka No-PvP city) into the middle of the ocean. Oh, and the lag was bad.
  2. The graphics were sub-par and the game is a memory hog.
  3. Free PvP. That’s not for everyone, but for those who love it, WoW has it too, it just looks prettier there.
  4. The advertising was targetting at hardcore players, not everday people. The few TV spots made parents want to shield children’s eyes with the beutifully rendered battles and dark magics.

Anyway, I’ll be playing Shadowbane till they shut it down. The rest of you can go back to your WoW (or Runescape) now.

No batch processor?

Why in the world does Adobe Illustrator not have an export batcher? I have 188 high-res photos to export from .ai to .png in 2 different sizes (thumbnail and fullsize). It makes my life much more frustrating. I did get ~40 done today, but I would’ve had them all done with a batch processor (not counting cropping off some whitespace afterwards, but that’s quick enough). On a slow computer the exports take awhile, and I have to load, preview export, resize, and export each individual one manually. Isn’t the point of computers to automate routine tasks?

Besides that, my day went pretty well. I just finished up a new song, the first one I’ve done any post-processing on in awhile. It turned out pretty well. And I got my hands on a copy of Neverwinter Nights Diamond. That was the reason i didn’t post yesterday.

One last thing: today I worked more on my work-in-progress Pen-and-Paper RPG: Twin Lands. You can check it out at http://smithy.ath.cx Any comments would be appreciated.

First day at work

Today was my first day working what some would call a real job. As in 9-5 desk job (or in my case 8-4). I am, as I mentioned before, working on the backend of my employer’s site.  But I am also modifying the frontend to work with said backend :D . Right now the whole thing is encapsulated in 4 files: .htacces, item.php, items.php, and br_db_abstract.php  (br stands for my employer’s name. First one to guess it gets  a cookie!) It’s your average-ordinary-everyday-mod_rewrite+PEAR::MDB2+inline-php-prints. Pretty standard stuff. It’ll list the items in a category (items.php). Display the item (item.php) and allow it to be ordered. The db_abstract is to keep the connection code out of the main PHP pages. Anyway…today went well. Nothing really happened besides that. Just the hubbub of normal work. It’s not like I normally don’t spend most of my day coding during the summer months (only some days! no worries, I’m not a fat junk-muncher). I think I’ll actually enjoy this…

Back from North Carolina…with much more knowledge of Perl

So…I did very little over the past 5 days. Ate, slept, played Warcraft III, and Perled. Lots of Perling. I can now write a semi-competent script to do something other that format the printing of “Hello, World!”. When I got back tonight, I went straight to my computer and threw together another monosynthic song, which isn’t up on reverb yet. About the end of this month I’ll albumize it and put it up on jamendo. I can’t find it now but the thing that brought the music to mind was someone who recorded the sound of his perl script collection and put it up on jamendo. Some of them (which he claims were the better-written ones with strict pragma) were actually very good. Anyway, I start work tomorrow writing the backend of my new employer’s commerce site. I anticipate more than one stress-wracked night of tossing and turning wondering if my security is up to par…

Got a job, going on vacation, and uploaded some new music

Alright, today I interviewed (and got) a job working for a small company here in town. I will be working on the backend of their website and will be getting 8$/hour and working ~40hours a week. That’s quite a bit of money for someone still in high school (~320$). Also, I realize now how stupid it was to start the 14DRL when I am going on vacation tomorrow xD. So I will continue that after I get back next monday. I start work next Tuesday, so it may be put off a bit longer.

One last thing, even though my reverbnation profile hasn’t been updated in almost a month, I have been making music. I put up three new ones just now. Marvel, Stop the FUD, and Timarus. Have at ‘em at http://reverbnation.com/segfult. (WARNING: minimalist techno/trance. No flames if you don’t like that genre)

P.S. for Crouse: I reeeeaaally like the blog theme. Please don’t change it.

14 Day Roguelike – Day III

Today I finally overcame my collision detection troubles. I also added mobs that randomly move around. They have a Damage Point (dp) and Armor Point (ap) rating, as well as a Health Point (hp) rating. My attack_mob(int y, int x) function works perfectly except that it apparently doesn’t store the new HP value in mobs[i].hp. Eventually I’ll figure out how to make that work…eventually.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
#include "curses.h"
#include "signal.h"
#include "stdlib.h"
#include "time.h"
 
//Define the map height and width
#define MAP_HEIGHT 40
#define MAP_WIDTH 30
 
//Create the 2D arrays for the floor and walls
bool floor[MAP_HEIGHT][MAP_WIDTH];
bool walls[MAP_HEIGHT][MAP_WIDTH];
 
//NCurses player yx
int player_y = 0;
int player_x = 0;
//Map player yx
int player_map_y = MAP_HEIGHT / 2;
int player_map_x = MAP_WIDTH / 2;
 
//Function prototypes
static void finish(int sig);
static bool proc_in(int c);
static void draw_map();
static void draw_player();
static void init_player();
static void init_mobs();
static void draw_mobs();
static void proc_mobs();
static bool check_collision(int y, int x);
static void attack_mob(int y, int x);
 
typedef struct mob_
{
        //NCurses Coordinates
        int nc_y;
        int nc_x;
        //Map Coordinates
        int mp_y;
        int mp_x;
        //Combat stuff
        int hp;
        int dp;
        int ap;
} mob;
 
 
typedef struct player_
{
        int nc_y;
        int nc_x;
        int mp_y;
        int mp_x;
        int hp;
        int dp;
        int ap;
} player;
 
int test = MAP_HEIGHT / 10;
 
mob mobs[MAP_HEIGHT / 10];
 
player p;
 
//MAIN
int main(int argc, char * argv[])
{
        //endwin() on SIGINT
        (void)signal(SIGINT, finish);
        //NCurses init stuff
        (void)initscr();
        (void)keypad(stdscr, TRUE);
        (void)cbreak();
        (void)noecho();
        (void)nonl();
 
        //Seed rand using time
        srand(time(NULL));
        //Generate a basic map
        int y = 0;
        int x = 0;
        for(y = 0; y < MAP_HEIGHT; y++)
        {
                for(x = 0; x < MAP_WIDTH; x++)
                {
                        floor[y][x] = TRUE;
                }
        }
        for(y = 0; y < MAP_HEIGHT; y++)
        {
                        walls[y][0] = TRUE;
                        walls[y][MAP_WIDTH - 1] = TRUE;
        }
        for(x = 0; x < MAP_WIDTH; x++)
        {
                walls[0][x] = TRUE;
                walls[MAP_HEIGHT - 1][x] = TRUE;
        }
        //Init the player
        init_player();
        //Init the mobs
        init_mobs();
        //Draw the map
        draw_map();
        //Draw the mobs
        draw_mobs();
        //Draw the player
        draw_player();
        //Refresh the screen
        refresh();
 
        //Loop forever
        while(TRUE)
        {
                //Only refresh the screen if something happens
                if(proc_in(getch()) == TRUE)
                {
                        //Process the mobs
                        proc_mobs();
                        //Draw the map;
                        draw_map();
                        //Draw the mobs
                        draw_mobs();
                        //Draw the player
                        draw_player();
                        //Refresh the screen
                        refresh();
                }
        }
        return 0;
}
 
static bool proc_in(int c)
{
        //Process the key that was pressed
        switch(c)
        {
                case '4': //If 4 then move left
                        if(check_collision(p.mp_y, p.mp_x - 1))
                        {
                                p.nc_x--;
                                p.mp_x--;
                        }
                        return TRUE;
                        break;
                case '6': //If 6 then move right
                        if(check_collision(p.mp_y, p.mp_x + 1))//But only if there is no wall
                        {
                                p.nc_x++;
                                p.mp_x++;
                        }
                        return TRUE;
                        break;
                case '8': //If 8 then move up
                        if(check_collision(p.mp_y - 1, p.mp_x))//But only if there is no wall
                        {
                                p.nc_y--;
                                p.mp_y--;
                        }
                        return TRUE;
                        break;
                case '2': //If 2 then move down
                        if(check_collision(p.mp_y + 1, p.mp_x))//But only if there is no wall
                        {
                                p.nc_y++;
                                p.mp_y++;
                        }
                        return TRUE;
                        break;
                case '1': //If 1 then move down and left
                        if(check_collision(p.mp_y + 1, p.mp_x - 1))//But only if there is no wall
                        {
                                p.nc_y++;
                                p.mp_y++;
                                p.nc_x--;
                                p.mp_x--;
                        }
                        return TRUE;
                        break;
                case '3': //If 3 then move down and right
                        if(check_collision(p.mp_y + 1, p.mp_x + 1))//But only if there is no wall
                        {
                                p.nc_y++;
                                p.mp_y++;
                                p.nc_x++;
                                p.mp_x++;
                        }
                        return TRUE;
                        break;
                case '7': //If 7 then move up and left
                        if(check_collision(p.mp_y - 1, p.mp_x - 1)) //But only if there is no wall
                        {
                                p.nc_y--;
                                p.mp_y--;
                                p.nc_x--;
                                p.mp_x--;
                        }
                        return TRUE;
                        break;
                case '9': //If 8 then move up and right
                        if(check_collision(p.mp_y - 1, p.mp_x + 1)) //But only if there is no wall
                        {
                                p.nc_y--;
                                p.mp_y--;
                                p.nc_x++;
                                p.mp_x++;
                        }
                        return TRUE;
                        break;
                case '.':
                        return TRUE;
                        break;
        }
        return FALSE;
}
 
 
static void draw_map()
{
        //Draw the map
        int y = 0;
        int x = 0;
        for(y = 0; y < MAP_HEIGHT; y++)
        {
                for(x = 0; x < MAP_WIDTH; x++)
                {
                        //If there is a floor on cell yx
                        if(floor[y][x] == TRUE)
                        {
                                //Draw it
                                mvaddch((LINES / 2 - MAP_HEIGHT / 2) + y,(COLS / 2 - MAP_WIDTH / 2) +  x, '.');
                        }
                }
        }
        move(0, 0);
        for(y = 0; y < MAP_HEIGHT; y++)
        {
                for(x = 0; x < MAP_WIDTH; x++)
                {
                        //If there is a wall on cell yx
                        if(walls[y][x] == TRUE)
                        {
                                //Draw it
                                mvaddch((LINES / 2 - MAP_HEIGHT / 2) + y,(COLS / 2 - MAP_WIDTH / 2) +  x, 'W');
                        }
                }
        }
        move(0, 0);
}
 
static void draw_player()
{
        mvaddch(p.nc_y, p.nc_x, '@');
        move(0,0);
}
 
static void finish(int sig)
{
        endwin();
        exit(0);
}
 
static void init_player()
{
        p.mp_y = MAP_HEIGHT / 2;
        p.mp_x = MAP_WIDTH / 2;
        p.nc_y = (LINES / 2 - MAP_HEIGHT / 2) + p.mp_y;
        p.nc_x = (COLS / 2 - MAP_WIDTH / 2) + p.mp_x;
        p.hp = 100;
        p.dp = 10;
        p.ap = 25;
}
 
static void init_mobs()
{
        int i = 0;
        for(i = 0; i < sizeof(mobs) / sizeof(mob); i++)
        {
                mobs[i].mp_y = rand()%(MAP_HEIGHT - 5) + 1;
                mobs[i].mp_x = rand()%(MAP_WIDTH - 5) + 1;
                mobs[i].nc_y = (LINES / 2 - MAP_HEIGHT / 2) + mobs[i].mp_y;
                mobs[i].nc_x = (COLS / 2 - MAP_WIDTH / 2) + mobs[i].mp_x;
                mobs[i].hp = rand()%250 + 1;
                mobs[i].dp = rand()%25 + 1;
                mobs[i].ap = rand()%50 + 1;
        }
}
 
static void draw_mobs()
{
        int i = 0;
        for(i = 0; i  0)
                {
                        mvaddch(mobs[i].nc_y, mobs[i].nc_x, 'm');
                }
                else
                {
                        mvaddch(mobs[i].nc_y, mobs[i].nc_x, 'x');
                }
        }
        move(0, 0);
}
 
static void proc_mobs()
{
        int i = 0;
        for(i = 0; i  0)
                {
                        int a = rand()%4;
                        int y = rand()%2;
                        int x = rand()%2;
                        switch(a){
                                case 0:
                                        if(y == 0 && check_collision(mobs[i].mp_y -1, mobs[i].mp_x))
                                        {
                                                mobs[i].nc_y--;
                                                mobs[i].mp_y--;
                                        }
                                        else if(y == 1 && check_collision(mobs[i].mp_y +1, mobs[i].mp_x))
                                        {
                                                mobs[i].nc_y++;
                                                mobs[i].mp_y++;
                                        }
                                        break;
                                case 1:
                                        if(x == 0 && check_collision(mobs[i].mp_y, mobs[i].mp_x -1))
                                        {
                                                mobs[i].nc_x--;
                                                mobs[i].mp_x--;
                                        }
                                        else if(x == 1 && check_collision(mobs[i].mp_y, mobs[i].mp_x +1))
                                        {
                                                mobs[i].nc_x++;
                                                mobs[i].mp_x++;
                                        }
                                        break;
                                case 2:
                                        if(y == 0 && check_collision(mobs[i].mp_y -1, mobs[i].mp_x))
                                        {
                                                mobs[i].nc_y--;
                                                mobs[i].mp_y--;
                                        }
                                        else if(y == 1 && check_collision(mobs[i].mp_y +1, mobs[i].mp_x))
                                        {
                                                mobs[i].nc_y++;
                                                mobs[i].mp_y++;
                                        }
                                        if(x == 0 && check_collision(mobs[i].mp_y, mobs[i].mp_x -1))
                                        {
                                                mobs[i].nc_x--;
                                                mobs[i].mp_x--;
                                        }
                                        else if(x == 1 && check_collision(mobs[i].mp_y, mobs[i].mp_x +1))
                                        {
                                                mobs[i].nc_x++;
                                                mobs[i].mp_x++;
                                        }
                                        break;
                                case 3:
                                        break;
                        }
                }
        }
}
 
static bool check_collision(int y, int x)
{
        int check = 0;
        if(walls[y][x] == FALSE && floor[y][x] == TRUE)
        {
                if(y != p.mp_y || x != p.mp_x)
                {
                        int i = 0;
                        for(i = 0; i  0)
                                {
                                        if(y != mobs[i].mp_y || x != mobs[i].mp_x)
                                        {
                                                check++;
                                        }
                                        else
                                        {
                                                attack_mob(y, x);
                                        }
                                }
                        }
                }
        }
        if(check == sizeof(mobs) / sizeof(mob))
        {
                return TRUE;
        }
        else
        {
                return FALSE;
        }
}
 
static void attack_mob(int y, int x)
{
        int i = 0;
        for(i = 0; i < sizeof(mobs) / sizeof(mob); i++)
        {
                if(mobs[i].mp_y == y && mobs[i].mp_x == x)
                {
                        int damage = 0;
                        int i = 0;
                        for(i = 0; i <= p.dp; i++)
                        {
                                damage = damage + rand()%6 + 1;
                        }
                        for(i = 0; i <= mobs[i].ap; i++)
                        {
                                damage = damage - rand()%4 + 1;
                        }
 
                        mobs[i].hp -= damage;
                        move(0, 0);
                        if(mobs[i].hp <= 0)
                        {
                                printf("You hit monster for %d damage. You killed monster", damage);
                        }
                        else
                        {
                                printf("You hit monster for %d damage.", damage);
                        }
                        move(0, 0);
                }
        }
}

14 Day Rouge-like – Day II

Today I played around with rewriting everything from scratch in C++. It ended up being object oriented but a pain to use, so I went back to my C implementation. The map system I reimplemented in layers ( a wall layer and a floor layer right now). Trouble is, it still doesn’t detect collisions. I found out that my problem was lack of planning. My player_x and player_y variables use NCurses-relative coordinates, whereas the wall[y][x] is map-relative.  So now I will rewrite that one more time and get it working. If I have too much more trouble I may try using LISP despite having 2 days less and being somewhat unfamiliar with the language.

14-day Rougelike – Day I

This morning I was surfing around and stumbled across references to a mysterious 7DRL. After more research I discovered that this was an acronym for 7-day-rougelike. Where a person works on a rougelike for 7 days and then stops development. Entirely. Permanently. Thinking this was an interesting idea, I decided to have a go at a 14DRL, since this will be my first rougelike and first time using curses/ncurses for anything but tests.

I’m writing it in C using NCurses mainly as an exercise to keep my C skills (which have fallen into disusage) up as well as to learn the NCurses library better. The fact that it’s enjoyable helps too. So…today I got it to Display the map, display the player, move the player, display messages, and show stats. I am, however having trouble with collision detection. How do I get the contents of a cell in ncurses? Googling turned up nothing (well, lots of python). Should I just create an array on map generation containing all impassable cells and check that whenever the player moves? Anyway, I’ll put up sourcecode soon.

For starters…

For starters I’d like to thank David Crouse for all his work on the archlinux.us email addresses and now this blog site.

Funnily enough, right now I’m using Gentoo, not Arch. I still have an Arch install, but primarily I’m using Gentoo.

A little about my computer:

Intel Core 2 Quad Q6600 3.0Ghz
nVidia GeForce 8500
2GB mushkin RAM
640GB WD HDD
WIndows XPx64
Arch Linux
Gentoo Linux
Mac OS X (iDeneb) Leopard

Alright, so now a little about myself:

I’m a high-school student who is homeschooled in Kentucky, USA. I got into computers about 5 years ago when I got a book on HTML from the library. Over the past 5 years I have learned C/C++, Java, PHP, Javascript/HTML/CSS, Python, and bash scripting. By far my favorite is C++. I’m not sure why, I just enjoy writing C/C++ code.
Anyway, my dad does remodeling work around town, and sometimes I will work with him to make some money. One Mr. Chinque that we worked for found out about my interest in computers and recommended that I look into ‘Lie-nuex’ (as he properly pronounced it). Turns out he wrote ASM compilers in the late ’80s and early ’90s, so he knew what he was talking about. So, that’s how i got here. 3 years after trying Ubuntu 6.something-or-other.

I tried Gentoo before Arch, and my computer at the time was slow enough that I gave up before I finished the install. So, finding Arch also minimalist (and liking it’s init system better) I have had an installation of it for the  past year or so. I don’t ever anticipate that changing.

Thanks again Crouse!!