unity2d – Error in: A namespace can not directly contain elements such as fields or methods

I'm in a project for my school of a maze game and in the following C # script I try to create a variable and set it to true when it collides with the target, but I get the following error:

Assets MoveCameraa.cs (8,10): Error CS0116: A namespace can not directly contain elements such as fields or methods

The script looks like this:

using UnityEngine;
public class MoveCameraa : MonoBehaviour
{
    public bool Lvl = false; //Variable entera de la clase Counter, la cual incrementara cada que entre en colision la otra clase con el tag "Paso3"
}
namespace x
{
    void OnCollisionEnter2D(Collision2D col) //aquí donde dice OnCollisionEnter2D me sale el error 
    {
        Debug.Log("OnCollisionEnter2D");
        {
            if (col.collider.compareTag("Meta"))
            {
                Lvl = true;
            }
        }    
    }   
}

Unity – Why is there no drop-down list of methods and options in Visual Studio and VSCode?

I'm using VSCode, but I also tried writing code for Unity with Visual Studio 2019, but when I write the lines, I do not get any drop-down menus, for example, with the methods of that class. Or objects. Or they are properties. etc .: Basically, IntelliSense does not work.

Is there a setting I need to enable to get it? Since then, I've seen that anyone using VSCode and Visual Studio gets these drop-down menus.

Can abstractions and proven code methods in embedded C ++ make the debugger redundant?

Although debuggers are a useful tool for many things, by definition they are primarily intended for … debugging. Your question, then, is whether best practices and confidence in third-party code can ever completely eliminate errors.

(…) trust that language selection and best practices reduce the likelihood of errors, so the debugger is no longer needed.

As you said, you did not, even if you trust your languages ​​/ frameworks and best practices to reduce the likelihood of errors eliminated all bugs, but the likelihood of their occurrence is reduced. How do you diagnose the errors that still occur without a debugger (or a similar approach to logging)?

If everyone is 100% familiar with their languages ​​and frameworks, how are errors detected in the languages ​​/ libraries themselves? Open a mainstream project on GitHub and see how many issues are reported.

Best practices can reduce software errors, but even the best practices and tools can not spoil the benefits of a debugger.

I think your answer is in your own comment:

(…) Many of my problems occur when the hardware behaves unexpectedly

The problem with bugs is that we never see them coming!

Is it the right pattern for the private methods of Razor Pages to return IActionResult to handler?

Is this a good code pattern in ASP.NET Core Razor Pages for private methods to return? IActionResult to the calling handler?

// Public handler

public IActionResult OnGet()
{
    var result = SetupPage();
    if (result != null)
        return result;

    // do some work

    return Page();
}

// Private methods

private IActionResult SetupPage()
{
    if (allValid)
    {
        // call method to do some work
        var result = DoSomething();
        if (result != null)
            return result;

        // do some more work
        return null;
    }
    else
    {
        return Return(abcUrl);
    }
}

private IActionResult DoSomething()
{
    if (someCondition)
    {
        // do some work
        return null;
    }
    else
    {
        return Return(xyzUrl);
    }
}

I feel like result Checks and redirects in each method are not elegant. If so, what is a good alternative?

Alternative reference to Davenport's analytical methods for the geometry of numbers?

Thank you for giving MathOverflow an answer!

  • Please be sure too answer the question, Provide details and share your research!

But avoid

  • Ask for help, clarify or respond to other answers.
  • Make statements based on opinions; Cover them with references or personal experience.

Use MathJax to format equations. Mathjax reference.

For more information, see our tips for writing great answers.

numerical methods – Inner product stable backwards

To let $ f (x, y) = x ^ {T} y $, Where $ x = (x_1, …, x_n), y = (y_1, …, y_n) $.Accept $ f $ represent the floating point calculation

To let $ f_1 = f (x_1y_1) $ and recursively define $ f_n, n ge $ 2 represent the floating point calculation of $ f (f_ {n-1} + f (x_ny_n)) $, Then

$ f_1 = x_1y_1 (1+ delta_1) $ Where $ | delta_1 | < epsilon_M $

$ f_2 = f (f_1 + x_2y_2) = (x_1y_1 (1+ Delta_1) + x_2y_2 (1+ Delta_2)) (1+ Beta_2) $ where disorder $ | beta_2 |, | delta_2 | $ $ < epsilon_m $

$ f_3 = f (f_2 + x_3y_3) = x_1y_1 (1+ Delta_1) (1+ Beta_2) (1+ Beta_3) + x_2y_2 (1+ Delta_2) (1+ Beta_2) (1+ Beta_3) + x_3y_3 (1+ delta_3) (1+ beta_3) $

,

,

,

$ f_n = f (f_ {n-1} + x_ny_n) = x_1y_1 (1+ delta_1) (1+ beta_2) cdot cdot cdot (1+ beta_n) + … + x_ny_n (1+ delta_n) (1+ beta_n) $$ | beta_i |, | delta_i | $ $ < epsilon_m $

$ f_n = sum_ {i = 1} ^ {n} x_iy_i (1+ gamma_i) $ Where, $ 1 + gamma_i = (1+ delta_i) (1+ beta_i) (1+ beta_ {i + 1}) … (1+ beta_n) $ With $ beta_1 = 0 $

Then take $ has {x_i} = x_i (1+ gamma_i) $ $ y_i = has {y_i} $, then $$ has {f} (x, y) = f ( has {x}, has {y}) $$ and notice that $ frac {|| has {x_i} – x_i ||} {|| x_i ||} = | gamma_i | $. $ textbf {My first question is what represents} $ $ O ( epsilon_m)? $ I know that $ gamma_i $ is a product of $ beta_j beta_k delta_i $ and other things, and I know that $ gamma_i $ is limited to a product of $ epsilon_m $ , for example: $$ gamma_n < epsilon_m (1+ epsilon_m) $$, knowing that, $ textbf {is true} $ $ | gamma_i | = O ( epsilon_m) $, and why?

formal methods – modeling of a number of probabilistic simultaneous processes

I study time-discrete Markov chains (DTMCs) for the analysis of a probabilistic consensus protocol. One basic thing I could not figure out is the modeling of a number of independent processes: think about it $ N $ processes. These processes simultaneously execute a series of identical statements named $ 0, 1, 2, 3, $ etc. and all begin in the classroom $ 0 $, If there is no probability, the modeling is simple: it is a state machine that does not derive deterministically from the start state $ N $ different states where in each of those $ N $ indicates that another process was the first to execute an instruction $ 0 $, What do we do when it comes to probability? Let's do the same $ N $ States that branch off from the start state, where the probability of transition to each state is the same $ frac {1} {N} $? As in, it is uniformly random which process was the first to execute the instruction $ 0 $?

Is that like taking the product of the state machines of each process?

I use a DTMC here. Would I win anything if I switched to a CTMC if I did not care about the global execution order?

Bonus Question: Assigning probabilities to each action (process that executes an instruction) that is executed first seems to be a generalization of the non-probabilistic notion of fairness. If so, what is the formal definition of this generalized concept of probabilistic fairness?

smooth manifolds – Easier methods for calculating homology / cohomology by adding additional structures

Accept $ X $ is a topological space and I want to talk about his "homology".

There is this notion of singular homology obtained from the singular chain complex. This is not very easy to calculate.

Suppose we assume that there is an additional structure in topological space $ X $So we can talk about the structure of a CW complex and from there to the concept of the cellular chain complex and cellular homology. This is easier than calculating a singular homology.

Let us continue with this topological space $ X $ (which we have assumed to have a CW structure) has an additional structure of a simplicial complex, then we can talk about the concept of the simplicial chain complex and then the concept of simplicial homology. This is easier to calculate than cellular homology.

Then it is the standard result that any two homology groups that come from different approaches coincide, if both are meaningful.

Question: Is there an extra structure (not trivial) that I can add to one?
Space with a simple structure that makes it easier to calculate
Homology in terms of chain complex easier than simple chain
Complex?

The same applies to cohomology. Suppose I have a topological space $ X $I can talk about his singular Cochain Complex and the corresponding singular cohomology.

Suppose this topological space $ X $ Given the structure of a manifold, we can talk about the Cochain complex of differential forms and use it to compute the cohomology of topological space $ X $, It is a standard result that if the coefficients are correct, the singular cohomology is identical to the deRham cohomology (deRham theorem).

Question: Is there an additional structure that I can add to a manifold?
this results in a simpler cochain complex than the cochain complex of
Differential forms that give a simpler way to calculate the cohomology of
the manifold? Suppose I fix a connection on the tangent
bundle up $ TM rightarrow M $ of the distributor $ M $ (or a Riemann metric on the manifold $ M $), I can produce easier
Complex with the compound that calculates cohomology easily?

When I try to find a meaning for the concept of cohomology theory, which connects to the tangent bundle $ TM rightarrow M $ (a metric on the distributor $ M $) then it is to be expected that this concept does not depend on the connection choice that I have defined. Does the assumption that there is a flat connection on the tangent bundle indicate an apparent cochain complex?

Suppose I ask that distributor $ M $ If a Lie group has an additional structure, there is a simpler Cochain complex that computes the cohomology of the manifold more easily than the DeRham cohomology. This is too much to ask, I am looking for results that lie between the deRham cohomology of manifoldness and the strictly lower structure than the notion of Lie groups.

References are welcome.