Battle Calculator Enhancement


#1

Would be nice if the battle calculator could include ships that will be on the star in a predetermined number of hours based on the current industry level. For example, if someone launched an attach on my star and their carrier will arrive in 5 hours, I need to use a calculator outside the game to determine how many ships the star will produce in 5 hours, then add it to the current total and change that amount in the battle calculator. I wish it was automatic!


#2

I think it would be easier to have a battle calculator where you type in the industry, manufacturing tech, and amount of hours then it will tell you how many ships will be made. Also there should be a way to save the calculations so you can quickly reference it.

When you are working with loops the calculator can get complicated. You might have 60 ships arriving from different carriers that will arrive at the stars and another 12 ships being made. It will be hard to calculate all the different loops along the path dropping off or picking up ships. It is a good idea but it will be hard to implement it in the game. My idea will be a little easier to implement but you will still have to do some calculating on your own.


#3

I’m not sure if your idea would be easier for me. If I want to know whether I can survive an attack on my star so I double click it and hit the battle calculator. The defending weapons tech and ship quantity is automatically filled in based on what is currently at the star. Now I just have to put in the attackers weapon tech and ship count. The problem is, if his ship is arriving in 10 hours, the result will be incorrect. So I have to then double click the star again to see how many ships per tick are going to be produced, and then use an external calculator to determine how many more ships will be at the star when the attacker arrives, then go back into the calculator and change the defending ships amount. It would be easier for me if I could just plug in the hours on the battle calculator and have the defending ships automatically adjusted accordingly based on the industry at that star and manufacturing tech of the current star owner. At that point I can determine how many reinforcements, if any, are required. Your request sounds like something completely different – an industry calculator… not a battle calculator. I’m looking for an enhancement to the battle calc. It could also be useful for the reverse: calculating how many ships are needed to attack an enemy star, but I think more additions would be needed to make that work well.


#4

I think part of the problem is that you want to do one very specific thing with it, but there are many potential workflows. For example, if I’m attacking and don’t want to send an overwhelming number, I may choose to add 1 to the target star’s industry or otherwise fudge the numbers to calculate what I think is a reasonable maximum number of ships that will be there when I arrive.

I had considered suggesting something similar to this, but I think allowing for everything you’d actually want to do with it would make it too complicated UI-wise. You’d need a bunch of input information and then you’d need to make the output clearly describe what the calculation is based on. It would be nice if there was a reasonable solution but I haven’t really been able to think of one that would be game-worthy.

This is something that could be implemented and customized as a user script extension though, if only for playing around with. I think you would need to be able to mess with the ETA, the manufacturing level, and the amount of industry.


#5

Not sure why there’s a problem at all. I think my request is fairly simple and should be a piece of cake to implement. It would be a very useful tool to have for determining a stars defensive capabilities and nothing more.


#6

It’s a simple request but an incomplete solution. Sure, you may only want to use it for defense, but others will want to use it for offense, and either way people will probably want to adjust manufacturing, industry, and perhaps even account for ship-drop off from some other nearby star.

Cramming all of these things in to the calculator screen in the game is probably a bad idea (lack of space, hard to use on mobile, etc.) Conversely, adding only one piece of the whole logical solution is probably also a bad idea because it will make the battle calculator more confusing every time you’re not using it for the single purpose you propose.

Edit: Essentially, I think any feature added to the game should be added in such a way that it is useful to the most people most of the time. I think the calculator is insufficient a lot of the time, but making it sufficient much more of the time would require implementing all of the aforementioned offensive/defensive adjustments which would be very hard to do while keeping the UI as simple as possible.


#7

All that would need to be done is put a field between “Defender Weapon Tech” and “Defender Ships” called “Production Hours at This Star”. The default could and should be zero (0) and finding out what it does for the first time would be as easy as clicking the “?” like everything else in the game.

Do you not agree that my request would be useful for anyone looking for a quick way to see if their own star can defend itself from an attack? IMO something is better than nothing. :stuck_out_tongue:

My OP got some likes so there are people that do like the idea.


#8

Personally, I think it would just be frustrating to have it already account for manufacturing/industry in the background but have no way to modify them, which is really all that’s missing to make it useful for offense as well. The only problem I have with that it might make the screen either too complicated or too big to use on mobile, but functionally it would be an improvement.

There’s also another issue that I just thought of, and I think it’s something that isn’t exposed in the client currently: Since stars can generate decimal numbers of ships per-hour (for example, 1.46 ships per hour or something) each star (as I understand it) maintains it’s own “remainder” number, then when it gets bigger than 1 the star makes an “extra” ship that hour. So each one will save up all the little decimals until it can make a whole ship, at which point it will make the whole ship. You’d have to know that remainder to be able to exactly calculate the number of ships present at the star at a certain time in the future. Then, even if you had that, it would mean the calculator would be specific to one star and one star only, meaning it would be more difficult than simply changing numbers to use it for a different star in one go.

