public SwapPair(OrderedPair <A> pair, bool swaped) { mSwaped = swaped; if (swaped) { mFirst = pair.mSecond; mSecond = pair.mFirst; } else { mFirst = pair.mFirst; mSecond = pair.mSecond; } }
public Net(Func <String, bool> logger, Controller c1, Controller c2, int nodeCount, int lineCount, int firstFishkaCount, int secondFishkaCount, int width, int height) { mGameOver = false; mLogger = logger; mNode = new List <Node>(); mLine = new List <Line>(); mPairCounter = new Counter <OrderedPair <Node> >(); mPlayer1 = new Player(Color.Blue, c1, this); mPlayer2 = new Player(Color.Red, c2, this); mPlayer1.setEnemy(mPlayer2); mPlayer2.setEnemy(mPlayer1); c1.init(mPlayer1); c2.init(mPlayer2); mCurPlayer = mPlayer1; Random r = new Random(); for (int i = 0; i < firstFishkaCount; i++) { mPlayer1.add(new Fishka(mPlayer1, 50 + 50 * i, height - 80)); } for (int i = 0; i < secondFishkaCount; i++) { mPlayer2.add(new Fishka(mPlayer2, width - 50 - 50 * i, 50)); } for (int i = 0; i < nodeCount; i++) { mNode.Add(new Node(75 + r.Next(width - 150), 75 + r.Next(height - 150))); } for (int i = 0; i < nodeCount; i++) { for (int o = 0; o < lineCount; o++) { int nodeIndex = r.Next(nodeCount); SwapPair <Node> swapPair = genSwapPair(i, nodeIndex); OrderedPair <Node> orderedPair = swapPair.getOrderedPair(); int shift = mPairCounter.get(orderedPair); mPairCounter.increase(orderedPair); mLine.Add(new Line(swapPair, shift)); } } }
public SwapPair <Value> map <Value>(Func <Value> func) { OrderedPair <Value> pair = func(getOrderedPair()); return(new SwapPair <Value>(pair, mSwaped)); }