design – How should I handle complex class construction?

I’m making a naval warfare strategy game, based on a boardgame, in C# and having difficulty finding a good way to construct my complex ship objects (I am a beginner in the language and OOP).

Currently, each ship class inherits from an abstract base `Ship` class that implements the interface `IShip` (code below). This interface defines the properties and behaviours common to all ships. I have attempted to reduce complexity by grouping related properties into their own objects (e.g., one models the crew, another models the rigging, etc.). As these properties are required for a given ship to function properly, I would like to initialise them in the ship constructor. I have reduced the number of constructor parameters to just a single `ShipProperties` object, which gets passed into a simple ship factory method to simplify ship construction and reduce code repetition. Ultimately, this property object will be set, using object initialisers for clarity, by reading game scenarios from a JSON file.

I feel there must be a better solution to this issue, however, so would appreciate feedback on my design.

Ship interface:

``````public interface IShip
{
Identifiers Identifiers { get; }
Stats Stats { get; }
Crew Crew { get; }
Rigging Rigging { get; }
Armaments Armaments { get; }
MovementAbilities MovementAbilities { get; }

void MoveTo(Coordinates coordinates);
void GrappleWith(IShip ship);
void UngrappleFrom(IShip ship);
void Board(IShip ship);
void Unfoul();
}
``````

Abstract base ship class, with default implementations of ship interface:

``````public abstract class Ship : IShip
{
public Identifiers Identifiers { get; }
public Stats Stats { get; }
public Crew Crew { get; }
public Rigging Rigging { get; }
public Armaments Armaments { get; }
public MovementAbilities MovementAbilities { get; }

public Ship(ShipProperties shipProperties)
{
Identifiers = shipProperties.Identifiers;
Stats = shipProperties.Stats;
Crew = shipProperties.Crew;
Rigging = shipProperties.Rigging;
Armaments = shipProperties.Armaments;
MovementAbilities = shipProperties.MovementAbilities;
}

public void MoveTo(Coordinates coordinates) { }
public void GrappleWith(IShip ship) { }
public void UngrappleFrom(IShip ship) { }
public void Board(IShip ship) { }
public void Unfoul() { }
}
``````

Ship properties record:

``````public record ShipProperties
{
public Identifiers Identifiers { get; init; }
public Stats Stats { get; init; }
public Crew Crew { get; init; }
public Rigging Rigging { get; init; }
public Armaments Armaments { get; init; }
public MovementAbilities MovementAbilities { get; init; }
}
``````

Ship property objects:

``````public class Identifiers
{
public string Name { get; }
public ShipClass Class { get; } // is an enum
public Nationality Nationality { get; } // is an enum
public int ID { get; }

public Identifiers(string name, ShipClass @class, Nationality nationality) // not every ship has an ID in every scenario
{
Name = name;
Class = @class;
Nationality = nationality;
}

public Identifiers(string name, ShipClass @class, Nationality nationality, int id)
: this(name, @class, nationality)
{
ID = id;
}
}

public class Stats
{
public int PointValue { get; }
public int HullHP { get; private set; }
public int HullDepth { get; }

public Stats(int pointValue, int hullHP, int hullDepth)
{
PointValue = pointValue;
HullHP = hullHP;
Depth = hullDepth;
}
}

public class Crew
{
public CrewQuality Quality { get; } // is an enum
public int() SectionStrengths { get; set; }

public Crew(CrewQuality quality, params int() sectionStrengths)
{
Quality = quality;

SectionStrengths = new int(sectionStrengths.Length);
for (int i = 0; i < sectionStrengths.Length; i++)
{
SectionStrengths(i) = sectionStrengths(i);
}
}
}

public class Rigging
{
public int() RiggingHPPerMast { get; set; }
public Rigging(params int() riggingHPPerMast)
{
RiggingHPPerMast = new int(riggingHPPerMast.Length);
for (int i = 0; i < riggingHPPerMast.Length; i++)
{
RiggingHPPerMast(i) = riggingHPPerMast(i);
}
}
}

public class Armaments
{
public ShotType ShotType { get; private set; } // is an enum
public Guns Guns {get; private set;}

public Armaments(Guns guns)
{
Guns = guns;
}

{
}
}

public class MovementAbilities
{
public int TurningAbility { get; private set; }
public int BattleSailSpeed { get; private set; }
public int FullSailSpeed { get; private set; }

public MovementAbilities(int turningAbility, int battleSailSpeed) // for basic game rules
{
TurningAbility = turningAbility;
BattleSailSpeed = battleSailSpeed;
}

public MovementAbilities(int turningAbility, int battleSailSpeed, int fullSailSpeed)
: this(turningAbility, battleSailSpeed)
{
FullSailSpeed = fullSailSpeed;
}
}
``````

Ship factory:

``````public class ShipFactory
{
public IShip CreateShip(ShipProperties shipProperties)
{
return shipProperties.Identifiers.Class switch
{
ShipClass.ShipOfTheLine      => new ShipOfTheLine(shipProperties),
ShipClass.LargeShipOfTheLine => new LargeShipOfTheLine(shipProperties),
ShipClass.Frigate            => new Frigate(shipProperties),
ShipClass.LargeFrigate       => new LargeFrigate(shipProperties),
ShipClass.Corvette           => new Corvette(shipProperties),
ShipClass.Brig               => new Brig(shipProperties),
ShipClass.Sloop              => new Sloop(shipProperties),
ShipClass.Schooner           => new Schooner(shipProperties),
ShipClass.Gondola            => new Gondola(shipProperties),
ShipClass.Galley             => new Galley(shipProperties),
ShipClass.Gunboat            => new Gunboat(shipProperties),
ShipClass.Privateer          => new Privateer(shipProperties),
ShipClass.Merchantman        => new Merchantman(shipProperties),
ShipClass.FireShip           => new FireShip(shipProperties),
ShipClass.BombKetch          => new BombKetch(shipProperties),
_                            => throw new NotImplementedException()
};
}
}
``````

