I have to do course works in C# language. I hope there is one can be able to help me in that. You see the details for them below.
I have GirdWorld to apply in it for each one. I have API .
I have done part of the code but I still confused
Coursework 1 - Infectious!
Infectious is a game of perfect information for 2 or more players (i.e. all players can see all of the board, all of the time). The coursework is to design, write, test, refine and document an effective Infectious player. A competition will run continuously with match results and league standings displayed over the Internet.
Coursework 2 – BugWorld
Bugs is a simple simultaneous-movement multi-player artificial life simulation, which captures much of the planning complexity of much more complex simulation.The coursework is to design, write, test, refine and document an effective Bugs player. A competition will run continuously with match results and league standings displayed over the Internet.
Kindest Regards,
A HamedPosted Feb 12, 2008, 1:19 PM
Hi Jan Montano
I hope you are very well. I’m looking forward to hear from you.
Actually I’ve added some code for infectious. I’d like you to help me in that. I’m still confused with it and I should submit the first coursework two weeks later.
Thanks
A HamedPosted Feb 7, 2008, 5:17 PM
Hi Jan Montano
Thanks for your replying. I would like to provide me by your E-mail to keep in touch and I send to you some codes. The code which I posted is part of the code. There are other codes I have done.
Regards,
Jan MontanoPosted Feb 6, 2008, 9:03 PM
And last, how does infectious work?
A HamedPosted Feb 6, 2008, 1:58 PM
using System; using System.Collections; // For ArrayList namespace GridWorld { public class AIPlayer : BasePlayer { PlayerWorldState myWorldState; ///
/// The ArrayList which will contain the 8 lines of a standard 3x3 OXO grid.
///
ArrayList Lines = new ArrayList();
public AIPlayer() : base ()
{
this.Name = "OneStepEvaluator";
// Initialise the array of 8 lines
Lines.Add(new Line(0,0,0,1,0,2)); // Vertical Line (0,0), (0,1), (0,2)
Lines.Add(new Line(1,0,1,1,1,2)); // Vertical Line (1,0), (1,1), (1,2)
Lines.Add(new Line(2,0,2,1,2,2)); // Vertical Line (2,0), (2,1), (2,2)
Lines.Add(new Line(0,0,1,0,2,0)); // Horizontal Line (0,0), (1,0), (2,0)
Lines.Add(new Line(0,1,1,1,2,1)); // Horizontal Line (0,1), (1,1), (2,1)
Lines.Add(new Line(0,2,1,2,2,2)); // Horizontal Line (0,2), (1,2), (2,2)
Lines.Add(new Line(0,0,1,1,2,2)); // Diagonal Line (0,0), (1,1), (2,2)
Lines.Add(new Line(2,0,1,1,0,2)); // Diagonal Line (2,0), (1,1), (0,2)
}
///
/// Get the commands for this turn. The board etc. is in igrid.
///
public override ICommand GetTurnCommands(IPlayerWorldState igrid)
{
myWorldState = (PlayerWorldState)igrid; // Make igrid into a PlayerWorldState class variable.
int[,] board; // We will use this to represent temporary board positions
ArrayList unmarkedsquares = GetAllUnMarkedSquares(); // the list of empty squares = the list of possible moves.
GridSquare bestSquare = null; // the best move seen so far
int bestScore = int.MinValue; // the score of the board posiiton resulting from the best move
int score; // the score of the position resulting from the move currently under consideration
foreach (GridSquare gs in unmarkedsquares) // loop through possible moves
{
board = MyWorldStateToIntArray(); // make a temporary copy of the board
board[gs.X, gs.Y] = myWorldState.ID; // mark square gs on the temporary board
score = GetBoardScore(board); // evaluate this board
WriteTrace("Move (" + gs.X + "," + gs.Y + ") gives position with score " + score);
if (score > bestScore) // If this is the best move so far then save it
{
bestScore = score;
bestSquare = gs;
}
}
// Return the best square seen (if any)
if (bestSquare != null)
return new Command(bestSquare.X, bestSquare.Y);
else
return null;
}
///
/// Evaluate the "score" of this temporary board, which is a measure of its goodness from my point of view
/// (i.e. how likely I think I am to win).
///
private int GetBoardScore(int[,] board)
{
int score = 0; // the score so far
int me = myWorldState.ID; // my ID
int opp = 3 - myWorldState.ID; // my opponent (if my ID is 1, my opponent's ID is 3-1 = 2; if my ID is 2, my opponent's ID is 3-2 = 1).
int empty = 0; // empty squares have player ID zero
foreach (Line li in Lines) // Consider each line in turn
{
if (li.MarkCount(board, me) == 3)
score += 10000; // Line l is a winning line (XXX)
else if (li.MarkCount(board, me) == 2 && li.MarkCount(board,empty) == 1)
score += 1000; // Line l has two of my mark and a space (XX_)
// else if ... - YOU FILL IN THE REST
}
return score;
}
///
/// Convert the board myWorldState to a (temporary) 3x3 int array (that we can modify)
///
///
int[,] MyWorldStateToIntArray()
{
int[,] board = new int[3,3];
for(int x = 0;x < 3; x++)
for(int y = 0;y < 3; y++)
board[x,y] = myWorldState[x,y].Player;
return board;
}
///
/// Get the list of unmarked squares = possible moves.
///
///
private ArrayList GetAllUnMarkedSquares()
{
ArrayList UnMarkedSquares = new ArrayList();
for(int x = 0;x < myWorldState.GridWidthInSquares;x++)
{
for(int y = 0;y < myWorldState.GridHeightInSquares;y++)
{
if(myWorldState[x,y].Contents == GridSquare.Empty)
{
UnMarkedSquares.Add(myWorldState[x,y]);
}
}
}
return UnMarkedSquares;
}
///
/// A collection of three points in a line on a standard OXO board, horizontal, vertical or diagonal.
///
private class Line
{
///
/// The coordinates of the line are (X0,Y0), (X1,Y1), (X2,Y2).
///
int X0,Y0,X1,Y1,X2,Y2;
///
/// Make a line with squares (x0,y0), (x1,y1), (x2,y2).
///
public Line(int x0, int y0, int x1, int y1, int x2, int y2)
{
X0 = x0; Y0 = y0; X1 = x1; Y1 = y1; X2 = x2; Y2 = y2;
}
///
/// Returns the number of squares marked by player playerid on this line.
///
public int MarkCount(int[,] board, int playerid)
{
int count = 0;
if (board[X0,Y0] == playerid)
count++;
if (board[X1,Y1] == playerid)
count++;
if (board[X2,Y2] == playerid)
count++;
return count;
}
}
}
}
Jan MontanoPosted Feb 5, 2008, 9:00 PM
Everyone here at c-sharpcorner would be very willing to help you, but you must do your part first. Have a research and make a code out of your requirement. We can help you with problems you encounter along the way but we can't help you to do all the work for you. Because you'll not be able to learn effectively.
You did some code for the first project? That's great! Is it working now the way you want it? If it's not, try to post the problems you encounter and people here would be glad to help you with it.
Cheers,
Jan
A HamedPosted Feb 5, 2008, 10:35 AM
I have done some codes for the first coursework. I hope there is someone is able to help me in that.
Thanks