Mercurial > hg > Members > tatsuki > Alice
view src/alice/test/topology/movement/SendLocation.java @ 84:4bd3178f218b working
minor change
author | sugi |
---|---|
date | Tue, 29 May 2012 17:26:23 +0900 |
parents | 909e1c9bc6fc |
children | 899b2b78ac75 |
line wrap: on
line source
package alice.test.topology.movement; import java.util.regex.Matcher; import java.util.regex.Pattern; import alice.codesegment.CodeSegment; import alice.datasegment.CommandType; import alice.datasegment.Receiver; public class SendLocation extends CodeSegment{ public Receiver nowX = ids.create(CommandType.PEEK); public Receiver host = ids.create(CommandType.PEEK); @Override public void run(){ System.out.println("SendLocation"); String name = host.asString(); Pattern pattern = Pattern.compile("^(node|cli)([0-9]+)$"); Matcher matcher = pattern.matcher(name); matcher.find(); int num = new Integer(matcher.group(2)); int x = this.nowX.asInteger(); System.out.println("X : " +(float)x/1000); float start = num * 2.0f - 3; float end = num * 2.0f - 0.9f; if (start <= (float)x/1000 && (float)x/1000<= end){ float positionX = (float)x/1000 - 2*(num -1) ; FishMovement fm = FishMovement.getInstance(); fm.setLocation(positionX , 0.0f); x++; ods.update("parent", "fishX", x); } SendLocation cs = new SendLocation(); cs.host.setKey("local","host"); cs.nowX.setKey("parent","fishX",this.nowX.index); } }