Showing posts with label education. Show all posts
Showing posts with label education. Show all posts
Wednesday, February 27, 2013
Blitz Open Day
I just got back in to Dundee today after traveling down to Leamington Spa in England for Blitz Open Day. It was an absolute blast! I highly recommend the experience to anyone currently at University and planning to go into the games industry.
The day was packed full of awesome stuff, all basically designed to educate students about the industry and Blitz in particular. Going into the weekend, I must admit that while I would have been happy to work at Blitz simply because they are a game company, I wasn't particularly enthusiastic about them as a studio. That has definitely changed! The culture and opportunities that Blitz represents are intriguing to me. First, they have many teams working on different games, so there's a lot of variety going on at any given time. Second, they create their own engine, giving an opportunity to try tool programming. They even have an R&D department for cutting edge research. Finally, the company allows it's employees to work on their own games on their own time - many other companies make you sign away your right to any IP you create while employed there, but not Blitz! One of the programmers I spoke to had just released her own game. Blitz even has an indie store where they will publish your games. In addition to all this, Blitz seems very focused on education, both for their employees and to better the industry in general.
After learning how awesome Blitz is as a company, I got to speak in small groups with several Blitz employees about the industry and breaking in. It was a great opportunity to discuss what needs to go into a portfolio, CV, and interview, as well as what to expect when actually working in the industry. After the open day, we went out for drinks with Philip Oliver (one of the founders of Blitz) and several employees. The other open day students eventually went home, but since I was staying in a hotel in town, I didn't have to. The developers invited me to second bar, where more Blitz folks and some indie devs were hanging out. It was a great night full of meeting new and interesting people and chatting with folks already in the industry. I had a blast!
I can't stress enough how awesome this event was, and I'd definitely recommend anyone currently in university for game development in the UK to try to go next year. You'll need to apply before January to get a place, so keep an eye on Blitz's website for when applications open up.
Sunday, January 20, 2013
Creating a DirectX Scene: Post-Project Reflection
Well, all the hectic craziness is over and the coursework is turned in. I'll be using the next few posts to reflect on where I am now and how far I've come. Today, I'll take a look at my completed DirectX scene and discuss what could have been better and what still needs work.
Overall, I feel like the scene was a pretty big success. I got the basics of what I wanted very solidly, and even added some advanced features. My planets moved and rotated in a realistic fashion, with textures set up properly. I even had moons rotating Earth and Mars, though didn't have time to set up more. 2D rendering allowed a nice HUD overlay with mouse pointer crosshairs. Camera movement was via keyboard, and while I would have liked to add movement via mouse, the keyboard movement worked pretty well.
For advanced features outside of what was taught in class, I added in-scene point lighting for the sun. I also changed how the sun itself was rendered in order to make it bright, setting it's ambient lighting to 1. A skybox with a starfield texture was used as the backdrop for the scene, rendered similarly to the sun with an ambient lighting setting of 1. Direct Sound was used to add music and a sound effect when the camera is moved, simulating a spaceship sound.
The most interesting advanced feature I attempted was a particle effect comet trail. While I am pleased with the result, there are many improvements which could have been made. The particle system functions by dropping a particle close within the vicinity of the comet. Each particle is given a velocity in each direction, but this velocity is smaller in magnitude than the comet's velocity. The effect this produces is the expected shape of the comet tail. In the tutorial I used, the particle system relied on the camera never moving. This meant that if the camera moved, strange artifacts would be seen in the system due to the alpha blending method - the particles had to be ordered based on depth in order to avoid this. This meant I had to implement a sorting function for these particles, something I hadn't really done before. It was one of my proudest moments so far in programming when I successfully implemented an insertion sort algorithm from scratch and saw it working here.
Unfortunately, despite this success, the particle system in the final product is still not perfect. The sorting is not set up when a particle is killed, and this causes a brief flicker of artifacts across the system. Additionally, I didn't realize that in addition to not sorting particles properly, the example also set up the particles as billboards only facing (and only rendered) in one direction. This means that from the sides the system seems distorted, and from the back it does not appear at all due to culling. Finally, the particles blinking instantly out of existence looks a bit odd. Instead, they should have an decreased alpha over time, fading out gently. All of these issues would be easy enough to fix, given time, and I may do just that simply to improve this project as an entry in my portfolio.
![]() |
| A screen capture of the scene. You can see the sun, Haley's Comet, Jupiter, Earth, and Mars in this image. |
Features
For advanced features outside of what was taught in class, I added in-scene point lighting for the sun. I also changed how the sun itself was rendered in order to make it bright, setting it's ambient lighting to 1. A skybox with a starfield texture was used as the backdrop for the scene, rendered similarly to the sun with an ambient lighting setting of 1. Direct Sound was used to add music and a sound effect when the camera is moved, simulating a spaceship sound.
Particle System
Unfortunately, despite this success, the particle system in the final product is still not perfect. The sorting is not set up when a particle is killed, and this causes a brief flicker of artifacts across the system. Additionally, I didn't realize that in addition to not sorting particles properly, the example also set up the particles as billboards only facing (and only rendered) in one direction. This means that from the sides the system seems distorted, and from the back it does not appear at all due to culling. Finally, the particles blinking instantly out of existence looks a bit odd. Instead, they should have an decreased alpha over time, fading out gently. All of these issues would be easy enough to fix, given time, and I may do just that simply to improve this project as an entry in my portfolio.
Program Structure
I am rather disappointed with my program structure for this project. Code organization is something I am intrigued by and generally pride myself on. Unfortunately, I was hindered in this project because I was learning as I went, and using primarily code from rastertek.com's excellent tutorial series. This code, while quite effective and great for single feature tutorials, is less than ideal for a larger project using many features at once. It takes zero advantage of C++'s inheritance features, and I found encapsulation difficult as well. In my coursework report for this project, I took the time to fully plan out a better program organization, and I may implement this organization in the future.
Moving Forward
This project isn't dead. I hope to continue improving it in the future in order to use it as a prime example of my work in my career portfolio. There are many interesting features I'd like to add, including:
- Program restructure
- Particle system fixes
- All other moons and dwarf planets
- Better representation of the sun's light, i.e. bloom, lens flare, glow
- Re-sizing, re-positioning of planets for better realistic representation
- Asteroid Field
- Planetary rings
- Mouse-assisted camera control
- Pause button
- Readout of current coordinates relative to the center of the sun
- Representation of planetary orbit (line)
- Select-able planets with readout giving information (possibly including voice-over)
- Clicking shoots a probe (possibly giving more readings)
The idea is an interactive, exploratory simulation of the solar system. Something like this could be used for education purposes. Ultimately, though, the goal is simply to create something nice for my portfolio. And I think, even in it's current state, that goal was accomplished!
If you would like to try out the scene, it is available online on my portfolio github. Enjoy!
If you would like to try out the scene, it is available online on my portfolio github. Enjoy!
Labels:
Abertay,
directX,
education,
graphics,
post-project reflection,
solar sojourn
Friday, December 21, 2012
Creating an AI Controller - Bezier Curves and More
I've talked a bit here about my coursework for my DirectX module. I also have a project for my AI class, which I've been working on over the past few days.
The Assignment
The assignment is simple: Create a fuzzy logic controller for a racing game that will control the NPC cars. The suggested implementation is extremely simplistic - the road is represented by a line, the car by some simple symbol or sprite, and the line moving left or right represents curves.
Inputs and Outputs
The inputs to the controller are twofold. First, the position of the line relative to the car, negative being on the left, positive on the right, in pixels. Second, the relative velocity of the line with respect to the car, in pixels per second.
The output will be the suggested acceleration for the car in order to bring it closer to the line, in pixels per second per second.
Membership Functions
I've decided to use five membership functions for each input (far right, right, center, left, and far left). For output, I've decided on nine membership functions (extreme right, large right, right, slight right, center, and so on).
For the shapes and locations of these functions, I've created an HTML5 interface which allows several points for the shapes to be adjusted via sliders and text boxes. Internally, all shapes are represented as trapezoids with four points: the left base point, left peak point, right peak point, and right base point. Additionally, each trapezoid has two "curviness" settings, left and right. The idea is that with these six settings, we can create any and all of the common membership function shapes (triangle, trapezoid, curve) and any combination of them, and they are all represented identically within the code. This will allow me to tweak the membership functions easily to tune the controller.
![]() |
| A screenshot of the control panel for modifying the membership functions |
This took a bit of doing, but I'm happy to say I've completed it and the interface is really nice. The most difficult part was the representation of the "curviness" for the sides of the trapezoid. I wanted to keep this simple from a user standpoint, but I wasn't sure what equation to use for the curves and how to constrain the system. After some discussion with an old colleague from my chemical engineering days, Robert Coolman, I determined that a cubic spline function would be appropriate. The native capabilities of the HTML5 canvas led me to investigate the bezier curve. It turned out this was just what I needed - the bezier curve is a spline using one or two control points. Using the demo located on sitepoint.com's excelent tutorial, I was able to visualize exactly what I would use to represent the "curviness". The two control points are located on the same y coordinate as the endpoints. The x coordinate for the control points can range anywhere in between the two x coordinates, but to keep symmetry must be an equal distance from their respective end point. This distance, then, represented the "curviness". I specify some value from 0 to 10, which is then scaled to the space between the two x coordinates.
The next problem, once this was determined, was actually applying the Bezier curve's equation to find a corresponding y coordinate. This is done internally by the HTML5 canvas to draw the curve, but to use the controller I would need to be able to find it on my own. Unfortunately this would require finding the solution to a cubic equation. After some perusal of various articles including Wikipedia's Bezier Curve and Cubic Equation articles, I was able to write a function to find the real cubic root of an equation given the coefficients, and was able to determine those coefficients from the Bezier curve equation and a bit of algebra.
Rules
Given these inputs and outputs, I created a fuzzy associative map in order to ensure each situation was covered under a rule. I also plan to represent the ruleset internally in a similar fashion, to make it possible to procedurally step through the rules, and to even make it possible to tune the rules as needed.
![]() |
| Fuzzy Associative map covering all possible set combinations |
Defuzzification
For defuzzification, I plan to keep things simple and use the Center of Maximums method. This should provide fairly accurate results as long as membership functions are mostly symmetrical - for non-symmetrical membership functions, error will be introduced due to the method not accounting for portions of the function below the maximum plateau being uneven. If I have sufficient time I may look into the center of gravity method, but for now it is beyond the scope of my plans.
The Game
The game itself will be coded using the HTML5 Canvas and JavaScript. A line will represent the centre of the road, and a sprite will represent the car. The camera will be centred on the car, but both the car and line can move freely about the game world.
There will be both a defined track (movement of the line defined using pattern movement techniques) and a user controlled track (movement of the line controlled by the user as described in the assignment sheet).
Second AI Controller: Genetic Algorithms
The assignment also requires a second AI method to be used in addition to Fuzzy Logic. I am interested in genetic algorithms, so I plan to use a genetic algorithm to tune the fuzzy logic controller. I will then compare this result to my manually tuned controller.
Wish List
In addition to the basic features outlined above, I have several advanced features I'd like to add:
- After a track is run, the program should automatically display a summary of the performance of the AI for that course, and several useful graphs and statistics including standard deviation.
- The ability to save membership function settings to file both before and after a track is run would be useful.
- Similarly, the ability to load these membership functions from file would also be useful.
- For the genetic algorithm tuning, it would be great to watch the membership function values change in real time.
- A real-time animation of fuzzy logic operations while AI is running the track could provide insight into AI actions and assist in debugging.
Completion of some of these features could take the project beyond a simple exercise and make it a useful teaching tool for demonstrating fuzzy logic in the future.
Subscribe to:
Posts (Atom)



