Monday, July 16, 2018

Web Programming projects

I am currently taking a web programming course and have already worked quite a bit with PHP and MySQL.  One of my major assignments required a student information table to be modified and the table of students to be displayed.   This course has been good for broadening my skills as more applications become web-based. 

Setting up the initial student table
First I used a SQL script to fill out the initial student table.  This was done through XAMPP and phpMyAdmin.


Student information displayed in HTML table using PHP
 After setting up the table, I needed to write a PHP script to display the contents of the MySQL student table.  This table also used CSS to style the table headings to be gray with bold text, the ID column to be italicized, and the other cells to be standard format with white background and black text.
The form for modifying the student table

The output after deleting student with ID of 1
The first action was to delete a user.  This action was detected if the ID for the student to be deleted is filled.  A MySQL query was generated with the POST data in PHP to delete the user before displaying the updated student table.
Form filled out to add a new student

Table updated to show the additional student
  Action #2 was to add a new user to the student table.  This action was detected if at least ID data was filled out in the student-add part of the input form, and the delete ID was empty.  Some text was shown at the top of the page to say what action is performed and also showed the POST data sent to the PHP file.  This post data was then used to form a MySQL query to add the student to the table if they had a valid ID.
Form filled out for updating student information

Table updated to reflect updated student #7
The third and final action was to update an existing student's information.  In order for this action to be detected, ID's for both deletion and addition had to be blank and the ID for update had to be full.  Only the posted text inputs that were full would be used in creating the update query, meaning one could opt to leave some fields unchanged.

While not the most advanced project, I thought I learned a lot from it.   It would be very helpful for creating webpages with dynamic input.  MySQL and PHP are not too hard to use, but they can be quite powerful for making a data-driven website.  Up to this class, my experience with web programming was only static HTML pages with a small foray into CSS.  I think this course is making me a more complete programmer.

Friday, June 29, 2018

Dream Coaster Rider


Lift hill on "Corky", a standard corkscrew coaster

Dream Coaster Rider was originally to be part of a project called Theme Park Builder 3D, which later got renamed to OpenParkDeveloper.  That project didn't pan out, but I still have a working roller coaster simulator to show for it.
Tracks were defined using XML data files.  How tracks worked was that elements were defined in their own tags, and later referenced later on in the track element sequence. Blocks could be defined in parallel to individual elements in the track file.  This separated element geometry from actual block lengths and their logic.

Blocks on a wooden coaster "Tornado"


Rides had different operation modes, including full-circuit, shuttle loop, and reverse incline shuttle.  In spirit, many of these modes followed conventions of RollerCoaster Tycoon. 


The program would load most arguments from the command line, including track file, and various switches pertaining to the ride.  One could bypass this using an I/O redirection file.

The simulator was programmed in C++ and was heavily object-oriented making use of singleton and factory design patterns.   For example, each style of track had it's own procedural factory which defined a span of track in IJK coordinates.  This was then extruded using the interpolation of the track's spline to generate track polygons.

I learned quite a few things on this project, including spline re-parameterization and the application of forward right and up vectors, treating them much like I would the standard Cartesian axes.  G-Forces were calculated by taking the instantaneous acceleration and projecting it on to i, j, and k unit vectors.

Heading into a barrel roll with g-forces and other ride stats displayed in the top-left.

More about the project and the source code can be found here:
https://github.com/RollerSimmer/DreamCoasterRider
https://github.com/RollerSimmer/DreamCoasterRider/releases

American City Voronoi

This in a Java Swing application which tries to find areas most reached by a city. It uses a modified Voronoi diagram drawing algorithm which factors in a "reach" value in addition to the distance when drawing the diagram. As it stands right now, reach is the cubic root of the metropolitan area population divided by 100K. The distance comparer compares the distance between two cities and a point using the following formula.

compVal = bDist * aReach - aDist * bReach

Positive values mean b is less reachable than a is.
There are checkboxes for using taxicab/manhattan distance, using reach or using the standard voronoi diagram drawing algorithm, and minimum population culling. The metropolitan areas selected were from the United States and Canada. I used the following lists for reference, but took some liberties in combining close-by areas as I saw fit.

https://en.wikipedia.org/wiki/List_of_primary_statistical_areas_of_the_United_States
https://en.wikipedia.org/wiki/List_of_census_metropolitan_areas_and_agglomerations_in_Canada

State boundaries were defined from defining state boundaries in Google Maps, and exporting the data into a format that I could easily convert into x,y data in my coordinate system.
 
The following images show what the application looks like in action, as well as the output it produces.

Using the save button, one can generate a picture of the entire map.
In later editions, I allowed for custom area colors.  This map shows a map which included major universities, where the university colors were included in the XML data file.
Later versions also included an improved distance calculator, and linking together cities into regions, as the below picture illustrates.
More about this project, as well as the source, can be found here:
https://github.com/RollerSimmer/AmericanCityVoronoi
https://github.com/RollerSimmer/AmericanCityVoronoi/releases







