Showing posts with label C++. Show all posts
Showing posts with label C++. Show all posts

Monday, March 7, 2016

From October 2, 2015

I apparently had this written back in October of last year when I was working on a calendar program in C, but I never posted it because it was titled "To be written tomorrow..." and I obviously got fucking distracted. Anyway, here's my (very likely hackish) calendar program.

After mulling over this ALL day, here is the answer I've come up with for this programming project.

/* Write a program that prints a calendar. */

#include <stdio.h>

int main (int argc, char* argv[]) {

    int days_month, week_begin, var1, var2;

    printf("Enter the number of days in the month: ");
    scanf("%d", &days_month);
    printf("Enter the day of the week the first day falls upon (1=Sun, 7=Sat): ");
    scanf("%d", &week_begin);

    var2 = 1;
    while (week_begin > var2) {
        printf("   ");
        var2++;
    }

    for (var1 = 1; days_month >= var1; var1++, ++week_begin) {
        printf("%3d", var1);
        if (week_begin >= 7) {
            printf("\n");
            week_begin -= 7;
        }
    }
    printf("\n");

return 0;
}

I looked up the answer in the book answer key and 50% of my program is almost identical to the author's program. Woohoo!
Unfortunately, that last gnarly bit with the if statement is vastly different from his. He used all sorts of maths like remainder and variables - 1 * variables to get his answer. I can't see the relationships of numbers quite that easily... yet. :(

Thursday, September 24, 2015

Roguelikes

I keep threatening to post about the additional research I've been doing, but I'm so wrapped up in reading about it that I have yet to actually write a post.

That, and work has been a little harrowing. Everyone has wanted their projects completed by Friday this week, which crunches our schedule into a "drop-everything-else-that-was-not-immediate-and-do-this" nightmare. When it's one out of every ten jobs, this isn't an issue; but when it's six out of ten orders, it gets hairy.

Enough about boring work.

The title of this post may have gotten some attention already. Either you are wondering why I would stick those two words together in such a bizarre way, or you are wondering what it was that I found pertaining to this particular style of game (default: neither of these things, just get on with your point).

Roguelikes are a type of game that is based on the 1980's text-game Rogue. They encompass game features such as procedural map generation, turn-based gameplay, and sometimes permanent character death. More information can be found here (Wikipedia) and a basic chronology of roguelikes can be found here (also Wikipedia).

Anyone who has been around this blog for a while knows that I'm enamored with the design of MUDs. Roguelikes began in 1978 with the release of Beneath Apple Manor, the same year that MUD1 was released in England. Both styles of game have their own appeal, though MUDs are by far more intensive as far as content generation goes. I assume that part of what makes roguelikes so popular is the lack of a need for so much manual content generation. The maps of the earliest roguelikes were made up of text characters, as shown below.

Source: http://www.kathekonta.com/rlguide/index.html, which will be mentioned shortly in detail

The classification of roguelikes gets a little bit convoluted, considering there are a large amount of games out there that share some of the same qualities, but not quite all of them. Some argue that Blizzard's Diablo is a roguelike, and others say otherwise, and there are many other cases like this. But these games led to a genre of dungeon-crawling games, of which the goal is simply to traverse the generated maps, find all the goodies, and kill all the bad guys.

I was having a lot of fun doing my research about roguelikes. Somewhere in the midst of it, and I don't know what inspired me to do it, but I typed "how to program a roguelike" into Google.

I have been thrilled with the results.

First, I have to shout super kudos to my first resource. This guy took personal time to write, very candidly, a step-by-step process of programming a roguelike. And the advice he offers in this guide is not specific to roguelikes; it is advice from a professional in the field who is imparting some hard-learned lessons from his experience in software development. I think I find that equally as impressive as the time he has spent writing the guide.


The guide is not complete, partially because of some issues in his platform (look on his blog for more information). Regardless, the 9 articles he has completed are packed with great information about developing a roguelike (or any program) with good structure and clarity.


I also found this article on RogueBasin, a wiki page dedicated to the roguelike genre. It does not go into anywhere near as much detail as the Beginner's Guide does, but it covers some really great points and gives something akin to a checklist for anyone planning to develop a roguelike. I enjoyed some of the considerations mentioned.


Of course, I have to post Archive.org's MS-DOS library. I think it is so neat that they have so many old games available to stream on their browser emulator. Here is a link to a playable version of Beneath Apple Manor, if anyone is interested in traveling back in time.


That about does it for me for today. I want to dive back into my programming exercises in the next couple of days, so hopefully I will have some progress to write about thereafter.

Tuesday, September 1, 2015

[untitled]


I think about this blog frequently. I think about the different directions I've pulled it in; about all the directions I've been pulled in, myself! I ought to be more regular here.

I ought to be more regular in studying the things I want to pursue, too. Here's the hard truth though... When you're not in high school or college, but in the school of the self, there is no grading scale to push you forward. There are only two states you can be: Are you where you want to be? Or aren't you?

For me, I laugh at programmer jokes because I understand them. But can I sit down and write a program? Well, maybe a really short one. It might be good for a couple of computations, but you'll have to use the console to run it. I have a hard time calling myself a "programmer" at this point.

If I had spent the last year or so working nonstop on programming languages, namely C, I'd be able to say a lot more for myself than that, I think. But this isn't a pity party. This is recognition of the truth. If I had worked harder, I would have made more progress.

I took a few detours here and there, and dabbled some in HTML/CSS. It was a good feeling to be able to build my company a website, and, in turn, host my own website for a guild I own in Guild Wars 2. I've been commissioned for a third website by my father's band. I won't say that my time learning HTML and CSS has been wasted. Even so, I'm not very good at it, and other web developers will make me feel stunted because I don't know Javascript or PHP. I started learning PHP too, but got overwhelmed with keeping these languages straight.

Now, after all this time, I'm back in the C seat. There are several reasons for this decision: I have an applicable chunk of code that is open for manipulation. Every time I make headway in a chapter of a book, I go look at this code to see how much more of it I understand. This is my way of quantifying my progress. Can I write a program? Not yet. But I can start making a little more sense of how this program is written and that is loads more than I could do before I worked through that chapter.

I keep my Github updated with recent programs I've written with the goal of working through each programming project at the end of a chapter. Some chapters have 8 projects, but lately they have had upwards of 12 - 15. It's slow going, especially when I have a wedding to plan, a full-time job to work, and all I want to do when I get home is mindless stuff. But when I write a program, it goes there. Find my Github at this link, or in my bookmarks page.

I also want to expand on that bookmarks page a bit more. As I learn things and teach myself how to do more things, I want this to turn into a resource for other people in the same boat I'm in. Those who want to learn how to do this stuff because of a calling or an interest, but don't know where to start. I was inclined to delete the posts I made that were off-topic from C, but I will leave them. It just goes to show how sometimes, distractions happen. And even if you look back at them with some regrets, you still have the experience to show for it.

I hope to be able to post things that are less dreary and more fun in the near future. Fingers crossed!!