Tags:
create new tag
view all tags

Homework 5 (di recupero) - Game of Life

ATTENZIONE: QUESTO ESERCIZIO E' SOLO PER CHI HA SUPERATO MENO DI 4 HOMEWORK

Si scriva un programma in assembly MIPS che implementi il Game of Life del matematico Conway.

Il programma prende in input da stdin:

  • un intero positivo g,
  • 32 stringhe binarie, ciascuna costituita da 32 bit indicati dai caratteri ascii 0 e 1, che costituiscono lo stato iniziale della matrice 32x32 di bit del Game of Life,

calcola e stampa a video altre 32 stringhe di 0 e 1 che costituiscono lo stato del Game of Life dopo g generazioni.

Regole del game of Life:

  • per ogni cella, chiamiamo V il numero totale di celle vive tra le 8 adiacenti
  • ad ogni generazione:
    • una cella viva resta viva se e solo se V=2 oppure V=3, altrimenti morirÓ
    • una cella morta nasce se e solo se V=3
  • in ogni generazione tutte le celle dipendono solo dallo stato della generazione precedente

Si assuma che:

  • 1 rappresenti la vita, 0 la morte,
  • le celle oltre i bordi della matrice siano morte.

Es.: usando (in unix) il comando:

cat test.txt | java -jar Mars4_3.jar gameoflife.asm

dove il file test.txt contiene:

10
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000001000
00000000000000000000000000000100
00000000000000000000000000011100
00000000000000000000000000000000
00000000000000000000000000000000

il programma deve stampare SOLO:

00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000000
00000000000000000000000000000001
00000000000000000000000000000011

che rappresenta la decima generazione del Game of Life a partire dallo stato iniziale fornito in input.

Suggerimenti:

  • syscall 35 vi premette di stampare un numero binario
  • syscall 12 vi permette di leggere un carattere per volta
  • una rappresentazione compatta dei 32 bit in una sola word per riga vi premette di usare operazioni logiche e maschere

Come sempre, chi “collaborerÓ” con altre N persone prenderÓ solo 1/N punti :|.

Consegna entro venerdý 14 a mezzanotte

  • rinominate il file usando la convenzione CognomeNome.asm (quindi il file del sig. Cicco Pasticcio sarÓ CiccioPasticcio.asm)
  • inviatelo tramite la pagina di consegna entro la mezzanotte di venerdý 14 giugno.
  • per inviare dovete essere registrati a twiki.

-- AndreaSterbini - 06 Jun 2013

Edit | Attach | Watch | Print version | History: r4 < r3 < r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r4 - 2013-06-10 - AndreaSterbini






 
Questo sito usa cookies, usandolo ne accettate la presenza. (CookiePolicy)
Torna al Dipartimento di Informatica
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2021 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback