public Polyomino(Polyomino polyomino) : this(polyomino.Minos) { this.colorR = polyomino.colorR; this.colorG = polyomino.colorG; this.colorB = polyomino.colorB; }
public Polyomino(Polyomino prevPoly, Vector2 adj) { this.Minos = new HashSet<Vector2>(); foreach (Vector2 v in prevPoly.Minos) { Minos.Add(new Vector2(v.X, v.Y)); } Minos.Add(adj); }
public GameBoardData(HashSet<Mino> SettledMinos, Polyomino FallingPolyomino, Vector2 FallingPolyominoLocation, int n, int Width, int Height, WallKickStrategy WallKickStrategy, PolyominoDealer dealer ) { this.GameOver = false; this.SettledMinos = SettledMinos; this.FallingPolyomino = FallingPolyomino; this.FallingPolyominoLocation = FallingPolyominoLocation; this.n = n; this.Height = Height; this.Width = Width; this.WallKickStrategy = WallKickStrategy; this.MyPieceDealer = dealer; FallingRate = 700; FallingCooldown = FallingRate; }
public static SolidColorBrush assignColor( Polyomino p_ ) { Polyomino p = new Polyomino( p_.Minos); HashBitArray h = p.toBitArray(); if (p.Minos.Count == 4) { // i bool[] x = { true, true, true, true, false, false, false, false, false, false, false, false, false, false, false, false }; HashBitArray b = new HashBitArray(x); if (h.Equals(b)) return Brushes.Cyan; // o bool[] x1 = { true, true, false, false, true, true, false, false, false, false, false, false, false, false, false, false }; HashBitArray b1 = new HashBitArray(x1); if (h.Equals(b1)) return Brushes.Yellow; // t bool[] x2 = { true, true, true, false, false, true, false, false, false, false, false, false, false, false, false, false }; HashBitArray b2 = new HashBitArray(x2); if (h.Equals(b2)) return Brushes.Purple; // s bool[] x3 = { true, true, false, false, false, true, true, false, false, false, false, false, false, false, false, false }; HashBitArray b3 = new HashBitArray(x3); if (h.Equals(b3)) return Brushes.Green; // z bool[] x4 = { false, true, true, false, true, true, false, false, false, false, false, false, false, false, false, false }; HashBitArray b4 = new HashBitArray(x4); if (h.Equals(b4)) return Brushes.Red; // j bool[] x5 = { true, true, true, false, true, false, false, false, false, false, false, false, false, false, false, false }; HashBitArray b5 = new HashBitArray(x5); if (h.Equals(b5)) return Brushes.Blue; // l bool[] x6 = { true, true, true, false, false, false, true, false, false, false, false, false, false, false, false, false }; HashBitArray b6 = new HashBitArray(x6); if (h.Equals(b6)) return Brushes.Orange; } //int hash = h.GetHashCode(); //if (hash < 0) //{ // hash = -(hash + 1); //} //double hue = (hash + 0.0) / int.MaxValue; //hue *= 360; //int red; //int green; //int blue; //HsvToRgb(hue, .5, .5, out red, out green, out blue); //Color c = new Color(); //c.R = (byte)red; //c.G = (byte)green; //c.B = (byte)blue; return Brushes.Black; }
internal List<Polyomino> getPolyominos(int n) { generatePolyominos(n); List<Polyomino> ret = new List<Polyomino>(); foreach (HashBitArray h in polyominoList[n]) { Polyomino p = new Polyomino(h, n); p.SRSNormalize(); ret.Add(p); } PolyominoColorChooser.assignColors(ret); return ret; }
public void generatePolyominos(int n) { if (!polyominoList.ContainsKey(n)) { HashSet<HashBitArray> toAdd = new HashSet<HashBitArray>(); if (n == 1) { HashBitArray b = new HashBitArray(1); b[0] = true; toAdd.Add(b); } else { generatePolyominos(n - 1); foreach (HashBitArray prev in polyominoList[n - 1]) { Polyomino prevPoly = new Polyomino(prev, n - 1); foreach (Vector2 adj in prevPoly.getAdj()) { Polyomino next = new Polyomino(prevPoly, adj); HashBitArray nextBits = next.toBitArray(); Boolean isNew = !toAdd.Contains(nextBits); for (int i = 0; i < 3 && isNew; i++) { next.rotate90CC(); nextBits = next.toBitArray(); isNew = !toAdd.Contains(nextBits); } if (isNew) { toAdd.Add(nextBits); } } } } polyominoList[n] = toAdd; } }
private bool loadPolyomino(Polyomino p) { FallingPolyomino = p; if (!tryFallingPosition(new Vector2(n + (n / 2) / 2 - 1, Height - n / 2 - 1))) { GameOver = true; return false; } p.SRSNormalize(); InfinityCount = maxInfinity; return true; }
public Mino(Vector2 v, Polyomino p) { this.v = v; this.p = p; }