Example: Star generates 1.3 ships per hour and starts with 0 ships

Hour:      1    2    3    4    5
Ships:     1    2    3    5    6
Remainder: 0.3  0.6  0.9  0.2  0.5

So in this case, you get the “extra” ship on hour 4, but this would be impossible to plan for if you didn’t know what the remainder was.

@JayKyburz, could you explain a little more about per-star partial ship production? Am I correct that that’s what happens and that the information isn’t exposed in the client?


#9

So you would cut off your nose to spite your face?

View the info for any star and it tells you exactly how many ships it produces per hour including the fraction based on it’s industry and manufacturing. There is no guesswork here. Just multiply that by the # of ticks until your attacker arrives and your # will be accurate by +/- 1 ship. The calculator could add or subtract that ship automatically to compensate. I don’t see how this poses a huge problem. As for space on the screen, I am using IE on Windows Phone and the current calculator only takes up half the screen. There is easily room to add at least 4 or 5 fields without requiring any scrolling. Even if I had to scroll a little bit I still think it would be worth it.

To compensate your fear of clogging up the interface, there could simply be an “advanced” button which opens up the additional options for the calculator.


#10

yeah, no only whole completed ships are sent to the client.

I have resisted adding too much detail to the combat calculator because there are so many things that can change before the combat takes place. Ship production, new tech levels, fleets you can’t see etc ect.

I think we could do better that what we currently have though!


#11

Sure it’s just one ship, but in a tight spot it could matter. When I’m doing it for defense, I round my production down. When I’m doing it for offense, I round theirs up. I can’t think of a consistent way to get it to work for both, and I think it’d be a shame to make it inherently one or the other.

Maybe simply adding industry/manufacturing that are defaulted the same as weapons but changeable along with an ETA field that you can use if you want would do the trick, however I just can’t think of a way to do it that would avoid me breaking out notepad and an actual calculator (or a spreadsheet) as there are almost always more variables I try to consider. Again, seems like a lot of stuff to add to the calculator screen for a questionable advantage over doing it by hand, but I’d be all for it if there was a nice clean way to get it most of the way there.


#12

Who said anything about making it inherently one or the other? There could easily be a toggle button or if there were separate “ETA” fields for defense and attack sections , that would work too.

It’s one thing less for you to have to do at all, and for those of us who just want a quick way to tell if the star can defend itself from a single pending attack, it does ALL the work.

We get it dude, you don’t want to see ANYTHING ELSE on the battle calculator unless it’s some amazing ultra calculator that does everything you ever wanted. And so my SIMPLE solution to that is to just leave it the way it is and add an “Advanced” button that will toggle the extra option or options that you clearly don’t even want to see.

“Problem” solved!

Indeed maybe Qwerty can come up with some script to do this, and I would be fine with that as well. It would just make my life a lot easier.


#13

Well, here then, go to town. If you can live with the +/- 1 and certain other limitations (resets the ETA and updates the defender ships after you calc, so that hitting the calc button multiple times doesn’t keep adding ships and time) then it might work for you:

//------------------------------------------------------------------------------
// The MIT License (MIT)
//
// Copyright (c) 2014 Dakota Hawkins
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//------------------------------------------------------------------------------
var universe = NeptunesPride.universe;
var npui = NeptunesPride.npui;

npui.CombatCalc = function () {
    var prop, star, i;
    var combatCalc = npui.Screen("combat_calculator")
        .size(480, 576);

    Crux.Widget("rel")
        .size(480, 576 - 48)
        .roost(combatCalc);

    var s = 10;
    var ws = 1;
    var ds = 1;
    var l = 1;
    var eta = 0;
    var ships_per_tick = 0;

    if (universe.selectedSpaceObject) {
        s = universe.selectedSpaceObject.st;
        if (universe.selectedSpaceObject.kind === "star") {
            s = universe.selectedSpaceObject.totalDefenses;
            ships_per_tick = universe.selectedSpaceObject.shipsPerTick;
        }
        if (universe.selectedSpaceObject.player) {
            ws = universe.selectedSpaceObject.player.tech.weapons.value;
        }
    }

    Crux.Text("defender_weapon_tech", "pad12 col_accent")
        .grid(0, 3, 30, 3)
        .roost(combatCalc);

    Crux.Text("defender_ships", "pad12 col_accent")
        .grid(0, 6, 30, 3)
        .roost(combatCalc);

    Crux.Text("", "pad12 col_accent")
        .grid(0, 9, 30, 3)
        .rawHTML("Defender Ships Per Tick")
        .roost(combatCalc);

    Crux.Text("defender_ships_bonus", "pad12 col_accent")
        .grid(0, 12, 30, 3)
        .roost(combatCalc);


    Crux.Widget("col_black")
        .grid(0, 15, 30, 0.5)
        .roost(combatCalc);

    Crux.Text("attacker_weapon_tech", "pad12 col_accent")
        .grid(0, 16.5, 30, 3)
        .roost(combatCalc);
    Crux.Text("attacker_ships", "pad12 col_accent")
        .grid(0, 19.5, 30, 3)
        .roost(combatCalc);
    Crux.Text("eta", "pad12 col_accent")
        .grid(0, 22.5, 30, 3)
        .roost(combatCalc);

    Crux.Widget("col_black")
        .grid(0, 25.5, 30, 0.5)
        .roost(combatCalc);

    combatCalc.dwt = Crux.TextInput(true, true)
        .setText(ws)
        .grid(20, 3, 10, 3)
        .roost(combatCalc);
    combatCalc.ds = Crux.TextInput(true, true)
        .setText(s)
        .grid(20, 6, 10, 3)
        .roost(combatCalc);
    combatCalc.dspt = Crux.TextInput(true, true)
        .setText(ships_per_tick)
        .grid(20, 9, 10, 3)
        .roost(combatCalc);

    Crux.Text("", "pad4 col_base rad4 txt_center")
        .grid(20, 12, 10, 3)
        .inset(8)
        .rawHTML("+1 Weapons")
        .roost(combatCalc);

    combatCalc.awt = Crux.TextInput(true, true)
        .setText(ws)
        .grid(20, 16.5, 10, 3)
        .roost(combatCalc);
    combatCalc.as = Crux.TextInput(true, true)
        .setText(s)
        .grid(20, 19.5, 10, 3)
        .roost(combatCalc);
    combatCalc.aeta = Crux.TextInput(true, true)
        .setText(eta)
        .grid(20, 22.5, 10, 3)
        .roost(combatCalc);

    Crux.Button("fight", "pre_calculate_combat")
        .grid(20, 27, 10, 3)
        .roost(combatCalc);

    combatCalc.result = Crux.Text("", "pad12 col_accent txt_center")
        .grid(0, 31, 30, 3)
        .rawHTML("")
        .roost(combatCalc);

    combatCalc.onPreCalcCombat = function () {
        var dwt = combatCalc.dwt.getText();
        var ds = Math.round(combatCalc.ds.getText()  + (combatCalc.aeta.getText() * combatCalc.dspt.getText()));
        var awt = combatCalc.awt.getText();
        var as = combatCalc.as.getText();

        combatCalc.ds.setText(ds);
        combatCalc.aeta.setText(0);

        if (ds === 0 || as === 0) {
            combatCalc.result.update("combat_calc_no_combat");
            return;
        }

        dwt += 1; // defender bonus
        var winner = "";
        while (!winner) {
            as -= dwt;
            if (as <= 0){
                winner = "defender";
                break;
            }
            ds -= awt;
            if (ds <= 0) {
                winner = "attacker";
                break;
            }
        }

        var td = {};
        td.as = as;
        td.ds = ds;
        if (winner == "attacker") {
            combatCalc.result.updateFormat("combat_calc_win_attack", td);
        } else {
            combatCalc.result.updateFormat("combat_calc_win_defend", td);
        }

    };
    combatCalc.on("pre_calculate_combat", combatCalc.onPreCalcCombat);

    return combatCalc;
};

NeptunesPride.np.trigger("map_refresh");

I don’t know why there’s a double scroll bar.

Bookmarklet (remove leading +):

