Dynamic programming: algorithm to minimize the damage received from monsters

I have been intrigued by the following question in an exam for quite some time: given a set of monsters with their health and attack damage (per second), I designed an algorithm that minimizes the overall damage received since it can damage a monster every second. . Note: all the monsters that are alive attack simultaneously, and the game ends only when all the monsters are killed.

Since a greedy algorithm will not work, I suppose there could be a dynamic programming solution. The DP algorithms that we cover are the type of backpack problems that are more or less in the form of subset selection, where the only decision taken is to determine whether or not the current element is included in the set. However, the problem published here is about the order of the elements (the order in which I attack the monsters). Therefore, it seems to me that knowing the optimal solution for a subproblem of any kind would not help me get the solution to a bigger problem.

I would appreciate suggestions on how to think about this problem.

dnd 3.5e: What are the sources of the (not) sacred damage and the DR for it?

This question has generated an interesting discussion about the damage (not) sacred. So far, it seems that we have established the following:

  • There seems to be no link between the (un) sacred damage and the (un) sacred weapons.
  • There seems to be no rule for (not) sacred damage. However, I also couldn't find any rules for good / bad damage.
  • It can be a mistake, where every instance of sacred damage should be good damage and ungodly damage should be evil damage.
  • At a minimum, it is known that both types of damage appear several times in the Book of exalted facts and the Book of Vile Darkness, but both also appear once in DMG2 & # 39; s (Un) Holy Strike and the errata of the first Monster Manual.

In order to continue the debate on whether or not this type of damage is a mistake, I would like to ask: What sources mention the (not) sacred damage and / or its DR? In particular, I am interested in seeing if there are more cases outside the BoED / BoVD, as they would be evidence that these types of damages are wrong and a potential place to look for rules on these types of damages. I would also like to see if they (or better yet, the rules for them) appear somewhere in 3e.

dnd 5e: Does the abjurer have to activate the projected room before or after throwing the damage?

Does the abjurer have to activate the projected room before or after the damage is launched?

For example, if another player has 10 hp, can the magician wait to see if 10 hp damage occurs before choosing to use the projected room on that player?

Projected room: Starting at the sixth level, when a creature that you can see less than 30 feet from you receives damage, you can use your reaction to make your Arcane Guard absorb that damage. If this damage reduces protection to OR hit points, the protected creature receives the remaining damage.

dnd 3.5e – D & D3.5e – Damage reduction – DR / Unholy vs DR / Evil

We have a party with a heavenly mystic (Book of Exalted Facts), and he was reading about his level 9 ability, which gives him DR 10 / Unholy. Would it be different from DR / evil, since it would only be violated by ungodly weapons and not by attacks by evil strangers?

I ask because I have not seen any monster or anything that has things like DR / Unholy, Holy, Axiomatic, etc. Usually, it's just Good / Evil / Lawful / Chaotic. Has anyone seen any material in books like this? My intuition tells me that it is a typo and should be DR 10 / evil, but the typo says nothing about it.

Thank you!

If you swallow a black hole the size of a marble, would it pierce you causing massive internal damage or consume you?

We could die consuming a regular marble. Just imagine what a black hole could do to us. It has such a density that I would be surprised if the earth itself could handle it (and yes, even the size of a marble).

However, let me reassure you regarding your question. What will happen is that cell by cell, you will begin to disintegrate and, in fact, you will have enough time to see how all this happens. Your flesh will literally start to peel, you can see your guts, every organ that travels through that little black hole, one by one, until there is nothing left of you. Just consider it a super powerful vacuum that never needs cleaning. (If I could only integrate such technology, I would be a billionaire, if not a trillionaire: P).

javascript – I can't pass the damage of a game through socket, please help

Good night, I am studying this but I cannot find a solution, and obviously it is because I am not a good programmer, but an amateur, and secondly I did not understand any important concept.
If anyone can help, you are welcome.
Let's go to the problem that I am trying to implement a small multiplayer online game, simple and that is why I am following a tutorial, however, I can not pass the data that is important in the position of the players, that is, the game or It even starts.

