Showing posts with label University. Show all posts
Showing posts with label University. Show all posts

Saturday, May 14, 2022

University Postmortem

 University Postmortem

After closing Blazing Games due mostly to too much competition, I returned to university in an attempt to get my bachelor’s degree to have the minimal degree that most companies hiring programmers were looking for and to make sure that my skills were up to date. While pursuing the degree, I was near the top of my class and thought that perhaps it may be worthwhile to get into the research side of computer science so opted to go for my MSc in Computer Science.

What Went Right

Just completing a master’s degree is an achievement. The number of students allowed into a program, at least at the university I attended, is only a small percentage of those who apply. The dropout rate is surprisingly high as well, especially within the sciences. While the graduate level courses are more work than third/fourth year courses, the difficulty jump is not as high as it was from first/second year courses to third/fourth year courses. Granted, the first/second year courses may appear easier to me as I was already familiar with the materials but tended to have to take the courses anyway as self-taught doesn’t count. While it is possible to challenge some courses, it is still a fair bit of work and you don’t save that much by doing it so may as well take the courses to fill in one or two missing spots in your knowledge.

The other major thing that went right was getting an answer to “is research an appropriate field for me?” While I was okay at research, looking at some of my alumni, it is clear that there are people much more suitable to academia than I am. This means that a future pursuit of a PhD is not likely for me. What I have learned about performing research will be useful for my further endeavors and to my surprise has improved my coding skills. The necessarily precise nature of research can be applied to software development, especially for testing software.

Even though there are no plans to pursue a PhD, I found myself really enjoying my work as a teaching assistant. Working as a teacher at a college or equivalent may be something in my future. Failing that, writing books to teach others may be an option. Videos are something I would like to experiment in, but with how over-crowded YouTube is, gaining an audience large enough to cover the effort is unlikely.  Still, a small (few dozen) audience is all I would need for a hobby so will probably give it a shot sometime.

What went wrong

The thesis aspect of my MSc took longer than expected due to a pandemic and the simple fact that I switched what I was working on part way through my research. My supervisor did warn me that the change in research direction would add time but was kind enough to let me go my own direction with research. The area I ended up researching involved multiple areas which did not help matters, especially when I was a newbie at machine learning so was still learning the basics while trying to expand upon existing research. 

Covid-19 probably impacted a lot of research. Normally, the effect on computer science would be minimal, but my research required a user study which requires people so having the campus shut down for a lengthy time was not good. This delay was longer than it should have been as my expectation was that classes would resume in the fall. When it became clear that this was not going to happen, the study was redesigned to be online. 

As already mentioned, my knowledge of the field of AI and machine learning was sparse. I had thought that graduate work was going to be like other courses where students learn the material. Graduate courses do work that way, but the thesis is really about taking a field further (even if only by a baby-step) so existing knowledge about a field is important. Picking a research area because it is something you want to learn is not a good idea. Learning a field while researching is not a good approach. My recommendation to future students is to make sure you are familiar with the field you are getting into before picking your area of research.

Mixed blessings

I am not as good at math as I should be. When working with 3D graphics, I can muddle through the concepts to get things working but don’t fully understand the math. Having to work more with the underlying math behind procedural content generation via machine learning, it became clear that the problem wasn’t entirely a lack of understanding. I use some of the more advanced concepts behind math, the problem is I do this outside of the official math route so don’t know the symbolism or the tricks and techniques to best utilize the concepts. Improving math skills is definitely in my future, it is just a matter of finding time to do so.

When I entered my master’s program, I had thought that my organizational skills were good. There is software available for helping organize and write a thesis. The need for such software, as my organizing methods aren’t bad, was not evident to me. While manually organizing things works, there is a lot of overhead searching for things. Having software that handles and organizes all the research details would have sped up writing the thesis and would have also made me make more notes instead of relying on my memory. There are simply too many things to remember so no matter how good your memory is, you are going to forget things. What is worse, you will remember a detail you want to reference but not remember what article it was in so will have to spend too much time skimming through older articles you have read.

Final Thoughts

While I am not going to pursue my PhD, teaching in the future is not ruled out. While a MSc is not required for being a developer, it doesn’t hurt and the skills I learned while attending graduate school are useful. My future right now is in a bit of a hiatus as I am taking care of my father, and will be doing so until he is at a stage where he can take care of himself with minimal aid. While that is happening, my spare time is going to be on the development of my own game engine. Why? Partially for learning but mostly because of my NIH complex. More on that in the future!


Sunday, July 11, 2021

AI and Game Editors

 For my Masters thesis I am working on a study with Dr. Yong Gao at UBC Okanagan on using Artificial Intelligence to aid in the creation of game levels. This will have you playing a simple platforming game and creating levels for that game using our editor. If you think this sounds interesting you can find more information on LiteTux.ca (redirects to the study site) between July 11th and July 31st.

Now that I have plugged my study, and humbly request that you share the LiteTux.ca link with your friends, I will spend a bit of time explaining what I am researching and how I got to the point I am currently at. I was originally looking at machine learning techniques and applying it to procedural content generation, which is known as PCGML (Procedural Content Generation via Machine Learning). Procedural content generation is the technique used to create new assets through computer algorithms and has been seen in the genre known as rogue-likes but it's also been used in creation of textures from art packages as well as music and sound effects amongst other things.

The idea I had when I first started this research was that if you trained a neural network with good levels then you may be able to get the AI to produce similar looking levels from what it has learned about what good levels are like. There have been several different types of neural networks used to create levels with the ones I developed being LSTMs and autoencoders. The one thing I noticed while experimenting with these was that they do produce interesting game levels but they tend to be still obviously computer generated. My thoughts were that it would be interesting if you could have a human and the AI working together.

Now knowing I was probably not the first person to come to this conclusion, I started looking into this idea and found that there were several editors known as mixed initiative Co-creative editors used for predominantly strategy and dungeon romps but a few other genres were present. The two main forms of editors where ones where the AI would make suggestions as the user edited and ones where the user in the AI took turns editing. I preferred the idea of suggestions so the editor I developed was set up so that as the user made changes to the map the AI would use it's techniques to make suggestions for how to improve the map well procedurally generating areas of the map that the user hasn't had yet to edit. One thing I did notice about most of these generators their editors is that the ones that did use machine learning approaches tended to use evolutionary genetic algorithms. This led to the basic idea for this study which was to see how using deep learning techniques compared to using genetic algorithms for editing and if one of the two techniques produced better overall results.

The game that I was focusing my research on was it very popular platform in game held by a very litigious company so knowing that that I would be having people edit levels for the game would potentially have IP issues. I looked into a clone of this game and found the open source SuperTux game. Unfortunately it was not as easy to compile and get running as I would have liked and had way too many features in there that my editor would not be able to support so I decided to clone the clone creating a simplified version of Super Tux which I called LiteTux. Well this is not the greatest game I have created and is probably a little bit too simplified I think that with a little bit more Polish (such as finishing the animation which I simply did not have time to complete) it would be pretty good game in fact may end becoming a much better game as once the study is completed I plan on not only releasing the game but the editor as open source with the hope that my research on mixed initiative editing will be useful to other people and by other people I mean general programmers not just academia.

Even if the study ends up the flaming disaster I fear it may become due to lack of enough participants finishing the study, I am going to continue to work on both the LiteTux game and the editor even if it is on my own I may apply some of the techniques that I've learned towards other genres. One of the things I am thinking about is my old Mr. Holman game and using at least some of the utilities in the editor to make creating levels for that game more enjoyable. Mr. Holman is on my list of projects that I do want to complete so don't be surprised if next year you see a new version of Mr. Holman with the interactive editor that makes suggestions for you and lets you share levels with your friends.

I hope you enjoyed this brief overview of my research and will support the study or at least tell other people that you think may be interested in the study about it. I will keep you updated on what's happening in future posts but no matter what the results the study the game and editor will live on in one form or another.

 

Saturday, January 19, 2019

Building PCG

A LCG basically uses the following calculation: X[n] = (A * X[n-1] + C) % M. X[n] is the next number in the sequence to generate with A being a specially selected multiplier value, C is a value to add to the generator, and M is the modulus or range of the generator. We will use Rotenberg's values of 141 for A, 3 for C and just use a byte so 256 for the modulus. Lets generate a randogram and see what we get.



While this is not as good as we hoped, it is not as bad as it seems as the order the dots appear is random. We are using an 8 bit generator so what if we went with 16? Obviously the lower order byte would remain the same but what if we took higher bits for the output.




Interesting enough, each bit you shift becomes more random with different shifts having different coverage of the randogram. What if we added a permutation to select from some of the better shifts? If only we had a random way of selecting which shift to use. What about the top 2 bits (more for larger generators)? While they have the most randomness, we may gain overall.


