From: dsc Date: Sat, 15 Jan 2011 07:01:03 +0000 (-0800) Subject: Adds AI auto-test level. Prevents pathing from executing more than once per tick. X-Git-Url: http://git.less.ly:3516/?a=commitdiff_plain;h=8bcff5b3a2d7ea662783737cc29ad76b27d0d4e0;p=tanks.git Adds AI auto-test level. Prevents pathing from executing more than once per tick. --- diff --git a/data/types/levels.yaml b/data/types/levels.yaml index 8fda01c..44a9f2a 100644 --- a/data/types/levels.yaml +++ b/data/types/levels.yaml @@ -84,6 +84,73 @@ types: # - type: nitro # loc: [325,475] + autotest: + name: Automated AI Test + desc: AI test level. + width: 500 + height: 500 + bounds: + - [-50,-50, 600,50] + - [-50,0, 50,500] + - [501,0, 50,500] + - [-50,501, 600,50] + walls: + - type: wall + args: [300,50, 50,200] # [x,y, w,h] + - type: wall + args: [300,350, 50,100] + - type: wall + args: [100,100, 50,50] + + - type: fence + args: [360,210, 30,30] + - type: rock + args: [400,200, 25,25] + - type: rock + args: [425,225, 25,25] + - type: fence + args: [460,210, 30,30] + + - type: fence + args: [10,210, 30,30] + - type: fence + args: [110,210, 30,30] + - type: fence + args: [210,210, 30,30] + + - type: rock + args: [50,350, 50,50] + - type: rock + args: [100,350, 50,50] + - type: rock + args: [50,400, 50,50] + - type: rock + args: [100,400, 50,50] + - type: rock + args: [150,300, 50,50] + units: + - type: blue + align: 1 + loc: [425,425] + - type: blue + align: 1 + loc: [125,475] + - type: blue + align: 1 + loc: [175,425] + - type: green + align: 2 + loc: [75,25] + - type: green + align: 2 + loc: [175,25] + - type: green + align: 2 + loc: [425,125] + # items: + # - type: nitro + # loc: [325,475] + los_test: name: Line-of-Sight Test desc: LOS test level. diff --git a/src/tanks/game.cjs b/src/tanks/game.cjs index b4dd5ef..582ed8e 100644 --- a/src/tanks/game.cjs +++ b/src/tanks/game.cjs @@ -109,11 +109,12 @@ Y.subclass('Game', { var d = evt.data , self = this; + this.pathsThisTick = 0; NOW = this.NOW = d.now; ELAPSED = this.ELAPSED = d.elapsed; TICKS = this.TICKS = d.ticks; SECONDTH = this.SECONDTH = ELAPSED / 1000; - SQUARETH = this.SQUARETH = REF_SIZE * SECONDTH + SQUARETH = this.SQUARETH = REF_SIZE * SECONDTH; this.active.invoke('updateCooldowns', ELAPSED, NOW); this.active.invoke('act', ELAPSED, NOW); diff --git a/src/tanks/thing/tank.cjs b/src/tanks/thing/tank.cjs index 30c0c62..24d3a30 100644 --- a/src/tanks/thing/tank.cjs +++ b/src/tanks/thing/tank.cjs @@ -212,7 +212,7 @@ Thing.subclass('Tank', function(Tank){ this['continueMove'] = function continueMove(){ - if ( !this.currentMove || this.ai.path.ready ){ + if ( (!this.currentMove || this.ai.path.ready) && this.game.pathsThisTick < 1 ){ var target = this.game.map.findNearEnemies(this, 10000).shift(); if (target) this.calculatePath(target.loc); @@ -234,11 +234,12 @@ Thing.subclass('Tank', function(Tank){ this['calculatePath'] = function calculatePath(end){ - if ( !end || !this.ai.path.activate() ) return; + if ( !end || this.game.pathsThisTick >= 1 || !this.ai.path.activate() ) return; // this.currentMove = null; this.forceCurrentMove = false; this.currentMoveLimit = -1; + this.game.pathsThisTick++; var pm = this.game.map , start = this.loc