I will send the code if you can help me. I appreciate it, but I would love to know the reasons behind this or not.

 var express = require('express');
 var app = express();
 var serv = require('http').Server(app);
 const io = require('socket.io')(serv);


 app.get('/', function (req, res) {
    res.sendFile(__dirname + '/client/index.html');
 });

 app.use('/client',express.static(__dirname + '/client'));


 serv.on('error', (err) => {
    console.error('Error de Servidor: ', err);
 });
 serv.listen(3000, () => {
   console.log('Server MP started!');
 });

 var SOCKET_LIST = {};

 io.on('connection', (socket) => {
    console.log('uma conexão!');
    socket.id = Math.random();
    socket.x = Math.floor(Math.random()*500);
    socket.y = Math.floor(Math.random()*500);
    SOCKET_LIST(socket.id) = socket;


    console.log('lenght:'+ SOCKET_LIST.lenght);

    socket.emit('newPosition', "SOCKET_LIST ok");
    socket.emit('currentPlayers', SOCKET_LIST);

 });

This is the server part … app.js

Next we have the game code:

  var config = {
  type: Phaser.CANVAS,
  parent: 'phaser-example',
  width: 800,
  height: 600,

  physics: {
  default: 'arcade',
  arcade: {
     debug: false,
     gravity: { y: 0 }
    }
  },
  scene: {
    preload: preload,
    create: create,
    update: update
  } ,

};


var game = new Phaser.Game(config);
var gameState = {};
var player = {};

function preload() {
   console.log('load');
   this.load.image('ship', 'client/assets/basegrid.png');
   //argumentos do spritesheet são, tag, path, { frameWidth: width, frameHeight: height }
   this.load.spritesheet('player', 'client/assets/piccolo.png',{ frameWidth: 48, frameHeight: 48 });
 } // fim do preload

function create() {
   console.log('create');
   gameState.background = this.add.image(400, 600, 'ship');

   var self = this;
   this.socket = io();
   console.log('socket definido');
   this.socket.on('newPosition', function(data){
   console.log('lista de noobs');
   //console.log(data);
   //player(data.id) = self.add.sprite(data.x, data.y, 'player');

  });

   this.socket.on('currentPlayers', function(data){
      console.log(data);
      //aqui vamos ter que entender tudo direito depois

   });



}// fim do create

function update() {



}// fim do update

I just can't pass the data, whatever length I use indefinitely, when I try to use SOCKT_LIST as an array, it doesn't happen unless it's empty.

in short, I need to pass objects (players and their damage) to reach the phaser, but I can only do it when a rope passes. please help

Thanks in advance.

dnd 5e: How does the contingency spell work with Heal wounds as the contingent spell works with the incoming damage?

The damage occurs at once, therefore, very technically, your contingency will not be activated

The rules on "Harm and Healing" state:

(…) Every time a creature takes damage, that damage is subtracted from its hit points (…)

It does not indicate that the damage is inflicted 1 hit point at a time, it is all at once. This means that it will immediately fall to 0 hit points (since 5e has no negative hit points). This technically means that contingency it will not be activated because it never fell to 1 hit point, it fell to 0.

Another thing worth remembering is that contingency always active after your trigger:

(…) The contingent spell takes effect immediately after the circumstance is met for the first time, whether you want it or not, and then the contingency ends (…)

Even if you make it fire when you reach 0 hit points, you will remain briefly unconscious

This is true because contingency occurs after activation and, therefore, would have reached 0 hit points and, as explained in the section "Reduction to 0 hit points":

When you fall to 0 hit points, you die directly or fall unconscious (…)

Ultimately, this means that you, for a moment, will fall unconscious (assuming you do not die instantly from excessive damage) and therefore:

The creature drops everything it is holding and falls prone.


Compare this setting with the death room spell that says:

(…) The first time the objective would fall to 0 hit points as a result of receiving damage, the objective instead falls to 1 hit point, and the spell ends (…)

the death room Instead, the spell will cause the creature to take 30 damage and then finish at 1 hit point, never falling unconscious.

dnd 5e: Can Death Ward save you from death due to the damage caused by the fall?

This is quite simple and straightforward … when you fall:

A fall from a great height is one of the most common dangers an adventurer faces. At the end of a fall, a creature suffers 1d6 of blunt damage for every 10 feet it falls, up to a maximum of 20d6. The creature lands prone, unless it avoids taking damage from the fall.

You only receive blunt damage on impact. It has nothing fancy: it is no different than being hurt by a trap or by someone who hits you with a club.

Death Ward simply says

The first time the target would fall to 0 hit points as a result of taking damage, the target instead falls to 1 hit point and the spell ends.

Then, you received damage from the fall. The damage was so great that you would have 0 HP. Death Ward is activated and you have 1 HP.

The growl that arises in the difference between "is reduced" and "would be reduced" alone (potentially) is important for the effects that do something special when you hit 0HP (such as Disintegrating into dust). Fall damage does nothing special when you reach 0HP … it only damages you like any other source of ordinary damage.

dnd 5e – How does Contingency with healing wounds work with incoming damage?

The damage occurs at once, therefore, very technically, your contingency will not be activated

The rules on "Harm and Healing" state:

(…) Every time a creature takes damage, that damage is subtracted from its hit points (…)

It does not indicate that the damage is inflicted 1 hit point at a time, it is all at once. This means that it will immediately fall to 0 hit points (since 5e has no negative hit points). This technically means that contingency it will not be activated because it never fell to 1 hit point, it fell to 0.

Another thing worth remembering is that contingency always active after your trigger:

(…) The contingent spell takes effect immediately after the circumstance is met for the first time, whether you want it or not, and then the contingency ends (…)

Even if you make it fire when you reach 0 hit points, you will remain briefly unconscious

This is true because contingency occurs after activation and, therefore, would have reached 0 hit points and, as explained in the section "Reduction to 0 hit points":

When you fall to 0 hit points, you die directly or fall unconscious (…)

Ultimately, this means that you, for a moment, will fall unconscious (assuming you do not die instantly from excessive damage) and therefore:

The creature drops everything it is holding and falls prone.


Compare this setting with the death room spell that says:

(…) The first time the objective would fall to 0 hit points as a result of receiving damage, the objective instead falls to 1 hit point, and the spell ends (…)

the death room Instead, the spell will cause the creature to take 30 damage and then finish at 1 hit point, never falling unconscious.

dnd 5e: How does damage work when entering a Wall of Fire?

When the wall is created, you can save dex for half the damage

When launched there is the following effect:

When the wall appears, each creature within its area must make a Dexterity save throw. In a failed salvation, a creature takes 5d8 fire damage, or half damage in a successful salvation.

Thematically, you can skip while the wall of fire is still forming.

After that, entering the fire will burn you

From then on there is this effect:

One side of the wall, selected by you when you cast this spell, deals 5d8 fire damage to each creature that ends its turn less than 10 feet from that side or inside the wall. A creature he receives the same damage when he enters the wall for the first time in a turn or ends there.. The other side of the wall does not cause damage.

In the latter there is no mention of a skill saving shot, or half damage. The wall of fire has emerged, you cannot "dodge" your way through a wall of fire, if you enter it you will burn.

When the second last sentence says "the same damage" refers to the previous sentence that says "cause 5d8 of fire damage".

In summary

  • When the wall is created, make a dex salvation. If you fail, take 5d8 of damage, if you succeed, take half of that.
  • You can move through the wall, but the first time you do it in a turn you will receive 5d8 damage.
  • If you end your turn on the wall or within 10 feet of the selected side, take 5d8 damage.