Answer the question
In order to leave comments, you need to log in
How to fix the program?
The error is that in my opinion, the coordinates of the 'rabbits' should 'jump' around the field, but according to observations, they always end up at the point 0;0. Why is that?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace wolf_islandUPDATE
{
static class Rabbits
{
public static List<int> rabbits_x = new List<int> { 3, 12 };
public static List<int> rabbits_y = new List<int> { 3, 12 };
public static Random rnd = new Random();
public static void rabbits_clone()
{
}
public static void rabbits_turn()
{
for (int i = 0; i < rabbits_x.Count; i++)
{
Console.SetCursorPosition(rabbits_x[i], rabbits_y[i]);
Console.BackgroundColor = ConsoleColor.White;
Console.Write(" ");
if (rnd.Next(1, 9) == 1)
{
int x = 0;
int y = 0;
bool e = false;
while (e != true)
{
x = rnd.Next(-1, 1);
y = rnd.Next(-1, 1);
if ( (rabbits_x[i]+x<=19 && rabbits_x[i]+x >= 0) && (rabbits_y[i] + y <= 19 && rabbits_y[i]+y >= 0) )
{
rabbits_x[i] += x;
rabbits_y[i] += y;
e = true;
}
//
}
}
}
}
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question