Melissa added additional permutations for rotation, XOR, and XORShift. More permutations are possible if you follow the rules:


  • Bits can be thrown away but you can't make new ones (precious).
  • Target and control groups of bits must be separate.
  • Control bits must not be modified.
  • Can do many rounds and different rounds can have different control bits.

By combining different permutations, it was possible to complete BigCrush using only a 36 bit PCG (Permuted Congruential Generators). So, in conclusion PCG is a family of Pseudo-Random Number Generation algorithms. They are relatively simple to implement. They run Fast as the code is simple boolean operations, multiplications and additions. They are Space-Efficient requiring less than double the modulus size. And passing the TestU01 BigCrush tests shows they are Statistically Good.

Saturday, January 5, 2019

Testing Random Number Generators

There are a number of factors that people look for in a random number generator.


  • Period - How long a generator can run before it repeats the entire sequence.
  • Uniformity - All the numbers within the range will appear.
  • Predictability - how predictable is the next number in the sequence.
  • Repeatability - can the same number repeat itself?
  • Security - is the sequence invertable?
  • Seekability - can we quickly skip over numbers?
  • Streams - How usable is the generator when threading?
  • k-dimensional equadistribution - How well distributed numbers are.

This diverse range of usage inevitably meant that there were a lot of different tests. L'Ecuyer and Simard made a huge contribution to testing in 2007 with the release of TestU01. They took a look at the myriad of tests that were available and created a test suite that includes a large number of previously independently published tests. They combined a number of different tests into batteries of tests (SmallCrush, BigCrush). Lots of the random number generators that were in common use at the time failed the test suite. The PCG paper covers testing of a large number of random number generators for those of you who are curious.

TestU01 is a C library with tests and generators for the most common PRNGs. This means that you need to write a simple C program to run the tests that you desire. Here is the version of Java's random number generator that I wrote to test it. Note that the values used are based on the API documentation and are the minimal random number generator that is required.

// Adapted from TestU01 manual, Figure 2.2, Figure 2.4

#include "TestU01.h"

// Example PRNG: Xorshift 32

static unsigned long x = 2463534242U;
static unsigned long a = 0x5DEECE66DL;
static unsigned long c = 11U;

unsigned int jvmlcg (void)
{
x = x * a + c;
return (int)(x>>16);
}

int main()
{
// Create TestU01 PRNG object for our generator
unif01_Gen* gen = unif01_CreateExternGenBits("JVM LCG", jvmlcg);
   
// Run the tests.
//bbattery_SmallCrush(gen);
bbattery_BigCrush(gen);

// Clean up.
unif01_DeleteExternGenBits(gen);

return 0;
}

The Java test did not do very well on the big crush test. I ran the tests in an emulator running Linux so that I didn't need to set up MinGW on my system as the libraries are for Unix. If you see a flaw in my program, feel free to email me. You can run the test for yourself but to save you hours of waiting, here are the final test results:

========= Summary results of BigCrush =========

Version:          TestU01 1.2.3
Generator:        JVM LCG
Number of statistics:  160
Total CPU time:   08:55:08.77
The following tests gave p-values outside [0.001, 0.9990]:
(eps  means a value < 1.0e-300):
(eps1 means a value < 1.0e-15):

