Giter VIP home page Giter VIP logo

2023-cy-fi's People

Contributors

entelectchallenge avatar jeniquepeters avatar nat212 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

2023-cy-fi's Issues

ElapsedTime in bot state is not calculated correctly.

Hi There,

I seems that the ElapsedTime value in the BotState is not being calculated correctly.
The calculation of the value being sent to bots is done in BotStateDTO.cs:

this.ElapsedTime = hero.End.Subtract(hero.Start).ToString("g");

This calculation uses the Start and End values as defined in HeroEntity.cs:

public DateTime Start;
public DateTime End;

The Start value on the hero entity is set when a bot gets registered:

bot.Hero.Start = DateTime.Now;

The End value is never given a value after being created as part of HeroEntity.
This leads to the following situation when trying to calculate ElapsedTime:

image

One possible place to update the End value on HeroEntities is in the root state Update function:

public void Update()
{
//What order do we want to update the bots in?
//Fastest bot?
Bots.ForEach((bot) =>
{
Console.WriteLine("Running Physics component");
bot.Hero.PhysicsComponent.Update(bot.Hero, Bots.Except(new List<Bot>() { bot }).Select((bot) => bot.Hero).ToList(), Levels[bot.CurrentLevel]);
bot.LastUpdated = DateTime.Now;
});
//Save to file
}

Another possible place to update the End value is in the GameLoop function where the BotStateDTO is created:

private void GameLoop()
{
//Send updated bot state
Logger.Log(LogLevel.Information, $"Tick: {cyFiState.Tick} ************************************************* ");
List<BotStateDTO> botStates = new List<BotStateDTO>();
foreach (var bot in cyFiState.Bots)
{
var oppositionBotsOnSameLevel = cyFiState.Bots.Except(new List<Bot> { bot }).Where(b => b.CurrentLevel == bot.CurrentLevel).ToList();
botStates.Add(new BotStateDTO(bot, oppositionBotsOnSameLevel, bot.Hero, cyFiState.Levels[bot.CurrentLevel]));
Logger.Log(LogLevel.Information, $"bot States: X {bot.Hero.XPosition}, Y {bot.Hero.YPosition}");
}

Alternatively, the End value could be removed from HeroEntities since it is not used anywhere in the program except to calculate ElapsedTime. Instead, the LastUpdated value from the Bot itself could be used since it gets updated every tick:
image

Depending on how / where you want to handle this I can put together a PR.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.