Monday, July 29, 2019

Back to the Back to the Map

I returned to my work on the terrain builder. My thought was I would update it to build the land masses outward from their centers. I wasn't sure how I was going to go about it. In my head I was seeing it as working in a circular path outward.

The more I thought about it the less I liked it. Fortunately as I was coding the solution hit me. Recursion. So instead of going in circles around the center I would begin at the center with a distance variable set to zero. As I work out, passing that variable to iterative calls, I used it to decrease the likelihood of cells being land further from the center.
Each call checks the current point and calls the function for its neighboring points. The result vaguely looks like a continent crossed with a confetti explosion. When zoomed in to game play distance it actually looks pretty good. It even builds out some ... acceptable mountain patterns.

Now I need to work out collisions, currently it isn't quite right. Actually I need to do some collision work - game wide. Then I need to improve the variety of the terrains based on modifiers specified in the library files.

Tuesday, July 9, 2019

Back to the Map

I've decided to re-attempt the planet surface generation logic. My previous attempt was ... not so good. So this time around I've decided to keep it simple. The maps it generates are fully ASCII and everything is contained within the main class, no OOP classes etc, just methods within main.

I have some modifiers that will later be passed in to create different types of worlds - temperature, landmass counts, etc. These affect what is created. I start with the polar arctic regions then I create random landmass centers and work out from those.

I'm currently walking up and down the center then east and west from those points. That is working ... Ok. I need to tweak it to work all around the center outward, I think that will give me better shapes.

Once I am happy with those I'll move on to features like mountains, rivers, and lakes.

Then the trick will be making it OOP and converting ASCII to image tiles.

Wednesday, May 8, 2019

Clipboard Trouble

In my foray into c++ so far there's one piece that is still eluding me: copying to the clipboard.

I want to be able to copy field values directly to the clipboard. So far this is eluding me. I've seen qtclipboard snippets but I've yet to get that class successfully added to my includes - even after installing qt on my laptop. I think that part of my problem is I'm trying to maintain a single code base. I don't mind needing to build windows binaries all the time, I DO need to structure everything so I don't have a nix directory and a windows directory (AND yet not have messy directories). I want one copy of the code files, one copy of the help defs, that's it.

At this point, after trying a few different options, I've put it on the back-burner.

Monday, May 6, 2019

Simple Fixes

I'm not sure if I'm a lazy developer, but I like my code like I like my computer's desktop - minimalist. I can appreciate engineering a solution for flexibility and robustness but either my skills are way below the people who write such code or their code is really difficult to decipher and update - or simply implement. If I'm looking for reusable code snippets I can use, as soon as my eyes start to glaze over I move on and look for a simpler piece of code. I'm pretty sure that says more about my skills than the snippets authors.

A great example of my minimalist tendencies is a fix I made this morning. I don't code in Python but I currently support an image data extraction script written in it (So I'm doing a lot of hilariously noobie web searches). I need to run large batches through it via input file of DB record IDs. The trouble is it isn't 'resumable'. So if it works all day and crashes before the batch is done, it has to reprocess everything from the top.

I'm not sure what other developers would do, here's what I did:

If it doesn't exist, I create a file:
<input file name>.bmark.txt

Where the script reads the input file into a tuple, I set bookmarkid the first row of the bmark file.

For each row of the input file... If bookmarkid is not "", is the current input id the bookmarkid? If so, clear the bookmarkid.
So the next row in the input, we have a bookmarkid of "" so we add the input id.

Later as we run the ids through SQL, as each one completes, I replace the bmark file contents with the successful id.

When everything is done, I delete the bmark file, just to be tidy.

So that was my minimalist solution to the problem. I added a little file to persist the last successful id that was processed. And when the script is started, I grab any 'bookmarked' id and check for it (The code was already reading the rows into a tuple, I just skipped adding them to the tuple until the bookmarkid == ""), resuming at the next row.

Win Build on Nix

I have completed a functioning version of NMX (Note Matrix - a project I've been building and rebuilding in various languages and platforms for - probably almost 15 years). It is a console-based notes / bookmarks / todo list / contacts etc app. It uses SQLITE for its database and every time an entry is viewed it creates a txt file of that entry, so you can view your data in any text editor (This feature came about in the Java version, so if you have Java issues, or the DB becomes corrupt, or incompatible with future versions of NMX, you can still read your data).

Being a total c++ noob, compiling the Windows binary was a challenge. I setup a virtual Windows box and tried Mingw. I had a hard time getting the SQLITE .dll linked. After a few attempts I decided to go with an IDE to build it. I went with a free lightweight app: Code::Blocks. I got my c++ files loaded into a blank project and linked the SQLITE .dll and it built!

My only concern was that the Windows OS in my virtual box would expire in about a month or so and I would have to rebuild it. So my goal was to be able to rebuild the Windows binary from within Wine.

I downloaded and installed Code::Blocks and Mingw in Wine. I had to get the Ming Gcc/G++ installed then it worked! I had to find and add the .dll versions of the standard libraries. I put these in the same directory as my sources. I tried creating a .bat file to call the same commands that Code::Blocks does when it rebuilds, but this didn't seem to work, so I'm stuck with Code::Blocks, but at least I can run it in Wine instead of a virtual machine.

Wednesday, April 17, 2019

CPP Progress

I have made progress at last. My implementation of my note-taking app now parses input, doing wildcard matches on the users input, against pipe delimited possibilities. It now creates new Entries and has a method to show them. I need to create the view entry command and I need to format the output, but it's a solid start.

I'm slowly beginning to feel more comfortable with the language and how to accomplish what I need. Pointer types are still tough, but getting better. I finally resolved the re-declaration error from header files being included more than once.

I'll have to setup a Windows vbox so I can grab the SQLITE .dll and compile it for Windows.

More to come...

Monday, April 15, 2019

C++ No Class

I've always worked with OOP patterns, even when I didn't know what I was doing. Honestly it makes sense to me, naturally. It is easy for me to wrap my head around how large problems can be broken down into manageable objects. I feels organic and natural to me. As many OOP explanations point out, it mirrors reality. I have a much harder time understanding functional paradigms. it just feels like the dreaded 'spaghetti code' to me.

However, as a high level language developer digging into C++, my feelings are a bit reversed. When I attempt to define and consume classes etc, I keep running into all sorts of issues - redeclared variables due to includes. However if I remove the offending includes I get 'cannot find X'. I feel as though I'm in a catch 22.

So for my first C++ project I've decided to avoid the headache altogether and code everything within functions. Sort of a noobie functional paradigm. Instead of classes I'll have header files containing that element's functions which are called in main and in turn can call other functions if needed.

So far I have sqlite hooked up and some basic string parsing - which is frustratingly difficult so far. I'm amazed at how difficult simply doing a string split is in C++. More on that in future articles.

Introduction to WorldWeaver

A New Iteration  I've been working on the second manifestation of my Interactive Fiction engine - WorldWeaver - for about a year now. I ...