Author Topic: Pulsar 4X  (Read 33495 times)

0 Members and 1 Guest are viewing this topic.

Offline se5a

  • Lt. Commander
  • ********
  • Posts: 288
  • Thanked: 30 times
Re: Pulsar 4X
« Reply #135 on: June 07, 2014, 06:10:05 AM »
actually you could probably do away with the new class and just have the dictionary be <string,GameEntity> then check the values Type, instead of looking at the enum:

Dictionary SystemLocationDict<string, GameEntity>;

GameEntity entity = SystemLocationDict[m_oTaskGroupPanel.SystemLocationsListBox.SelectedItem.ToString()];

if (entity is Planet)
{
   NewOrder = new Orders((Constants.ShipTN.OrderType)ActionIndex, -1, -1, 0, (Planet)entity);
   CurrentTaskGroup.IssueOrder(NewOrder);
}
 

Offline Nathan_

  • Pulsar 4x Dev
  • Commodore
  • *
  • N
  • Posts: 701
Re: Pulsar 4X
« Reply #136 on: June 07, 2014, 02:24:58 PM »
probably should keep the class, I don't think theres a type in gameEntity, though there is one in StarSystemEntity, I would also be a little more paranoid about checking certain things like the planet assignment to be sure that the planet and the TG are in the same star system, the contact to see if it is actually in the contact list,etc , but that does look good.

Quote
more efficient. (looking up values in dictionaries instead of looping)
You're doing string compares though, still efficiency isn't that important for the front end.

Quote
easier to read. (imo anyway)
As a personal preference I'd rather have a switch than the else ifs, but thats very minor.

lastly, I pushed a bugfix to this file before you grabbed it, so that might be a problem with merging your version and mine, here is the section in question:
Code: [Select]
SystemLocationListType Type = SystemLocationListType.Count;
                            if (loop == 0)
                            {
                                newIndex = PlaceIndex;
                                Type = SystemLocationListType.Planets;
#warning special case zero here, if another SystemLocationListType is made to be loop = 0, then Planets here will have to change.
                            }
                            else
                            {
                                newIndex = PlaceIndex - SystemLocationListIndices[loop-1];
                                Type = SystemLocationListTypes[loop - 1];
                            }


                            /// <summary>
                            /// Which type is this?
                            /// </summary>
                            switch (Type)
« Last Edit: June 07, 2014, 02:42:50 PM by Nathan_ »
 

Offline se5a

  • Lt. Commander
  • ********
  • Posts: 288
  • Thanked: 30 times
Re: Pulsar 4X
« Reply #137 on: June 07, 2014, 02:59:35 PM »
I don't think theres a type in gameEntity,

I don't quite follow... the above example checking if (entity is Planet) does work (Planet, and everything else I think does inherit from GameEntity)


Yeah I can add some more checks, though you can go overboard and start hampering planning for something that may not be the case now, but will be when the TG is going to carry out the order later. might be better to just check for these problems when the TG is attempting to carry out the order (and handle it better than Aurora) since it's going to hit cases where this TG is going to want to interact with another TG or contact that is not in the same system, has been destroyed, or lost sight anyway.

the problem with looping is that you can get into an O(n^2) case without realizing it. a dictionary however uses a hashtable so it's close to O(1). but yeah, in this case the actual time would have been negligible.  
« Last Edit: June 07, 2014, 03:28:31 PM by se5a »
 

Offline Nathan_

  • Pulsar 4x Dev
  • Commodore
  • *
  • N
  • Posts: 701
Re: Pulsar 4X
« Reply #138 on: June 07, 2014, 05:28:48 PM »
I don't quite follow... the above example checking if (entity is Planet) does work (Planet, and everything else I think does inherit from GameEntity)
I was thinking of the SSEntityType when you mentioned type. there are a couple of things strewn throughout the code that don't inherit from GameEntity, but I think they are a non-factor.