New Programming Blog

My name is John Anderson.  I often go by the name RollerSimmer online in gaming communities.  This blog will highlight some projects that I have worked on over the years, as well as any ones that I may work on in the future.  It will tie into my Github repository at.

I am a programmer who has worked on various programs related to game development and game utilities.  I also have interest in artificial intelligence, machine learning, computer vision, and computer graphics.

I started out in programming on QuickBasic and Pascal all the way back in the late 1990s.  Throughout the 2000s, I participated in game communities and made utilities for members of the community to use.  During this time I heavily used C and C++.  In the 2010s, I pursued a Bachelors of Science in Computer Science and Mathematics, and currently I am a Masters of Science student in Computer Science.  Throughout my formal education, I was introduced to new languages like Java, Prolog, Python, PHP, CSS, and Bash.  Around 2010 or so I converted over to Linux from Windows, which gave me a lot of free programming utilities to use.

I was most well known for making utilities and trainers for the RollerCoaster Tycoon franchise, most notably RollerCoaster Tycoon 2.  Back then I went by ja227 followed by Parkitect.  My biggest projects for that game franchise were
  • 8 Cars per Trainer - a trainer that edited things in the game while it was running.  The simple menu-only interface was heavily inspired by Beast Trainer for RCT1, but it grew into it's own beast and later versions had so many features that even I don't even remember them all.  Amazingly, this was coded mostly in C without MFC or anything to help me.
  • ParkDat - a specialized save game modifier that modified which plugin objects were tied to a given park.
  • Palette Maker - This command line utility created a color palette object (known as "water" color in game) allowing for crazy parks like black and white retro parks or really dark parks. 
  • Large Scenery Maker - There was already a pretty good RCT2 scenery creator made by Doctor J (James Hughes), but it was really hard to make multitile scenery objects.  This large scenery maker took a large image file, cut it up, and applied height displacements to each tile to create multitile scenery objects.  It came in handy since usually people filled up their small scenery spaces and needed more room.  You could make 1x1 "large" scenery objects and have 128 more slots (I think that was the number)
  • RCT2 ReliABLE - This trainer counteracted a lot of anti-cheat code in the game to prevent breakdowns when people set their lift hills to 255 mph or whatever they wanted to do.
In addition to RCT2, I made a roster generator for Madden NFL 2004. This was one of my first experiments with random number generators.  I thought it was a pretty cool project, and hoped to someday implement some similar features into a football game I had always wanted to make.  I had also made a team editor for Microprose NFL Football back in my early days of programming, but it was never distributed online since the game didn't have a huge following online.  I still think Microprose made one of the best football sims ever, but it was quickly eclipsed by EA's Madden.

Other simulation games that I had made attempts towards making utilities for were Yoot Tower and SimCity 2000.  Yoot Tower proved to be pretty easy to mod since it was mostly just Visual Studio resource files.   I had been able to get a hold of the SimCity 2000 file formats enough to edit the roads and land types, which was the only thing one couldn't really edit in SimCity Urban Renewal Kit.  However, by the time I had made this breakthrough, no one seemed to be interested in the game, and SimCity 4 was about to come out.  SC4 proved to be the most heavily modded SimCity game.

Recent projects of mine have focused more on making physics simulations, artificial intelligence, and generators for both language and landscapes.   These projects, while not serving much of a standalone purpose, are good demos that could be integrated into a more meaningful application.  

One of the coolest projects was a college team generator.  While it didn't have much practical use on its own, it demonstrated the use of grammar rules, probability distributions, and procedurally generating a somewhat realistic world of college team names and colors that could plausibly exist in some alternate universe.  Much like the Madden roster generator, I would love to include it in a future football simulator.  I think licenses are overrated.  I would rather make a great football sim than have proper team licenses.  With a generator that could make a full set of teams each time one wants to start a dynasty mode, it would make for much more replay value.  Projects like this have further fed my interest in natural language processing and generation.  I hope to take a graduate level course on the subject in the future.

I am still interested in game development and design.  I did a couple semesters at a game school, in which I made a couple 2D arcade games and a Minecraft clone.  I wish I could have stayed longer, but things didn't work out there for me.  The short time I spent there was packed with knowledge from people that had worked in the industry, and I learned a lot in a short time.

Some of my earliest forays into programming was on the graphics programming side.  I started out learning about compression and image file formats.  I created programs for palette editing, image loading of PCX, GIF, and BMP formats, as well as a bootleg knockoff of Photoshop and Paintshop Pro that I called DrawProg.  While not very featured, it could be run in DOS.  I developed this in Turbo Pascal over the space of a year.  Before my RCT2 projects, it was my crowning achievement in programming.

In spite of all these projects and degrees, I still have never had a professional programming role.  I hope someday to land a programming gig that can support me.  I have invested 20 years of my life into this pursuit, and I don't feel like quitting any time soon.  I am open to contract work, freelance, part time, and especially full time positions.

https://github.com/RollerSimmer