public void updateResult(GoMove gm) { _currVar.updateResult(gm); }
/** * ZZZZZZZ Z ZZZ ZZZ ZZZ ZZZZZZZZZZZZZ ZZZZZ * ZZ ZZZZZ ZZ Z ZZZZ, ZZ ZZZZZZ ZZZZZZZZZZZ. * ZZZZZZZZZZ, ZZZ ZZZZZZZ ZZZ ZZZZ ZZZZ ZZZ ZZZZ ZZ ZZZZ. * * ZZZZ: ZZ/ZZ ZZZ ZZZZZZZZZ ZZZ ZZZZ ZZZZZZZZ ZZZZZ ZZZZZZ, ZZZ Z ZZZZZ'Z ZZZZ ZZZ ZZZZZZZ ZZZ */ Boolean processASection(ArrayList arrKV) { Boolean fMultipleMoves = false; //ZZZZZZZ ZZZZ ZZZZZZZ ZZZ ZZZZZZZZ ZZZZZ. GoMove gm = null; string key, strValue; for (int i = 0;i<arrKV.Count;i++) { key = ((KeyValuePair)(arrKV[i])).k; for (int j=0; j<((KeyValuePair)(arrKV[i])).alV.Count; j++) { strValue = (string)(((KeyValuePair)(arrKV[i])).alV[j]); if (key.Equals("B")) //ZZZZZ ZZZZZ { Debug.Assert(gm == null); gm = new GoMove(strValue, StoneColor.black); } else if (key.Equals("W")) //ZZZZZ ZZZZZ { Debug.Assert(gm == null); gm = new GoMove(strValue, StoneColor.white); } else if (key.Equals("C")) //ZZZZZZZ { //ZZZZZ.ZZZZZZ(Z>0); if (gm != null) gm.Comment = strValue; else //ZZZ ZZ ZZ ZZZ ZZZZ ZZZZZZZ _gi.comment += strValue; } else if (key.Equals("L")) //ZZZZZ { if (gm != null) gm.addLabel(strValue); else //ZZZ ZZ ZZ ZZZ ZZZZ ZZZZZZZ _stGameComment += strValue; } else if (key.Equals("M")) //ZZZZ { if (gm != null) gm.addMark(strValue); else //ZZZ ZZ ZZ ZZZ ZZZZ ZZZZZZZ _gi.comment += strValue; } else if (key.Equals("AW")) //ZZZ ZZZZZ ZZZZZ { fMultipleMoves = true; gm = new GoMove(strValue, StoneColor.white); } else if (key.Equals("AB")) //ZZZ ZZZZZ ZZZZZ { fMultipleMoves = true; gm = new GoMove(strValue, StoneColor.black); } else if (key.Equals("HA")) _gi.handicap = (strValue); else if (key.Equals("BR")) _gi.rankBlack = (strValue); else if (key.Equals("PB")) _gi.playerBlack = (strValue); else if (key.Equals("PW")) _gi.playerWhite = (strValue); else if (key.Equals("WR")) _gi.rankWhite = (strValue); else if (key.Equals("DT")) _gi.date = (strValue); else if (key.Equals("KM")) _gi.km = (strValue); else if (key.Equals("RE")) _gi.result = (strValue); else if (key.Equals("SZ")) _gi.size = (strValue); else if (key.Equals("EV")) _gi.gameEvent = (strValue); else if (key.Equals("PC")) _gi.location = (strValue); else if (key.Equals("TM")) _gi.time = (strValue); else if (key.Equals("GN")) _gi.gameName = strValue; else if (key.Equals("FF")) _gi.unknown_ff = (strValue); else if (key.Equals("GM")) _gi.unknown_gm = (strValue); else if (key.Equals("VW")) _gi.unknown_vw = (strValue); else if (key.Equals("US")) _gi.unknown_vw = (strValue); else if (key.Equals("BS")) _gi.unknown_vw = (strValue); else if (key.Equals("WS")) _gi.unknown_vw = (strValue); else if (key.Equals("ID")) _gi.unknown_vw = (strValue); else if (key.Equals("KI")) _gi.unknown_vw = (strValue); else if (key.Equals("SO")) _gi.unknown_vw = (strValue); else if (key.Equals("TR")) _gi.unknown_vw = (strValue); else if (key.Equals("LB")) _gi.unknown_vw = (strValue); else if (key.Equals("RO")) _gi.unknown_vw = (strValue); //ZZZZ ZZZZZ else System.Diagnostics.Debug.Assert(false, "unhandle key: " + key + " "+ strValue); //ZZZZZZZZZ ZZZ ZZZZ ZZZZZZ ZZZ ZZZZ ZZ ZZZZ ZZZZ (ZZ, ZZ) ZZZZ ZZZZZZZZ ZZZZZ. if (fMultipleMoves) { _currVar.addAMove(gm); } } } //ZZZ ZZZ ZZZZ ZZ ZZZZZZZ ZZZZZZZZZ. if (!fMultipleMoves && gm != null) { _currVar.addAMove(gm); } return true; }
private void setLabelsOnBoard(GoMove gm) { short nLabel = 0; Point p; if (null != gm.Labels) { int i = gm.Labels.Count; i = gm.Labels.Capacity; System.Collections.IEnumerator myEnumerator = gm.Labels.GetEnumerator(); while (myEnumerator.MoveNext()) { p = (Point)myEnumerator.Current; Grid[p.X,p.Y].setLabel(++nLabel); } } }
public void playNext(ref GoMove gm) { Point p = gm.Point; m_colorToPlay = gm.Color; //当前颜色为当前棋子的颜色 //先清除屌所有的label和mark clearLabelsAndMarksOnBoard(); if (m_gmLastMove != null) repaintOneSpotNow(m_gmLastMove.Point); bDrawMark = true; Grid[p.X,p.Y].setStone(gm.Color); m_gmLastMove = new GoMove(p.X, p.Y, gm.Color, nSeq++); //重新画出marks和labels setLabelsOnBoard(gm); setMarksOnBoard(gm); doDeadGroup(nextTurn(m_colorToPlay)); //处理无气的对方棋子,如果存在,则下面进行处理. if (m_fAnyKill) appendDeadGroup(ref gm, nextTurn(m_colorToPlay)); else //处理无气的己方棋子. { doDeadGroup(m_colorToPlay); if (m_fAnyKill) appendDeadGroup(ref gm, m_colorToPlay); } m_fAnyKill = false; optRepaint(); //转换下棋子颜色 m_colorToPlay = nextTurn(m_colorToPlay); //更新注释 textBox1.Clear(); textBox1.AppendText(gm.Comment); }
public void resetBoard() { int i,j; for (i=0; i<nSize; i++) for (j=0; j<nSize; j++) Grid[i,j].removeStone(); m_gmLastMove = null; Invalidate(null); }
///��������� private void MouseUpHandler(Object sender,MouseEventArgs e) { Point p; GoMove gmThisMove; p = PointToGrid(e.X,e.Y); //�Ƿ�������� �������� ����ӽ������ ����û���� if (!onBoard(p.X, p.Y) || !closeEnough(p,e.X, e.Y)|| Grid[p.X,p.Y].hasStone()) return; //��һ���� ������һ�� Ȼ��play ����Tree�ϼ�¼ gmThisMove = new GoMove(p.X, p.Y, m_colorToPlay, 0); playNext(ref gmThisMove); gameTree.addMove(gmThisMove); }
public void resetBoard() { int i,j; for (i=0; i<nSize; i++) for (j=0; j<nSize; j++) Grid[i,j].removeStone(); m_gmLastMove = null; optRepaint(); }
public void playNext(ref GoMove gm) { Point p = gm.Point; m_colorToPlay = gm.Color; //��ǰ��ɫΪ��ǰ���ӵ���ɫ //������е�label mark clearLabelsAndMarksOnBoard(); if (m_gmLastMove != null) repaintOneSpotNow(m_gmLastMove.Point); bDrawMark = true; Grid[p.X,p.Y].setStone(gm.Color); m_gmLastMove = new GoMove(p.X, p.Y, gm.Color, nSeq++); //���»���marks labels setLabelsOnBoard(gm); setMarksOnBoard(gm); doDeadGroup(nextTurn(m_colorToPlay)); //������������� if (m_fAnyKill) appendDeadGroup(ref gm, nextTurn(m_colorToPlay)); //��¼���� else //����Լ���û���Բе��Լ��³��������� { doDeadGroup(m_colorToPlay); if (m_fAnyKill) appendDeadGroup(ref gm, m_colorToPlay); } m_fAnyKill = false; optRepaint(); //�Է����� m_colorToPlay = nextTurn(m_colorToPlay); //����ע�� textBox1.Clear(); textBox1.AppendText(gm.Comment); }
public void playNext(ref GoMove gm) { Point p = gm.Point; m_colorToPlay = gm.Color; //������ɫ //�����ȫ����� clearLabelsAndMarksOnBoard(); if (m_gmLastMove != null) repaintOneSpotNow(m_gmLastMove.Point); bDrawMark = true; Grid[p.X,p.Y].setStone(gm.Color); m_gmLastMove = new GoMove(p.X, p.Y, gm.Color, nSeq++); //����ľ�п����� setLabelsOnBoard(gm); setMarksOnBoard(gm); doDeadGroup(nextTurn(m_colorToPlay)); //��һ���Ƿ��е�Ӧ�ñ������û������ if (m_fAnyKill) appendDeadGroup(ref gm, nextTurn(m_colorToPlay)); else //���û�и���ɫ�ĵ㣬��ô�鿴��һ����ɫ { doDeadGroup(m_colorToPlay); if (m_fAnyKill) appendDeadGroup(ref gm, m_colorToPlay); } m_fAnyKill = false; optRepaint(); //�趨��һ���˵���ɫ m_colorToPlay = nextTurn(m_colorToPlay); //������Ϸ��Ϣ textBox1.Clear(); textBox1.AppendText(gm.Comment); }
/* *���ڻظ���һ������ * ��gm��lastmove���б�����������Ϣ: * 1.���β����ĵ�λ�� * 1.1 �Լ���ɫ��Ϣ * 2. lastmove store the stones got killed by current move * 3.- -��֪������Щʲô */ public void playPrev(GoMove gm) { if (m_gmLastMove == null) return;//���û����һ���� Grid[m_gmLastMove.Point.X, m_gmLastMove.Point.Y].removeStone();//ɾ������� m_gmLastMove = gameTree.peekPrev();//������һ���� if (gm.DeadGroup != null)//��������ɾ��֮����ԭ����ɾ���ĵ������ˣ���ظ� foreach (Point pt in gm.DeadGroup) { repaintOneSpotNow(pt); Grid[pt.X, pt.Y].setStone(gm.DeadGroupColor); } optRepaint();//�ػ�ͼ }
/* * ZZZZ ZZZ ZZZZ ZZ ZZZZ ZZZ ZZZZ ZZZZZZZZZ ZZ ZZZZ ZZZZZZ ZZZZ ZZZZ ZZ ZZZZZZ. * ZZZZ ZZ ZZ: * 1. ZZZZZZ ZZZ ZZZZZZZ ZZZZ ZZZZ ZZZ ZZZZZ * 1.1 ZZZZ ZZZZZZ ZZZ "ZZZZZZZZ" ZZZZZZZZZZ * 2. store the stones got killed by current move * 3. ZZZZZZZZZZ ZZZ ZZZ "ZZZZZZZZ" */ public void playPrev(GoMove gm) { return; }
/* * play the move so that the game situation is just BEFORE this move is played. * what to do: * 1. remove the current move from the board * 1.1 also remove the "lastmove" hightlight * 2. store the stones got killed by current move * 3. hightlight the new "lastmove" */ public void playPrev(GoMove gm) { Grid[m_gmLastMove.Point.X, m_gmLastMove.Point.Y].removeStone();//ɾ����ǰ�� m_gmLastMove=gameTree.peekPrev();//����һ������£��ܹ��������� if(gm.DeadGroup!=null)//�������лָ� { foreach (Point pt in gm.DeadGroup) { repaintOneSpotNow(pt); Grid[pt.X, pt.Y].setStone(gm.DeadGroupColor); } } optRepaint();//���� return; }
/* * 撤销操作 */ public void playPrev(GoMove gm) { int i = gm.Point.X; int j = gm.Point.Y; Grid[i,j].removeStone(); m_gmLastMove = gameTree.peekPrev(); if (m_gmLastMove != null) Grid[m_gmLastMove.Point.X,m_gmLastMove.Point.Y].setUpdated(); if (gm.DeadGroup != null) { System.Collections.IEnumerator myEnumerator = gm.DeadGroup.GetEnumerator(); while (myEnumerator.MoveNext()) { Point p; p = (Point)myEnumerator.Current; Grid[p.X,p.Y].setNoKilled(); Grid[p.X,p.Y].setStone(nextTurn(gm.Color)); } } optRepaint(); //Console.WriteLine("i={0},j={1} c={2}",m_gmLastMove.Point.X,m_gmLastMove.Point.Y,m_gmLastMove.Color); return; }
public void addAMove(GoMove gm) { gm.Seq = m_total ++; m_seq++; m_moves.Add(gm); }
private void MouseUpHandler(Object sender,MouseEventArgs e) { Point p; GoMove gmThisMove; p = PointToGrid(e.X,e.Y); if (!onBoard(p.X, p.Y) || !closeEnough(p,e.X, e.Y)|| Grid[p.X,p.Y].hasStone()) return; //��������Ƿ���Է������� //������Է������ӵĻ�����ô�ͷ��ã����Ҽ�¼�� gmThisMove = new GoMove(p.X, p.Y, m_colorToPlay, 0); playNext(ref gmThisMove); gameTree.addMove(gmThisMove); }
public void updateResult(GoMove gm) { }
public void playNext(ref GoMove gm) { Point p = gm.Point; m_colorToPlay = gm.Color; //下一步大颜色 //清理界面上的信息 clearLabelsAndMarksOnBoard(); if (m_gmLastMove != null) repaintOneSpotNow(m_gmLastMove.Point); bDrawMark = true; Grid[p.X,p.Y].setStone(gm.Color); m_gmLastMove = new GoMove(p.X, p.Y, gm.Color, nSeq++); //设置信息 setLabelsOnBoard(gm); setMarksOnBoard(gm); doDeadGroup(nextTurn(m_colorToPlay)); //如果没气了 if (m_fAnyKill) appendDeadGroup(ref gm, nextTurn(m_colorToPlay)); else //如果有气 { doDeadGroup(m_colorToPlay); if (m_fAnyKill) appendDeadGroup(ref gm, m_colorToPlay); } m_fAnyKill = false; optRepaint(); //切换颜色 m_colorToPlay = nextTurn(m_colorToPlay); //清理信息 textBox1.Clear(); textBox1.AppendText(gm.Comment); }
/* * ����һ����~ */ public void playPrev(GoMove gm) { Point a = gm.Point; //���Ƴ������� Grid[a.X,a.Y].removeStone(); m_gmLastMove = gameTree.peekPrev(); if (m_gmLastMove != null) Grid[m_gmLastMove.Point.X,m_gmLastMove.Point.Y].setUpdated(); //�ж��Ƿ������� �Ҳ����Լ��������� if (gm.DeadGroup != null && gm.DeadGroupColor != gm.Color) { foreach (Point p in gm.DeadGroup) { Grid[p.X,p.Y].setNoKilled(); Grid[p.X, p.Y].setStone(gm.DeadGroupColor); } } optRepaint(); return; }
/* *后退一步 */ public void playPrev(GoMove gm) { Point thepoint = gm.Point; Grid[thepoint.X,thepoint.Y].removeStone(); if (gm.DeadGroup) { int thecount = gm.DeadGroup.Count; thecount = gm.DeadGroup.Capacity; System.Collections.IEnumerator theenum = gm.DeadGroup.GetEnumerator(); while (theenum.MoveNext()) { thepoint = (Point)theenum.Current; Grid[thepoint.X,thepoint.Y].setStone(gm.DeadGroupColor); } } m_gmLastMove = gameTree.peekPrev(); if (m_gmLastMove) { repaintOneSpotNow(m_gmLastMove.Point); setLabelsOnBoard(m_gmLastMove); setMarksOnBoard(m_gmLastMove); } optRepaint(); m_colorToPlay = nextTurn(m_colorToPlay); textBox1.Clear(); if (m_gmLastMove) textBox1.AppendText(m_gmLastMove.Comment); }
private void appendDeadGroup(ref GoMove gm, StoneColor c) { ArrayList a = new ArrayList(); for (int i=0; i<nSize; i++) for (int j=0; j<nSize; j++) if (Grid[i,j].isKilled()) { Point pt = new Point(i,j); a.Add(pt); Grid[i,j].setNoKilled(); } gm.DeadGroup = a; gm.DeadGroupColor = c; }
//鼠标弹起事件 private void MouseUpHandler(Object sender,MouseEventArgs e) { Point p; GoMove gmThisMove; p = PointToGrid(e.X,e.Y); if (!onBoard(p.X, p.Y) || !closeEnough(p,e.X, e.Y)|| Grid[p.X,p.Y].hasStone()) return; //如果没有点击到界面或者点击到棋子上就返回 //放置棋子 gmThisMove = new GoMove(p.X, p.Y, m_colorToPlay, 0); playNext(ref gmThisMove); gameTree.addMove(gmThisMove); }
void recordMove(Point p, StoneColor colorToPlay) { Grid[p.X,p.Y].setStone(colorToPlay); m_gmLastMove = new GoMove(p.X, p.Y, colorToPlay, nSeq++); }
public void addMove(GoMove gm) { _currVar.addAMove(gm); }
private void setMarksOnBoard(GoMove gm) { Point p; if (null != gm.Labels) { System.Collections.IEnumerator myEnumerator = gm.Marks.GetEnumerator(); while ( myEnumerator.MoveNext() ) { p = (Point)myEnumerator.Current; Grid[p.X,p.Y].setMark(); } } }
/// 下子的处理函数 private void MouseUpHandler(Object sender,MouseEventArgs e) { Point p; GoMove gmThisMove; p = PointToGrid(e.X,e.Y); if (!onBoard(p.X, p.Y) || !closeEnough(p,e.X, e.Y)|| Grid[p.X,p.Y].hasStone()) return; //判断是否当前点击点可下子. //如果可以,新建新的一个move,play它. gmThisMove = new GoMove(p.X, p.Y, m_colorToPlay, 0); playNext(ref gmThisMove); gameTree.addMove(gmThisMove); }