Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using ConnectFour;
- using System;
- public class MarvinKirchnerBot : IPlayer
- {
- public readonly Random random = new Random();
- public int Set(ConnectFour.Board board)
- {
- //setColumnValue needed
- //while setolumn is the standard value
- //return of setColumnValue
- var setColumn = 0;
- Occupants test = board.CurrentPlayer;
- // setColumn = board[x, y].Column;
- for (int y = 0; y < board.Height; y++)
- {
- for (int x = 0; x < board.Width; x++)
- {
- if (!board.Columns[x].IsFull)
- {
- //if (board.Fields[x, y].Occupant != board.CurrentPlayer)
- //{
- if (x <= 1 && y < board.Height) //kein links
- {
- if (board.Fields[x + 1, y].Occupant == Occupants.None)//wenn einen nach rechts frei ist, setze einen nach rechts
- {
- if (board.Fields[x, y].Occupant != test)
- {
- setColumn = board[x + 1, y].Column;
- }
- }
- else
- {
- if (board.Fields[x, y].Occupant != test)
- {
- setColumn = board[x, y - 1].Column; //top
- }
- }
- }
- else
- {
- if (x >= board.Width - 1 && x > 1) //kein rechts
- {
- if (board.Fields[x - 1, y].Occupant == Occupants.None) //wenn einen nach links frei ist, setze dort hin
- {
- if (board.Fields[x , y].Occupant != test)
- {
- setColumn = board[x - 1, y].Column;
- }
- }
- else
- {
- if (board.Fields[x , y].Occupant != test)
- {
- setColumn = board[x, y - 1].Column;//top
- }
- }
- }
- else
- {
- if (board.Fields[x + 1, y].Occupant == Occupants.None)
- {
- //wenn einen nach rechts frei ist, setze einen nach rechts
- if (board.Fields[x , y].Occupant != board.CurrentPlayer)
- {
- setColumn = board[x + 1, y].Column;
- }
- }
- else if (board.Fields[x - 1, y].Occupant == Occupants.None && x > 1)
- {
- //wenn einen nach links frei ist, setze dort hin
- if (board.Fields[x , y].Occupant != board.CurrentPlayer)
- {
- setColumn = board[x - 1, y].Column;
- }
- }
- else
- {
- //top
- if (board.Fields[x, y].Occupant != board.CurrentPlayer)
- {
- setColumn = board[x, y - 1].Column;
- }
- }
- }
- }
- //}
- }
- }
- }
- return setColumn;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement