Feature #967

Random action2

Added by yexo over 9 years ago. Updated over 9 years ago.

Status:ClosedStart date:2010-05-25
Priority:NormalDue date:
Assignee:-% Done:

100%

Category:-
Target version:-

Associated revisions

Revision 500:4bed8a40075d
Added by Hirundo over 9 years ago

Add [#967]: Basic support for RandomAction2 in the AST.

Revision 500:4bed8a40075d
Added by Hirundo over 9 years ago

Add [#967]: Basic support for RandomAction2 in the AST.

Revision 501:b9b0b16aa3dc
Added by Hirundo over 9 years ago

Feature [#967]: Support for the basic features of randomized action2.

Revision 501:b9b0b16aa3dc
Added by Hirundo over 9 years ago

Feature [#967]: Support for the basic features of randomized action2.

Revision 502:a6dfa29b64eb
Added by Hirundo over 9 years ago

Add [#967]: Constants for the various triggers.

Revision 502:a6dfa29b64eb
Added by Hirundo over 9 years ago

Add [#967]: Constants for the various triggers.

Revision 503:53dfd9c7c424
Added by Hirundo over 9 years ago

Feature [#967]: Dependent or independent random chains.

Revision 503:53dfd9c7c424
Added by Hirundo over 9 years ago

Feature [#967]: Dependent or independent random chains.

Revision 505:07c01dec0dbf
Added by Hirundo over 9 years ago

Feature [#967]: Allow access of the tile-specific bits of a station or airport tile.

Revision 505:07c01dec0dbf
Added by Hirundo over 9 years ago

Feature [#967]: Allow access of the tile-specific bits of a station or airport tile.

Revision 506:2124386f087f
Added by Hirundo over 9 years ago

Feature [#967]: Allow type 0x84 for random action2, with constant parameter.

Revision 506:2124386f087f
Added by Hirundo over 9 years ago

Feature [#967]: Allow type 0x84 for random action2, with constant parameter.

Revision 507:d24ec8151c32
Added by Hirundo over 9 years ago

Feature [#967]: Allow any expression as parameter for random action2 type 0x84 (relative).

Revision 507:d24ec8151c32
Added by Hirundo over 9 years ago

Feature [#967]: Allow any expression as parameter for random action2 type 0x84 (relative).

Revision 508:ca116d5a4155
Added by Hirundo over 9 years ago

Doc [#967]: Document random-blocks in reference.html

Revision 508:ca116d5a4155
Added by Hirundo over 9 years ago

Doc [#967]: Document random-blocks in reference.html

History

#1 Updated by Hirundo over 9 years ago

Syntax suggestion:

random(<feature>, <type>, <id>, <triggers>) {
    dependent: random_x; //uses same random bits as random_x
    independent: random_y; //uses none of the random bits used by random_y
    <probability> : <id>/(return <expr>)
    //examples:
    3 : switch_z;
    4 : return 12 + 2;
}

Parameters:
<feature>,<id> like switch blocks

<type> For all features, SELF accesses the object's own random bits. For stations, these are the 16 per-station bits.
PARENT uses the bits of the lead engine (vehicles) or industry (industry tiles).
TILE uses the 4 tile-specific random bits of a station.
FORWARD_SELF, BACKWARD_SELF, BACKWARD_ENGINE, BACKWARD_SAMEID are possible for vehicles (see description of type 0x84)
It takes one parameter (example: @FORWARD_SELF(3 - 1)@) which specifies the amount to count. 
This will be a constant at first, but we can make this dynamic later. 
In that case, a preceding varaction2 is added that redirects to the random action and stores the expression in register 100, as per the specs.

<triggers> Triggers to use. May be omitted (default = 0).
Either a bitmask (@bitmask(TRIGGER_A, TRIGGER_B)@) or using bitwise-or (@TRIGGER_A | TRIGGER_B@).

#2 Updated by Hirundo over 9 years ago

  • % Done changed from 0 to 40

still todo:

type 0x84 (including usage of register 100)
accessing tile-specific bits of stations / airport tiles
dependent / independent random chains
documentation

#3 Updated by Hirundo over 9 years ago

  • % Done changed from 40 to 70

Remaining TODOs:
- Any expression as 'count', using register 0x100. A count of 0 should be done using that register as well.
- Documentation
- Regression test

#4 Updated by Hirundo over 9 years ago

  • Status changed from New to Closed
  • % Done changed from 70 to 100

Regression test is listed here: http://dev.openttdcoop.org/issues/984

Rest is done

Also available in: Atom PDF