real analysis – Question about construction of \$mathbb{R}\$

I hope this question is not naïve, but I’ve stumbled across it and now it’s really bugging me. If we define the real numbers as the completion of the rationals, isn’t the statement that every Cauchy sequence converges a tautology? In what sense is it a theorem?

japan – Are there any Japanese castles currently under construction?

Many once destroyed or demolished Japanese castles were later erected anew in order to boost local tourism. For example, reconstruction of Osaka Castle was finished in 1997.

Are there any castles that are currently being built? I am only aware of on-going restoration of Kumamoto Castle after it was damaged in 2016 earthquake.

differential equations – Construction of Navigation Function: Error

https://www.sciencedirect.com/science/article/abs/pii/S0921889015302451

https://arxiv.org/pdf/1605.00638.pdf – Paragraph III

I am trying to create a navigation function for a 2D system.

$$begin{cases} dot{x}=-x \ dot{y}=-y end{cases}$$

It is built, according to sources, in the following way.

In the end, I want to get something like this

Well. I am trying to do it according to the following algorithm:

1.$$X=(x,y)$$ – vector of states and $$x_{goal}=(0,0)$$ – vector of goal states;

1. $$x_{obs}=(1,1)$$ – obstacles position;

2. $$gamma_d(x)=||X-x_{goal}||^2$$

3. $$beta(x)=(X-x_{obs})^T(X-x_{obs})$$

4. Construct navigation function like: $$frac{gamma_d(x)}{(gamma_d(x)^k+beta(x))^{1/k}}$$

Well, this is the code in Mathematica and I get utter nonsense. Instead of an area of attraction in the region of the target state, I get uncertainty, and the obstacles are not visible at all.

``````Clear("Derivative")

ClearAll("Global`*")

k = 5

X = {x, y}

xgoal = {0, 0}

xobs = {1, 1}

(Gamma)d = Sqrt((X - xgoal).(X - xgoal))^2

(Beta) = (X - xobs).(X - xobs)

(CapitalPhi) = (Gamma)d/(((Gamma)d^k + (Beta))^(1/k))

ParametricPlot3D({x, y, (CapitalPhi)}, {x, -4, 4}, {y, -4, 4},
PlotPoints -> 50)
``````

Problem: What did I go wrong in designing the navigation function?

nt.number theory – Construction of maximal abelian extensions of totally real fields complex-analytically

So Hilbert’s 12th problem has finally been solved for totally real fields (https://arxiv.org/abs/2103.02516), although $$p$$-adic analytically. There is an explicit construction of maximal abelian extensions of totally real fields through adjunction of Brumer-Stark units along with certain other elements.

The question is: what insights does this $$p$$-adic construction provide into how this might be accomplished complex analytically as was the original vision of Hilbert, already realized for the rational field, its imaginary quadratic extensions and a few other fields using division points on abelian varieties?

Dasgupta and Kakde mention that just as in their work integration might be required rather than just special values of complex analytic functions.

Construction of the Hilbert Scheme

I am reading the book "Rational Curves on Algebraic Varieties" of János Kollár. Definition-Proposition 1.2, begin like this:

Let $$g:Yrightarrow Z$$ be a projective morphism and $$mathcal{O}(1)$$ a $$g$$-ample line bundle. I would like to know what is a "$$g$$-ample line bundle".

Thank you a lot!

circle packing – trigonometry- Construction Profession needs help

Architect designed floor layout with a radius that is outside of the building and too far away to see the vertex. Normally we would pull a string the length of the radius but that is not an option. Is there a way to calculate the height of an arc from different points along the chord?

Example- I know where the arc starts and ends, the radius is 300′ and not visible from inside the building but we also know the chord length is 50′. How can I plot the curve of this circle every 3′?
The intention is to draw the arc on the floor as close as possible.

nt.number theory – Construction of Genus class fields

Given a finite extension $$K/mathbb{Q}$$, the genus class field $$G$$ is defined to be the maximal abelian extension of $$mathbb{Q}$$ that is a subfield of the Hilbert class field $$H$$ of $$K$$. I am trying to understand the proof of an alternative construction of $$G$$ in the case when $$K$$ is a cyclic extension with prime degree $$l$$ as follows.

Let $$p_1, p_2, …, p_n$$ be the primes in $$mathbb{Q}$$ that ramify in $$K$$. Suppose $$G_1, G_2, …, G_n$$ be cyclic extensions of degree $$l$$ over $$mathbb{Q}$$ such that $$G_i$$ ramify only at $$p_i$$. Then $$G = G_1 G_2…G_n$$.

I was reading the proof in “Construction of Class Fields – Cael Herz“. The basic strategy is to associate $$K$$ and the $$G_i$$‘s to norm subgroups of $$K$$ using Class field theory and relate them. But I find it hard to comprehend and justify certain crucial claims in the proof one of which I posted on MO earlier (Norm groups of number fields).

Can someone refer me to an alternate proof of this fact or provide some light into Cael’s proof if possible?