I am getting an error with my code.. I am new to C# and I am trying to make a two player turn based game. Doing this using visual studio
The error is "Warning 2 The variable 'gs' is assigned but its value is never used"
The code is below;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System;
namespace GridWorld
{
public class newAI : BasePlayer
{
PlayerWorldState myWorldState;
private double maxSpeed = 5f;
//public int MaxNumTurn = 15;
private int Steps;
private object count;
public newAI ()
: base()
{
this.Name = "AI FOR GAMES THE A TEAM";
// this.MaxNumTurn = 15;
var gs = new GridSquare.ContentType(); // the variable gs is now a new GridSquare content type
}
void Pathfind()
{
PlayerWorldState startingPoint = BasePlayer(GridSquare.ContentType.Snail);
int myX = 0;
int myY = 0;
if (myX == -1 || myY == -1) // if myX & myY are equal to minus 1 then increment the steps
Steps++;
{
return;
}
gs [myX, myY].Steps = 0; // outside whileloop
while (true)
{
bool madeProgress = false;
foreach (startingPoint mainPoint in gs)
{
int x = mainPoint.X;
int y = mainPoint.Y;
if (SquareOpen(x, y))
{
int passHere = GridSquare[x, y].Steps;
foreach (startingPoint movePoint in ValidMoves(x, y))
{
int myX = movePoint.X;
int myY = movePoint.Y;
int newPass = passHere + 1;
if (GridSquare[myX, myY].Steps > newPass)
{
GridSquare[myX, myY].Steps = newPass;
madeProgress = true;
}