+javascript:(function(){var e=NeptunesPride.universe;var t=NeptunesPride.npui;t.CombatCalc=function(){var n,r,i;var s=t.Screen("combat_calculator").size(480,576);Crux.Widget("rel").size(480,576-48).roost(s);var o=10;var u=1;var a=1;var f=1;var l=0;var c=0;if(e.selectedSpaceObject){o=e.selectedSpaceObject.st;if(e.selectedSpaceObject.kind==="star"){o=e.selectedSpaceObject.totalDefenses;c=e.selectedSpaceObject.shipsPerTick}if(e.selectedSpaceObject.player){u=e.selectedSpaceObject.player.tech.weapons.value}}Crux.Text("defender_weapon_tech","pad12 col_accent").grid(0,3,30,3).roost(s);Crux.Text("defender_ships","pad12 col_accent").grid(0,6,30,3).roost(s);Crux.Text("","pad12 col_accent").grid(0,9,30,3).rawHTML("Defender Ships Per Tick").roost(s);Crux.Text("defender_ships_bonus","pad12 col_accent").grid(0,12,30,3).roost(s);Crux.Widget("col_black").grid(0,15,30,.5).roost(s);Crux.Text("attacker_weapon_tech","pad12 col_accent").grid(0,16.5,30,3).roost(s);Crux.Text("attacker_ships","pad12 col_accent").grid(0,19.5,30,3).roost(s);Crux.Text("eta","pad12 col_accent").grid(0,22.5,30,3).roost(s);Crux.Widget("col_black").grid(0,25.5,30,.5).roost(s);s.dwt=Crux.TextInput(true,true).setText(u).grid(20,3,10,3).roost(s);s.ds=Crux.TextInput(true,true).setText(o).grid(20,6,10,3).roost(s);s.dspt=Crux.TextInput(true,true).setText(c).grid(20,9,10,3).roost(s);Crux.Text("","pad4 col_base rad4 txt_center").grid(20,12,10,3).inset(8).rawHTML("+1 Weapons").roost(s);s.awt=Crux.TextInput(true,true).setText(u).grid(20,16.5,10,3).roost(s);s.as=Crux.TextInput(true,true).setText(o).grid(20,19.5,10,3).roost(s);s.aeta=Crux.TextInput(true,true).setText(l).grid(20,22.5,10,3).roost(s);Crux.Button("fight","pre_calculate_combat").grid(20,27,10,3).roost(s);s.result=Crux.Text("","pad12 col_accent txt_center").grid(0,31,30,3).rawHTML("").roost(s);s.onPreCalcCombat=function(){var e=s.dwt.getText();var t=Math.round(s.ds.getText()+s.aeta.getText()*s.dspt.getText());var n=s.awt.getText();var r=s.as.getText();s.ds.setText(t);s.aeta.setText(0);if(t===0||r===0){s.result.update("combat_calc_no_combat");return}e+=1;var i="";while(!i){r-=e;if(r<=0){i="defender";break}t-=n;if(t<=0){i="attacker";break}}var o={};o.as=r;o.ds=t;if(i=="attacker"){s.result.updateFormat("combat_calc_win_attack",o)}else{s.result.updateFormat("combat_calc_win_defend",o)}};s.on("pre_calculate_combat",s.onPreCalcCombat);return s};NeptunesPride.np.trigger("map_refresh")})();

#15

Why not have a battle calculator where you select 1 or more stars. You type in the manufacturing level and the amount of hours for production. By selecting the stars individually, the game will keep track of the extra decimal for building a ship within the game.

This isn’t exactly what Floydian has in mind but it is still the best solution for improving the battle calculator. He has a nice simple idea but there are too many variables that someone has to take into consideration. I don’t think working around all the loops will be very easy because of all the possibilities. Also a player might be planning to take 50 ships that are gathered for an attack on another star. The carriers for this attack might not be built yet because production needs to hit. If a player wants to know how many ships will be at a star at a given time, they also need to take into consideration the ships that will be used for attacking or adding to the defense of another star. If your whole empire is based on loops, the system would be calculating all the loops leading up to that star, taking into account individual decimal values for each star. You can see how this can get very complicated to implement. It is possible to code all of this but you also have to think about your own strategy that the system won’t be able to predict and it will be a lot of work to implement. My option will work until something better is made.


#16

THANK YOU! This is EXACTLY what I wanted!


#17

I wholeheartedly disagree. I am not looking for a battle calculator that will automatically calculate how many ships are in route to a star. I just want to know what’s needed at a single star in order to fend off a single attack. It’s THAT SIMPLE.


#18

I haven’t loaded this script. Is it something I should be rolling into the main game?


#19

Yes please! :wink:


#20

Not as it is. It’s kind of awkward the way it zeroes out the ETA and updates the defender ships field when it calculates. It would be better if there were a separate “new ships” field that updated automatically when you edit the other fields, rather than when you click “Attack.” I didn’t see how to make that happen though.

I think it could be better about rounding up or down the new ships produced based on the following:

  • Round up if you’re attacking (if the star you launched the calc from belongs to someone else, or if the carrier you launched the calc from is headed to a star that belongs to someone else.)
  • Round down if you’re defending (similar to above, but if you own the star.)

It might also be nice to auto-fill in the ETA if you launched the calc from a carrier.


#21

At first I thought the zeroing out the ETA was going to be a problem, but since it doesn’t reset the defending ships back to the original amount, it doesn’t affect my calculations. It’s actually working perfectly. I don’t mind rounding up by 1 ship. You’re always better to be safe than sorry. You always take the chance that someone is going to research manufacturing or weapons and so the battle calculator is just an estimator.