Quote
Yeah I can add some more checks, though you can go overboard and start hampering planning for something that may not be the case now, but will be when the TG is going to carry out the order later. might be better to just check for these problems when the TG is attempting to carry out the order (and handle it better than Aurora) since it's going to hit cases where this TG is going to want to interact with another TG or contact that is not in the same system, has been destroyed, or lost sight anyway.
Orders involving TGs that have been destroyed are already handled in simEntity, anyway this is more for error checking the UI since it is already set up so that only data from the same star system can get in. so something wierd would have to happen to get a TG in a different star system. I hadn't considered the contact/TG jumps/docks condition just yet, that I'll have to come back to when those are implemented, and since that could happen in the middle of an order it would have to be checked every tick. Also I may have to rework how contact orders are handled since they are passed along as TG orders right now.

Orders to taskgroups that have been destroyed are just dropped now with a note to the faction message log that such and such a ship order is gone, what do you think should be done there?
« Last Edit: June 07, 2014, 05:51:39 PM by Nathan_ »
 

Offline se5a

  • Lt. Commander
  • ********
  • Posts: 288
  • Thanked: 30 times
Re: Pulsar 4X
« Reply #139 on: June 07, 2014, 05:59:33 PM »
if it's an enemy/neutral contact thats seen to be destroyed I'd probably drop it and move to the next order. (with an option somewhere to pause on such things)
if it's an enemy/neutral contact that's disappeared yeah replacing it with a waypoint would be a good idea.

if it's TG of own empire, then I'd have it follow in the case of it going into another system(if possible) and pause if not possible.
destroyed I'd probably drop and move to next order but default the pause option on for this one.

I wonder if a pause if dropped option on the order itself might be useful...
 

Offline Nathan_

  • Pulsar 4x Dev
  • Commodore
  • *
  • N
  • Posts: 701
Re: Pulsar 4X
« Reply #140 on: June 07, 2014, 10:12:01 PM »
You should be able to see the dev forum now, not much is there though.
 

Offline se5a

  • Lt. Commander
  • ********
  • Posts: 288
  • Thanked: 30 times
Re: Pulsar 4X
« Reply #141 on: June 08, 2014, 06:31:43 AM »
Oh cool! thanks. I'll have a read through there. I started tidying up the above code today, but then got distracted. and kept changing my mind on how best to do it.
 

Offline Nathan_

  • Pulsar 4x Dev
  • Commodore
  • *
  • N
  • Posts: 701
Re: Pulsar 4X
« Reply #142 on: June 08, 2014, 11:22:26 AM »
you should also be added to pulsar4xdevs on github now. Also for the orders options, I'm thinking that should be some sort of configuration thing.
« Last Edit: June 08, 2014, 11:36:10 AM by Nathan_ »
 

Offline Valectar

  • Able Ordinary Rate
  • V
  • Posts: 3
Re: Pulsar 4X
« Reply #143 on: June 10, 2014, 10:18:11 AM »
Is there a place I can see the outline for Pulsar 4X's goals / plans? What features are planned, similarities / differences from Aurora, etc.  I would check the wiki, but it seems to be down.
 

Offline Nathan_

  • Pulsar 4x Dev
  • Commodore
  • *
  • N
  • Posts: 701
Re: Pulsar 4X
« Reply #144 on: June 10, 2014, 11:54:35 AM »
Is there a place I can see the outline for Pulsar 4X's goals / plans? What features are planned, similarities / differences from Aurora, etc.  I would check the wiki, but it seems to be down.

There is not, but the goal for the TN rules set is to duplicate AuroraTN as faithfully as possible. the NA rules set is still on the drawing board, but it takes many concepts from Newtonian Aurora.
 

Offline Valectar

  • Able Ordinary Rate
  • V
  • Posts: 3
Re: Pulsar 4X
« Reply #145 on: June 10, 2014, 02:27:56 PM »
Alright, have you laid out the general structure of the code somewhere? And if there were one feature I would think you'd want to differ from Aurora it would be the UI, so do you have any plans for how that would be structured? There are a lot of small things about Aurora's UI that could be fixed, but I also think a general restructuring could help make important information more visible to players and make fiddling with your empire less of a hassle.

If you have room, I might consider contributing to Pulsar, as I could use something to work on over the summer and on the side during the school year.  I don't know C#, but I do know C++ and C so it shouldn't be too hard to pick up.
 

Offline Nathan_

  • Pulsar 4x Dev
  • Commodore
  • *
  • N
  • Posts: 701
Re: Pulsar 4X
« Reply #146 on: June 10, 2014, 02:34:57 PM »
Alright, have you laid out the general structure of the code somewhere? And if there were one feature I would think you'd want to differ from Aurora it would be the UI, so do you have any plans for how that would be structured? There are a lot of small things about Aurora's UI that could be fixed, but I also think a general restructuring could help make important information more visible to players and make fiddling with your empire less of a hassle.

If you have room, I might consider contributing to Pulsar, as I could use something to work on over the summer and on the side during the school year.  I don't know C#, but I do know C++ and C so it shouldn't be too hard to pick up.

There are notable parts of how the code is laid out in the dev forum, and on the skype chat history we're using, mainly you'd have to ask questions if there is an area you are interested in and the comments aren't revealing. UI improvements are eventually going to be done, but for right now I'm just getting the combat engine to a baseline level of functionality. We will not completely redo the UI though, it does work for the most part.
 

Offline intercross21

  • Leading Rate
  • *
  • i
  • Posts: 10
Re: Pulsar 4X
« Reply #147 on: June 16, 2014, 08:20:53 AM »
Hello,
I watch for this project at least 4 months and I'm very happy because it's hard find good looking code for learning.    But I have a little question: it's normal that I have only rectangles where must be text? In GLFont.   cs I clearly see what text must be drawn right but I have only that:
hxxp: i.  imgur.  com/IDDuM0w.  png
Sorry but I can't attach this as image because of url modification.
« Last Edit: June 16, 2014, 08:22:32 AM by intercross21 »
 

Offline Bgreman

  • Lt. Commander
  • ********
  • Posts: 213
  • Thanked: 2 times
Re: Pulsar 4X
« Reply #148 on: June 16, 2014, 08:40:59 AM »
Not sure if it's an anti-pattern or not, but most WinForms UI elements have a Tag property of Type "object," so you can throw the actual GameEntity associated with the object behind a ListBoxItem into its Tag and then just do some type checking when you're trying to do something with that ListBoxItem.
 

Offline Nathan_

  • Pulsar 4x Dev
  • Commodore
  • *
  • N
  • Posts: 701
Re: Pulsar 4X
« Reply #149 on: June 16, 2014, 12:55:41 PM »
Hello,
I watch for this project at least 4 months and I'm very happy because it's hard find good looking code for learning.    But I have a little question: it's normal that I have only rectangles where must be text? In GLFont.   cs I clearly see what text must be drawn right but I have only that:
hxxp: i.  imgur.  com/IDDuM0w.  png
Sorry but I can't attach this as image because of url modification.

No, text should be displayed. one interesting thing to note is that the taskgroup names aren't displayed at all in your image, those use a different font. I'm not sure what could cause this however. I assume you're running on linux, our cross platform support is somewhat lacking at the moment. I've attached an image of what mine looks like further down, and I'll post the link to your image here:http://i.imgur.com/IDDuM0w.png

Quote
Not sure if it's an anti-pattern or not, but most WinForms UI elements have a Tag property of Type "object," so you can throw the actual GameEntity associated with the object behind a ListBoxItem into its Tag and then just do some type checking when you're trying to do something with that ListBoxItem.
I'll look into that, tag does seem to be there, but it appears to be for the entire listbox as a whole, rather than an entry by entry case. In any event se5a's solution seems like the best and most accessible one at the moment, so if and when I revisit orders, if it hasn't already been done I'll put that in there.