Test                          p-value
----------------------------------------------
2  SerialOver, r = 22               eps  
4  CollisionOver, t = 2           1 - eps1
6  CollisionOver, t = 3           1 - eps1
8  CollisionOver, t = 7             eps  
10  CollisionOver, t = 14            eps  
12  CollisionOver, t = 21            eps  
13  BirthdaySpacings, t = 2          eps  
14  BirthdaySpacings, t = 3          eps  
15  BirthdaySpacings, t = 4          eps  
16  BirthdaySpacings, t = 7          eps  
17  BirthdaySpacings, t = 7          eps  
18  BirthdaySpacings, t = 8          eps  
19  BirthdaySpacings, t = 8          eps  
20  BirthdaySpacings, t = 16         eps  
21  BirthdaySpacings, t = 16         eps  
22  ClosePairs mNP, t = 3          1.6e-26
22  ClosePairs mNP1, t = 3         1.3e-48
22  ClosePairs mNP2S, t = 3          eps  
23  ClosePairs mNP, t = 5           3.4e-4
23  ClosePairs mNP1, t = 5          3.4e-4
23  ClosePairs mNP2S, t = 5          eps  
24  ClosePairs mNP2S, t = 9        5.7e-46
25  ClosePairs mNP, t = 16         8.0e-30
25  ClosePairs mNP1, t = 16        3.7e-29
25  ClosePairs mNP2S, t = 16      1.1e-283
27  SimpPoker, r = 27                eps  
29  SimpPoker, r = 25                eps  
32  CouponCollector, r = 20          eps  
33  CouponCollector, r = 27          eps  
35  Gap, r = 25                      eps  
37  Gap, r = 20                      eps  
43  Permutation, t = 10             0.9997 
58  AppearanceSpacings, r = 27       eps  
60  WeightDistrib, r = 20            eps  
61  WeightDistrib, r = 28            eps  
64  WeightDistrib, r = 26            eps  
67  MatrixRank, L=30, r=26         7.9e-10
75  RandomWalk1 H (L=50, r=25)       eps  
75  RandomWalk1 M (L=50, r=25)       eps  
75  RandomWalk1 J (L=50, r=25)       eps  
75  RandomWalk1 R (L=50, r=25)       eps  
75  RandomWalk1 C (L=50, r=25)       eps  
85  Fourier3, r = 27                 eps  
87  LongestHeadRun, r = 27           eps  
87  LongestHeadRun, r = 27         1 - eps1
89  PeriodsInStrings, r = 20       1 - eps1
91  HammingWeight2, r = 27         5.0e-13
96  HammingIndep, L=30, r=27         eps  
98  HammingIndep, L=300, r=26        eps  
100  HammingIndep, L=1200, r=25       eps  
102  Run of bits, r = 27              eps  
106  AutoCor, d=3, r=27              2.6e-7
----------------------------------------------
All other tests were passed

One interesting observation that Melissa made in her study is that the XORShift did poor in the crush tests but it's companion XORShift* did exceptionally well. This is a surprise when you consider that XORShift and XORSHift* use the same shift-and-apply-xor operations. The only difference between XORShift and XORShift* is XORShift* adds a multiplication at the end. Anybody familiar with random number generators will know that Linear Congruential Generators (LCGs) work by multiplying then adding. This means that XORShift* gains it's powers by essentially running it's output through a LCG.

If an improvement step works for XORShift, would such an improvement step work for a LCG?

Wednesday, December 31, 2014

2015 Plans

I suppose I should be doing a postmortem of Snowman's Fez, here but since I never finished the game the way I wanted (yes, it's playable, is a game, and has a beginning and an end but it is not the game I wanted to create) I am going to instead take this time to write about my 2015 plans.

I am in the process of upgrading my degree to a bachelor degree through online/correspondence courses offered by a B.C. University. I am not entirely sure this is the best way of learning, but it is the way that most companies who are likely to hire me look for. While I would like the cheaper online alternatives to be viable, they are simply not there yet. This is unfortunate, but unlike the tech industry, change is really slow in the real world. The big disadvantage of going with University online/correspondence type courses is that you don't have the feel for what exactly the teacher is looking for so as a result you must learn much more of the material than would be necessary in the classroom. The ability to work at your own pace (within the time-limits the University puts on the courses) to me is worth the extra work learning.

There are probably many people who think that the extra flexibility means that there should be ample time to finish a game a month. To some extent this is true but knowing how easy it is to procrastinate, one has to take care not to get side-tracked on personal projects. That said, many of the courses I am taking do have some flexibility with the projects that are created. When possible I plan on doing game-related projects. This way I will get to combine my University hours with my One Game A Month hobby. This assumes, of course, that there are no issues with me doing this which I simply don't know yet.

When there are no course projects to use for 1GAM then picking an interesting game jam will be an option. Perhaps a better option would be to take one of the numerous games I want to do more with and do another pass on that game. Implementing the rather neat combat system I came up with for Snowman's Fez, for instance. If anyone reading this has a preference between those two options (original Jam stuff or enhanced existing stuff) feel free to email me with your opinions.

One project I am thinking of doing again is my NES RPG project. I would do a post in the middle of each month focusing on that project, and at the end of each month I would do a rant or a postmortem of whatever game I released for 1GAM. Email me if you are interested in this but I probably won't start doing this until March or April.

So in summary, I am going to be focused on my University work, but do plan on continuing with 1GAM. When/if possible both will be done together.