-
Notifications
You must be signed in to change notification settings - Fork 0
/
Player.cs
68 lines (54 loc) · 1.53 KB
/
Player.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
using System;
using System.Collections.Generic;
using System.Linq;
namespace TicTacToe
{
public enum Kind
{
O = 'o',
X = 'x',
Tie = 't',
None = 'n'
}
public class Player : ICloneable
{
static double Map(double a1, double a2, double b1, double b2, double s) => b1 + (s - a1) * (b2 - b1) / (a2 - a1);
public int X = 0;
public int Y = 0;
public Kind Type { get; private set; }
public int TotalMoves;
private byte[] set_vals = new byte[3*3];
//int score = 0;
public Player(Kind pt)
{
Type = pt;
TotalMoves = 0;
}
public void SetMove()
{
set_vals[Y * 3 + X] = 1;
TotalMoves++;
}
public void RemoveMove(int x, int y)
{
set_vals[y * 3 + x] = 0;
TotalMoves--;
}
public bool IsWinner(Board board)
{
if (TotalMoves < board.MatchDepth) return false;
var res = false;
int mathced = 0;
for (int i = 0; i < set_vals.Length; i++)
{
}
return res;
}
object ICloneable.Clone()
{
var player = new Player(this.Type){ X = this.X, Y = this.Y, set_vals = new byte[set_vals.Length], TotalMoves = this.TotalMoves };
Buffer.BlockCopy(this.set_vals, 0, player.set_vals, 0, this.set_vals.Length * sizeof(byte));
return player;
}
}
}