I spent this week working on my goals for the midterm. I implemented an algorithm which sorts all the orders by player (this will be used to implement the ordered turn system next week). I used the region system created last week to add code which finds a specific leader in a given region. This allowed me to implement the code which adds points to a player's score.
The way the scoring works is: when a system is colonized, the game searches for the leader of the type of colonist which just colonized the world (i.e. a merchant leader for ship of merchants). If a leader of the correct type is found in the region which the newly colonized system is in, then the owner of that leader gets 1 point of the same type as the colonist (i.e. 1 point in the "money" score for a merchant). If no leader of the correct type is found, but a settler leader is found in the region, then the point goes to the owner of the settler leader.
So far everything is on track for the midterm. Next week I will be working on getting everything finished for the midterm. The biggest things left are getting the ordered simultaneous turn finished and implementing the end game conditions.
This week I did a lot of small behind the scenes stuff which helped to develop the rules for the game, but they didn't make much of an observable difference to the player.
I introduced a layer of inheritance to the fleet orders since they all needed to check for the same conditions before for they performed the order. Namely, they need to check to make sure the system is not colonized, is not occupied by a leader, and is not destroyed. I added a check to make sure that each system only accepts one order per player per turn. I also made sure mining ships can only colonize uninhabitable planets and all other ships can never colonize uninhabitable planets.
The biggest change I made this week was introducing a region detection system. A region in this game is a group of colonized or occupied systems which are connected adjacently to each other. This information is used to determine which player gets the points for colonizing a system, when to initiate combat, and the resolution of combat.
The week went well, and I feel like got a good amount of solid code done. The region detection is going to help a lot in the next couple weeks as it forms the foundation for most of the rules. I also laid out the goals for midterm which will help guide me as the midterm approaches.
For next week: I will focus on finishing the non-combat orders. I will use the region detection system I implemented this week to implement scoring.
As the GSoC midterm approaches, I've decided on a few goals to attain by midterm. In general, I would like to have a playable demonstration of the non-combat parts of the game. So the goal is for the player to be able to see and interact with the board and their fleets and see the expected result except where combat would occur. To accomplish this, I need to complete the following things before midterm:
- finish up the orders
- implement scoring
- implement end-game conditions (although they probably wont be reached without combat)
- make sure orders are processed in the correct order (see: http://nuleren.blogspot.com
/2008/05/thoughts-on-simultane )ous-turns.html
This week I began work on orders and the turn sequence. I developed a very simple turn sequence to simply perform the orders in the order queue. This was mostly to test out the orders. I implemented the first version of three orders:
- The colonize order can be issued by any colonist type ship (merchants, scientists, settlers, mining robots). It consumes the ship/fleet and generates a resource which corresponds to the passengers the ship was carrying.
- The move order can be issued by any colonist leader. It moves the leader to the specified system and puts the leader's fleet in orbit.
- The attack order can be issued by a bomber. This order consumes the bomber's fleet. It adds the destroyed resource to the specified system and sets the destroyed flag in the system.
I also merged my tae branch with the master tpserver-cpp branch which was a little tricky to do in cogito, but I think I managed to do it properly.
Overall the week went quite smoothly. No significant bugs or obstacles.
For next week: The orders I've implemented right now are not restricted at all, so I need to add some restrictions to prevent illegal moves. To do this I'm going to need to begin implementing the code to detect regions of colonized space. I also need to nail down what I want to have complete by the midterm as it is fast approaching.
This week I focused on ships and fleets.
I had a slow start to the week as I was trying to decide how I wanted to implement ships and fleets. Ships are a very important part of this ruleset. They represent the "playing pieces" of the game and will most likely be the only objects to receive any orders. When I was initially planning the game, the ships seemed to be logically divided into different fleets: a fleet of colonists, a fleet of leaders, and a military fleet. So, I originally thought to split them into these three fleets and send orders to specific ships within each fleet. However, when I started to look at the implementation of ships, I realized it may not be possible to send an order to a specific ship within a fleet. I inquired about it in the tp-devel mailing list and found out that this was only possible in TP04. So I spent time planning out how I wanted to handle this and also how each ship type should be organized. I settled on having one ship per fleet to support TP03, and maybe later breaking it out into a separate TP04 implementation.
I started the coding by implementing a property, some components, and a ship. The property, passengers, has 8 possible values and handles the 4 colonist types and 4 leader types. The components, cargo bays, each had a different value of the passengers property. The ship, a transport ship, has a cargo bay outfitted to carry one type of passenger.
To test all this code this I added a couple functions to create fleets, and added code to create a simple test fleet with one passenger ship in it.
I ran into my first big bug here. I tried running the game and I would get a seg fault after joining the game. I spent some time enabling debugging on both the client and server, and adding debug statements to the server. I discovered the problem was that I had removed the "damage" parameter from the fleet object, but hadn't removed all the references to it. I finished removing it, which fixed the seg fault, but then the client yelled at me. So I ended up just adding damage back into the fleet object, which caused the fleet to be created successfully.
This is where I hit my second bug. The sample fleet was created, but it didn't have the ship I made in it. You can read about the problem and my solution in this thread.
While I was working on the missing ship problem, I went ahead and implemented the remaining properties, components, and ships (here and here).
Overall, this week went well. It wasn't as smooth as the past couple weeks. I felt like I didn't get as much done, but I did learn a lot and working through those first couple bugs will definitely help in the future.
For next week:
Start working on orders and maybe a basic turn structure. Some of these orders may require a good bit of extra code to check to make sure they're legal moves. So, I probably won't finish implementing all the orders by the end of next week, but it should be a good start.