mirror of
https://github.com/open-thought/reasoning-gym.git
synced 2026-04-28 17:29:39 +00:00
fix: Correct sequence generation and pattern rule application logic
This commit is contained in:
parent
46601a2b8a
commit
7f27a2285c
1 changed files with 4 additions and 4 deletions
|
|
@ -46,7 +46,7 @@ class PatternRule:
|
|||
|
||||
def apply(self, sequence: List[int], position: int) -> int:
|
||||
"""Apply the rule to generate the next number"""
|
||||
result = sequence[position - 1] # Start with previous number
|
||||
result = sequence[position] # Start with current number
|
||||
|
||||
for op, param in zip(self.operations, self.parameters):
|
||||
if op == Operation.ADD:
|
||||
|
|
@ -60,8 +60,8 @@ class PatternRule:
|
|||
elif op == Operation.HALF:
|
||||
result //= 2 # Integer division
|
||||
elif op == Operation.PREV_PLUS:
|
||||
if position > 1:
|
||||
result += sequence[position - 2]
|
||||
if position > 0:
|
||||
result += sequence[position - 1]
|
||||
|
||||
return result
|
||||
|
||||
|
|
@ -180,7 +180,7 @@ class SequenceDataset:
|
|||
|
||||
# Generate remaining terms
|
||||
try:
|
||||
for i in range(1, num_terms + 1): # +1 for answer
|
||||
for i in range(num_terms): # Generate terms
|
||||
next_term = rule.apply(sequence, i)
|
||||
sequence.append(next_term)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue